mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Include RelFileLocator fields individually in BufferTag.
This is preparatory work for a project to increase the number of bits in a RelFileNumber from 32 to 56. Along the way, introduce static inline accessor functions for a couple of BufferTag fields. Dilip Kumar, reviewed by me. The overall patch series has also had review at various times from Andres Freund, Ashutosh Sharma, Hannu Krosing, Vignesh C, Álvaro Herrera, and Tom Lane. Discussion: http://postgr.es/m/CAFiTN-trubju5YbWAq-BSpZ90-Z6xCVBQE8BVqXqANOZAF1Znw@mail.gmail.com
This commit is contained in:
@ -215,13 +215,13 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
|
||||
Page localpage = (char *) LocalBufHdrGetBlock(bufHdr);
|
||||
|
||||
/* Find smgr relation for buffer */
|
||||
oreln = smgropen(bufHdr->tag.rlocator, MyBackendId);
|
||||
oreln = smgropen(BufTagGetRelFileLocator(&bufHdr->tag), MyBackendId);
|
||||
|
||||
PageSetChecksumInplace(localpage, bufHdr->tag.blockNum);
|
||||
|
||||
/* And write... */
|
||||
smgrwrite(oreln,
|
||||
bufHdr->tag.forkNum,
|
||||
BufTagGetForkNum(&bufHdr->tag),
|
||||
bufHdr->tag.blockNum,
|
||||
localpage,
|
||||
false);
|
||||
@ -337,16 +337,18 @@ DropRelationLocalBuffers(RelFileLocator rlocator, ForkNumber forkNum,
|
||||
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||
|
||||
if ((buf_state & BM_TAG_VALID) &&
|
||||
RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator) &&
|
||||
bufHdr->tag.forkNum == forkNum &&
|
||||
BufTagMatchesRelFileLocator(&bufHdr->tag, &rlocator) &&
|
||||
BufTagGetForkNum(&bufHdr->tag) == forkNum &&
|
||||
bufHdr->tag.blockNum >= firstDelBlock)
|
||||
{
|
||||
if (LocalRefCount[i] != 0)
|
||||
elog(ERROR, "block %u of %s is still referenced (local %u)",
|
||||
bufHdr->tag.blockNum,
|
||||
relpathbackend(bufHdr->tag.rlocator, MyBackendId,
|
||||
bufHdr->tag.forkNum),
|
||||
relpathbackend(BufTagGetRelFileLocator(&bufHdr->tag),
|
||||
MyBackendId,
|
||||
BufTagGetForkNum(&bufHdr->tag)),
|
||||
LocalRefCount[i]);
|
||||
|
||||
/* Remove entry from hashtable */
|
||||
hresult = (LocalBufferLookupEnt *)
|
||||
hash_search(LocalBufHash, (void *) &bufHdr->tag,
|
||||
@ -383,13 +385,14 @@ DropRelationAllLocalBuffers(RelFileLocator rlocator)
|
||||
buf_state = pg_atomic_read_u32(&bufHdr->state);
|
||||
|
||||
if ((buf_state & BM_TAG_VALID) &&
|
||||
RelFileLocatorEquals(bufHdr->tag.rlocator, rlocator))
|
||||
BufTagMatchesRelFileLocator(&bufHdr->tag, &rlocator))
|
||||
{
|
||||
if (LocalRefCount[i] != 0)
|
||||
elog(ERROR, "block %u of %s is still referenced (local %u)",
|
||||
bufHdr->tag.blockNum,
|
||||
relpathbackend(bufHdr->tag.rlocator, MyBackendId,
|
||||
bufHdr->tag.forkNum),
|
||||
relpathbackend(BufTagGetRelFileLocator(&bufHdr->tag),
|
||||
MyBackendId,
|
||||
BufTagGetForkNum(&bufHdr->tag)),
|
||||
LocalRefCount[i]);
|
||||
/* Remove entry from hashtable */
|
||||
hresult = (LocalBufferLookupEnt *)
|
||||
|
Reference in New Issue
Block a user