From 65b158ae4e892c2da7a5e31e2d2645e5e79a0bfd Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Fri, 30 Sep 2022 15:57:47 +0900 Subject: [PATCH] Remove useless argument from UnpinBuffer() The last caller of UnpinBuffer() that did not want to adjust CurrentResourceOwner was removed in 2d115e4, and nothing has been introduced in bufmgr.c to do the same thing since. This simplifies 10 code paths. Author: Aleksander Alekseev Reviewed-by: Nathan Bossart, Zhang Mingli, Bharath Rupireddy Discussion: https://postgr.es/m/CAJ7c6TOmmFpb6ohurLhTC7hKNJWGzdwf8s4EAtAZxD48g-e6Jw@mail.gmail.com --- src/backend/storage/buffer/bufmgr.c | 33 +++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 5b0e531f979..6b953814812 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -465,7 +465,7 @@ static Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence, bool *hit); static bool PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy); static void PinBuffer_Locked(BufferDesc *buf); -static void UnpinBuffer(BufferDesc *buf, bool fixOwner); +static void UnpinBuffer(BufferDesc *buf); static void BufferSync(int flags); static uint32 WaitBufHdrUnlocked(BufferDesc *buf); static int SyncOneBuffer(int buf_id, bool skip_recently_used, @@ -1258,7 +1258,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, { /* Drop lock/pin and loop around for another buffer */ LWLockRelease(BufferDescriptorGetContentLock(buf)); - UnpinBuffer(buf, true); + UnpinBuffer(buf); continue; } } @@ -1286,7 +1286,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, * Someone else has locked the buffer, so give it up and loop * back to get another one. */ - UnpinBuffer(buf, true); + UnpinBuffer(buf); continue; } } @@ -1353,7 +1353,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, * pool in the first place. First, give up the buffer we were * planning to use. */ - UnpinBuffer(buf, true); + UnpinBuffer(buf); /* Can give up that buffer's mapping partition lock now */ if (oldPartitionLock != NULL && @@ -1414,7 +1414,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, oldPartitionLock != newPartitionLock) LWLockRelease(oldPartitionLock); LWLockRelease(newPartitionLock); - UnpinBuffer(buf, true); + UnpinBuffer(buf); } /* @@ -1671,7 +1671,7 @@ ReleaseAndReadBuffer(Buffer buffer, BufTagMatchesRelFileLocator(&bufHdr->tag, &relation->rd_locator) && BufTagGetForkNum(&bufHdr->tag) == forkNum) return buffer; - UnpinBuffer(bufHdr, true); + UnpinBuffer(bufHdr); } } @@ -1843,13 +1843,11 @@ PinBuffer_Locked(BufferDesc *buf) /* * UnpinBuffer -- make buffer available for replacement. * - * This should be applied only to shared buffers, never local ones. - * - * Most but not all callers want CurrentResourceOwner to be adjusted. - * Those that don't should pass fixOwner = false. + * This should be applied only to shared buffers, never local ones. This + * always adjusts CurrentResourceOwner. */ static void -UnpinBuffer(BufferDesc *buf, bool fixOwner) +UnpinBuffer(BufferDesc *buf) { PrivateRefCountEntry *ref; Buffer b = BufferDescriptorGetBuffer(buf); @@ -1858,8 +1856,7 @@ UnpinBuffer(BufferDesc *buf, bool fixOwner) ref = GetPrivateRefCountEntry(b, false); Assert(ref != NULL); - if (fixOwner) - ResourceOwnerForgetBuffer(CurrentResourceOwner, b); + ResourceOwnerForgetBuffer(CurrentResourceOwner, b); Assert(ref->refcount > 0); ref->refcount--; @@ -2579,7 +2576,7 @@ SyncOneBuffer(int buf_id, bool skip_recently_used, WritebackContext *wb_context) tag = bufHdr->tag; - UnpinBuffer(bufHdr, true); + UnpinBuffer(bufHdr); ScheduleBufferTagForWriteback(wb_context, &tag); @@ -3591,7 +3588,7 @@ FlushRelationBuffers(Relation rel) LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED); FlushBuffer(bufHdr, RelationGetSmgr(rel)); LWLockRelease(BufferDescriptorGetContentLock(bufHdr)); - UnpinBuffer(bufHdr, true); + UnpinBuffer(bufHdr); } else UnlockBufHdr(bufHdr, buf_state); @@ -3689,7 +3686,7 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels) LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED); FlushBuffer(bufHdr, srelent->srel); LWLockRelease(BufferDescriptorGetContentLock(bufHdr)); - UnpinBuffer(bufHdr, true); + UnpinBuffer(bufHdr); } else UnlockBufHdr(bufHdr, buf_state); @@ -3899,7 +3896,7 @@ FlushDatabaseBuffers(Oid dbid) LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED); FlushBuffer(bufHdr, NULL); LWLockRelease(BufferDescriptorGetContentLock(bufHdr)); - UnpinBuffer(bufHdr, true); + UnpinBuffer(bufHdr); } else UnlockBufHdr(bufHdr, buf_state); @@ -3945,7 +3942,7 @@ ReleaseBuffer(Buffer buffer) return; } - UnpinBuffer(GetBufferDescriptor(buffer - 1), true); + UnpinBuffer(GetBufferDescriptor(buffer - 1)); } /*