From 0d5b5264f0730c168b40934a1a721dc848fe0da0 Mon Sep 17 00:00:00 2001 From: Zhao Junwang Date: Sun, 26 May 2024 15:06:58 +0800 Subject: [PATCH] Improve conditional compilation for direct I/O alignment checks Signed-off-by: Zhao Junwang --- src/backend/storage/smgr/md.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index bf0f3ca76d..fa789045a1 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -465,9 +465,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, MdfdVec *v; /* If this build supports direct I/O, the buffer must be I/O aligned. */ - if (PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ) - Assert((uintptr_t) buffer == TYPEALIGN(PG_IO_ALIGN_SIZE, buffer)); - +#if PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ + Assert((uintptr_t) buffer == TYPEALIGN(PG_IO_ALIGN_SIZE, buffer)); +#endif /* This assert is too expensive to have on normally ... */ #ifdef CHECK_WRITE_VS_EXTEND Assert(blocknum >= mdnblocks(reln, forknum)); @@ -767,12 +767,13 @@ buffers_to_iovec(struct iovec *iov, void **buffers, int nblocks) Assert(nblocks >= 1); /* If this build supports direct I/O, buffers must be I/O aligned. */ +#if PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ for (int i = 0; i < nblocks; ++i) { - if (PG_O_DIRECT != 0 && PG_IO_ALIGN_SIZE <= BLCKSZ) - Assert((uintptr_t) buffers[i] == - TYPEALIGN(PG_IO_ALIGN_SIZE, buffers[i])); + Assert((uintptr_t) buffers[i] == + TYPEALIGN(PG_IO_ALIGN_SIZE, buffers[i])); } +#endif /* Start the first iovec off with the first buffer. */ iovp = &iov[0]; -- 2.41.0