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
This commit is contained in:
parent
ccf36ea258
commit
65b158ae4e
@ -465,7 +465,7 @@ static Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence,
|
|||||||
bool *hit);
|
bool *hit);
|
||||||
static bool PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy);
|
static bool PinBuffer(BufferDesc *buf, BufferAccessStrategy strategy);
|
||||||
static void PinBuffer_Locked(BufferDesc *buf);
|
static void PinBuffer_Locked(BufferDesc *buf);
|
||||||
static void UnpinBuffer(BufferDesc *buf, bool fixOwner);
|
static void UnpinBuffer(BufferDesc *buf);
|
||||||
static void BufferSync(int flags);
|
static void BufferSync(int flags);
|
||||||
static uint32 WaitBufHdrUnlocked(BufferDesc *buf);
|
static uint32 WaitBufHdrUnlocked(BufferDesc *buf);
|
||||||
static int SyncOneBuffer(int buf_id, bool skip_recently_used,
|
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 */
|
/* Drop lock/pin and loop around for another buffer */
|
||||||
LWLockRelease(BufferDescriptorGetContentLock(buf));
|
LWLockRelease(BufferDescriptorGetContentLock(buf));
|
||||||
UnpinBuffer(buf, true);
|
UnpinBuffer(buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1286,7 +1286,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
* Someone else has locked the buffer, so give it up and loop
|
* Someone else has locked the buffer, so give it up and loop
|
||||||
* back to get another one.
|
* back to get another one.
|
||||||
*/
|
*/
|
||||||
UnpinBuffer(buf, true);
|
UnpinBuffer(buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1353,7 +1353,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
* pool in the first place. First, give up the buffer we were
|
* pool in the first place. First, give up the buffer we were
|
||||||
* planning to use.
|
* planning to use.
|
||||||
*/
|
*/
|
||||||
UnpinBuffer(buf, true);
|
UnpinBuffer(buf);
|
||||||
|
|
||||||
/* Can give up that buffer's mapping partition lock now */
|
/* Can give up that buffer's mapping partition lock now */
|
||||||
if (oldPartitionLock != NULL &&
|
if (oldPartitionLock != NULL &&
|
||||||
@ -1414,7 +1414,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
|
|||||||
oldPartitionLock != newPartitionLock)
|
oldPartitionLock != newPartitionLock)
|
||||||
LWLockRelease(oldPartitionLock);
|
LWLockRelease(oldPartitionLock);
|
||||||
LWLockRelease(newPartitionLock);
|
LWLockRelease(newPartitionLock);
|
||||||
UnpinBuffer(buf, true);
|
UnpinBuffer(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1671,7 +1671,7 @@ ReleaseAndReadBuffer(Buffer buffer,
|
|||||||
BufTagMatchesRelFileLocator(&bufHdr->tag, &relation->rd_locator) &&
|
BufTagMatchesRelFileLocator(&bufHdr->tag, &relation->rd_locator) &&
|
||||||
BufTagGetForkNum(&bufHdr->tag) == forkNum)
|
BufTagGetForkNum(&bufHdr->tag) == forkNum)
|
||||||
return buffer;
|
return buffer;
|
||||||
UnpinBuffer(bufHdr, true);
|
UnpinBuffer(bufHdr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1843,13 +1843,11 @@ PinBuffer_Locked(BufferDesc *buf)
|
|||||||
/*
|
/*
|
||||||
* UnpinBuffer -- make buffer available for replacement.
|
* UnpinBuffer -- make buffer available for replacement.
|
||||||
*
|
*
|
||||||
* This should be applied only to shared buffers, never local ones.
|
* This should be applied only to shared buffers, never local ones. This
|
||||||
*
|
* always adjusts CurrentResourceOwner.
|
||||||
* Most but not all callers want CurrentResourceOwner to be adjusted.
|
|
||||||
* Those that don't should pass fixOwner = false.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
UnpinBuffer(BufferDesc *buf, bool fixOwner)
|
UnpinBuffer(BufferDesc *buf)
|
||||||
{
|
{
|
||||||
PrivateRefCountEntry *ref;
|
PrivateRefCountEntry *ref;
|
||||||
Buffer b = BufferDescriptorGetBuffer(buf);
|
Buffer b = BufferDescriptorGetBuffer(buf);
|
||||||
@ -1858,7 +1856,6 @@ UnpinBuffer(BufferDesc *buf, bool fixOwner)
|
|||||||
ref = GetPrivateRefCountEntry(b, false);
|
ref = GetPrivateRefCountEntry(b, false);
|
||||||
Assert(ref != NULL);
|
Assert(ref != NULL);
|
||||||
|
|
||||||
if (fixOwner)
|
|
||||||
ResourceOwnerForgetBuffer(CurrentResourceOwner, b);
|
ResourceOwnerForgetBuffer(CurrentResourceOwner, b);
|
||||||
|
|
||||||
Assert(ref->refcount > 0);
|
Assert(ref->refcount > 0);
|
||||||
@ -2579,7 +2576,7 @@ SyncOneBuffer(int buf_id, bool skip_recently_used, WritebackContext *wb_context)
|
|||||||
|
|
||||||
tag = bufHdr->tag;
|
tag = bufHdr->tag;
|
||||||
|
|
||||||
UnpinBuffer(bufHdr, true);
|
UnpinBuffer(bufHdr);
|
||||||
|
|
||||||
ScheduleBufferTagForWriteback(wb_context, &tag);
|
ScheduleBufferTagForWriteback(wb_context, &tag);
|
||||||
|
|
||||||
@ -3591,7 +3588,7 @@ FlushRelationBuffers(Relation rel)
|
|||||||
LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED);
|
LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED);
|
||||||
FlushBuffer(bufHdr, RelationGetSmgr(rel));
|
FlushBuffer(bufHdr, RelationGetSmgr(rel));
|
||||||
LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
|
LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
|
||||||
UnpinBuffer(bufHdr, true);
|
UnpinBuffer(bufHdr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UnlockBufHdr(bufHdr, buf_state);
|
UnlockBufHdr(bufHdr, buf_state);
|
||||||
@ -3689,7 +3686,7 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED);
|
LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED);
|
||||||
FlushBuffer(bufHdr, srelent->srel);
|
FlushBuffer(bufHdr, srelent->srel);
|
||||||
LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
|
LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
|
||||||
UnpinBuffer(bufHdr, true);
|
UnpinBuffer(bufHdr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UnlockBufHdr(bufHdr, buf_state);
|
UnlockBufHdr(bufHdr, buf_state);
|
||||||
@ -3899,7 +3896,7 @@ FlushDatabaseBuffers(Oid dbid)
|
|||||||
LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED);
|
LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_SHARED);
|
||||||
FlushBuffer(bufHdr, NULL);
|
FlushBuffer(bufHdr, NULL);
|
||||||
LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
|
LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
|
||||||
UnpinBuffer(bufHdr, true);
|
UnpinBuffer(bufHdr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UnlockBufHdr(bufHdr, buf_state);
|
UnlockBufHdr(bufHdr, buf_state);
|
||||||
@ -3945,7 +3942,7 @@ ReleaseBuffer(Buffer buffer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnpinBuffer(GetBufferDescriptor(buffer - 1), true);
|
UnpinBuffer(GetBufferDescriptor(buffer - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user