diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-07-27 13:54:37 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-07-27 13:54:37 -0400 |
commit | 3ac88fddd92cc3fd8475a2f5f33837dc18d2057b (patch) | |
tree | 5a9bc612c5fa4a58376661a8a33d3b6fbda014b6 /src/backend/storage | |
parent | 03361a368e7bf909283cc7721af004317fdabd3d (diff) | |
download | postgresql-3ac88fddd92cc3fd8475a2f5f33837dc18d2057b.tar.gz postgresql-3ac88fddd92cc3fd8475a2f5f33837dc18d2057b.zip |
Convert macros to static inline functions (buf_internals.h)
Dilip Kumar, reviewed by Vignesh C, Ashutosh Sharma, and me.
Discussion: http://postgr.es/m/CAFiTN-tYbM7D+2UGiNc2kAFMSQTa5FTeYvmg-Vj2HvPdVw2Gvg@mail.gmail.com
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/buffer/buf_init.c | 2 | ||||
-rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 16 | ||||
-rw-r--r-- | src/backend/storage/buffer/localbuf.c | 12 |
3 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 2862e9e412c..6b6264854e6 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -116,7 +116,7 @@ InitBufferPool(void) { BufferDesc *buf = GetBufferDescriptor(i); - CLEAR_BUFFERTAG(buf->tag); + ClearBufferTag(&buf->tag); pg_atomic_init_u32(&buf->state, 0); buf->wait_backend_pgprocno = INVALID_PGPROCNO; diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index b7488b5d89e..6b30138ab32 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -515,7 +515,7 @@ PrefetchSharedBuffer(SMgrRelation smgr_reln, Assert(BlockNumberIsValid(blockNum)); /* create a tag so we can lookup the buffer */ - INIT_BUFFERTAG(newTag, smgr_reln->smgr_rlocator.locator, + InitBufferTag(&newTag, &smgr_reln->smgr_rlocator.locator, forkNum, blockNum); /* determine its hash code and partition lock ID */ @@ -632,7 +632,7 @@ ReadRecentBuffer(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockN ResourceOwnerEnlargeBuffers(CurrentResourceOwner); ReservePrivateRefCountEntry(); - INIT_BUFFERTAG(tag, rlocator, forkNum, blockNum); + InitBufferTag(&tag, &rlocator, forkNum, blockNum); if (BufferIsLocal(recent_buffer)) { @@ -642,7 +642,7 @@ ReadRecentBuffer(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockN buf_state = pg_atomic_read_u32(&bufHdr->state); /* Is it still valid and holding the right tag? */ - if ((buf_state & BM_VALID) && BUFFERTAGS_EQUAL(tag, bufHdr->tag)) + if ((buf_state & BM_VALID) && BufferTagsEqual(&tag, &bufHdr->tag)) { /* * Bump buffer's ref and usage counts. This is equivalent of @@ -679,7 +679,7 @@ ReadRecentBuffer(RelFileLocator rlocator, ForkNumber forkNum, BlockNumber blockN else buf_state = LockBufHdr(bufHdr); - if ((buf_state & BM_VALID) && BUFFERTAGS_EQUAL(tag, bufHdr->tag)) + if ((buf_state & BM_VALID) && BufferTagsEqual(&tag, &bufHdr->tag)) { /* * It's now safe to pin the buffer. We can't pin first and ask @@ -1134,7 +1134,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, uint32 buf_state; /* create a tag so we can lookup the buffer */ - INIT_BUFFERTAG(newTag, smgr->smgr_rlocator.locator, forkNum, blockNum); + InitBufferTag(&newTag, &smgr->smgr_rlocator.locator, forkNum, blockNum); /* determine its hash code and partition lock ID */ newHash = BufTableHashCode(&newTag); @@ -1517,7 +1517,7 @@ retry: buf_state = LockBufHdr(buf); /* If it's changed while we were waiting for lock, do nothing */ - if (!BUFFERTAGS_EQUAL(buf->tag, oldTag)) + if (!BufferTagsEqual(&buf->tag, &oldTag)) { UnlockBufHdr(buf, buf_state); LWLockRelease(oldPartitionLock); @@ -1549,7 +1549,7 @@ retry: * linear scans of the buffer array don't think the buffer is valid. */ oldFlags = buf_state & BUF_FLAG_MASK; - CLEAR_BUFFERTAG(buf->tag); + ClearBufferTag(&buf->tag); buf_state &= ~(BUF_FLAG_MASK | BUF_USAGECOUNT_MASK); UnlockBufHdr(buf, buf_state); @@ -3365,7 +3365,7 @@ FindAndDropRelationBuffers(RelFileLocator rlocator, ForkNumber forkNum, uint32 buf_state; /* create a tag so we can lookup the buffer */ - INIT_BUFFERTAG(bufTag, rlocator, forkNum, curBlock); + InitBufferTag(&bufTag, &rlocator, forkNum, curBlock); /* determine its hash code and partition lock ID */ bufHash = BufTableHashCode(&bufTag); diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 9c038851d75..014f644bf9d 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -68,7 +68,7 @@ PrefetchLocalBuffer(SMgrRelation smgr, ForkNumber forkNum, BufferTag newTag; /* identity of requested block */ LocalBufferLookupEnt *hresult; - INIT_BUFFERTAG(newTag, smgr->smgr_rlocator.locator, forkNum, blockNum); + InitBufferTag(&newTag, &smgr->smgr_rlocator.locator, forkNum, blockNum); /* Initialize local buffers if first request in this session */ if (LocalBufHash == NULL) @@ -117,7 +117,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, bool found; uint32 buf_state; - INIT_BUFFERTAG(newTag, smgr->smgr_rlocator.locator, forkNum, blockNum); + InitBufferTag(&newTag, &smgr->smgr_rlocator.locator, forkNum, blockNum); /* Initialize local buffers if first request in this session */ if (LocalBufHash == NULL) @@ -131,7 +131,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, { b = hresult->id; bufHdr = GetLocalBufferDescriptor(b); - Assert(BUFFERTAGS_EQUAL(bufHdr->tag, newTag)); + Assert(BufferTagsEqual(&bufHdr->tag, &newTag)); #ifdef LBDEBUG fprintf(stderr, "LB ALLOC (%u,%d,%d) %d\n", smgr->smgr_rlocator.locator.relNumber, forkNum, blockNum, -b - 1); @@ -253,7 +253,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, if (!hresult) /* shouldn't happen */ elog(ERROR, "local buffer hash table corrupted"); /* mark buffer invalid just in case hash insert fails */ - CLEAR_BUFFERTAG(bufHdr->tag); + ClearBufferTag(&bufHdr->tag); buf_state &= ~(BM_VALID | BM_TAG_VALID); pg_atomic_unlocked_write_u32(&bufHdr->state, buf_state); } @@ -354,7 +354,7 @@ DropRelationLocalBuffers(RelFileLocator rlocator, ForkNumber forkNum, if (!hresult) /* shouldn't happen */ elog(ERROR, "local buffer hash table corrupted"); /* Mark buffer invalid */ - CLEAR_BUFFERTAG(bufHdr->tag); + ClearBufferTag(&bufHdr->tag); buf_state &= ~BUF_FLAG_MASK; buf_state &= ~BUF_USAGECOUNT_MASK; pg_atomic_unlocked_write_u32(&bufHdr->state, buf_state); @@ -398,7 +398,7 @@ DropRelationAllLocalBuffers(RelFileLocator rlocator) if (!hresult) /* shouldn't happen */ elog(ERROR, "local buffer hash table corrupted"); /* Mark buffer invalid */ - CLEAR_BUFFERTAG(bufHdr->tag); + ClearBufferTag(&bufHdr->tag); buf_state &= ~BUF_FLAG_MASK; buf_state &= ~BUF_USAGECOUNT_MASK; pg_atomic_unlocked_write_u32(&bufHdr->state, buf_state); |