ExtendBufferedWhat -> BufferManagerRelation.

Commit 31966b15 invented a way for functions dealing with relation
extension to accept a Relation in online code and an SMgrRelation in
recovery code.  It seems highly likely that future bufmgr.c interfaces
will face the same problem, and need to do something similar.
Generalize the names so that each interface doesn't have to re-invent
the wheel.

Back-patch to 16.  Since extension AM authors might start using the
constructor macros once 16 ships, we agreed to do the rename in 16
rather than waiting for 17.

Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKG%2B6tLD2BhpRWycEoti6LVLyQq457UL4ticP5xd8LqHySA%40mail.gmail.com
This commit is contained in:
Thomas Munro 2023-08-23 12:10:18 +12:00
parent d8cd49e992
commit f58af9f416
20 changed files with 90 additions and 90 deletions

View File

@ -386,7 +386,7 @@ BloomNewBuffer(Relation index)
}
/* Must extend the file */
buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);
return buffer;

View File

@ -848,7 +848,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo)
* whole relation will be rolled back.
*/
meta = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
meta = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
Assert(BufferGetBlockNumber(meta) == BRIN_METAPAGE_BLKNO);
@ -915,7 +915,7 @@ brinbuildempty(Relation index)
Buffer metabuf;
/* An empty BRIN index has a metapage only. */
metabuf = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
metabuf = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
/* Initialize and xlog metabuffer. */

View File

@ -569,7 +569,7 @@ revmap_physical_extend(BrinRevmap *revmap)
}
else
{
buf = ExtendBufferedRel(EB_REL(irel), MAIN_FORKNUM, NULL,
buf = ExtendBufferedRel(BMR_REL(irel), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);
if (BufferGetBlockNumber(buf) != mapBlk)
{

View File

@ -440,9 +440,9 @@ ginbuildempty(Relation index)
MetaBuffer;
/* An empty GIN index has two pages. */
MetaBuffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
MetaBuffer = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
RootBuffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
RootBuffer = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
/* Initialize and xlog metabuffer and root buffer. */

View File

@ -327,7 +327,7 @@ GinNewBuffer(Relation index)
}
/* Must extend the file */
buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);
return buffer;

View File

@ -134,7 +134,7 @@ gistbuildempty(Relation index)
Buffer buffer;
/* Initialize the root page */
buffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_SKIP_EXTENSION_LOCK | EB_LOCK_FIRST);
/* Initialize and xlog buffer */

View File

@ -877,7 +877,7 @@ gistNewBuffer(Relation r, Relation heaprel)
}
/* Must extend the file */
buffer = ExtendBufferedRel(EB_REL(r), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(r), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);
return buffer;

View File

@ -209,7 +209,7 @@ _hash_getnewbuf(Relation rel, BlockNumber blkno, ForkNumber forkNum)
/* smgr insists we explicitly extend the relation */
if (blkno == nblocks)
{
buf = ExtendBufferedRel(EB_REL(rel), forkNum, NULL,
buf = ExtendBufferedRel(BMR_REL(rel), forkNum, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
if (BufferGetBlockNumber(buf) != blkno)
elog(ERROR, "unexpected hash relation size: %u, should be %u",

View File

@ -339,7 +339,7 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
* [auto]vacuum trying to truncate later pages as REL_TRUNCATE_MINIMUM is
* way larger.
*/
first_block = ExtendBufferedRelBy(EB_REL(relation), MAIN_FORKNUM,
first_block = ExtendBufferedRelBy(BMR_REL(relation), MAIN_FORKNUM,
bistate ? bistate->strategy : NULL,
EB_LOCK_FIRST,
extend_by_pages,

View File

@ -628,7 +628,7 @@ vm_extend(Relation rel, BlockNumber vm_nblocks)
{
Buffer buf;
buf = ExtendBufferedRelTo(EB_REL(rel), VISIBILITYMAP_FORKNUM, NULL,
buf = ExtendBufferedRelTo(BMR_REL(rel), VISIBILITYMAP_FORKNUM, NULL,
EB_CREATE_FORK_IF_NEEDED |
EB_CLEAR_SIZE_CACHE,
vm_nblocks,

View File

@ -975,7 +975,7 @@ _bt_allocbuf(Relation rel, Relation heaprel)
* otherwise would make, as we can't use _bt_lockbuf() without introducing
* a race.
*/
buf = ExtendBufferedRel(EB_REL(rel), MAIN_FORKNUM, NULL, EB_LOCK_FIRST);
buf = ExtendBufferedRel(BMR_REL(rel), MAIN_FORKNUM, NULL, EB_LOCK_FIRST);
if (!RelationUsesLocalBuffers(rel))
VALGRIND_MAKE_MEM_DEFINED(BufferGetPage(buf), BLCKSZ);

View File

@ -405,7 +405,7 @@ SpGistNewBuffer(Relation index)
ReleaseBuffer(buffer);
}
buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);
return buffer;

View File

@ -524,7 +524,7 @@ XLogReadBufferExtended(RelFileLocator rlocator, ForkNumber forknum,
/* OK to extend the file */
/* we do this in recovery only - no rel-extension lock needed */
Assert(InRecovery);
buffer = ExtendBufferedRelTo(EB_SMGR(smgr, RELPERSISTENCE_PERMANENT),
buffer = ExtendBufferedRelTo(BMR_SMGR(smgr, RELPERSISTENCE_PERMANENT),
forknum,
NULL,
EB_PERFORMING_RECOVERY |

View File

@ -377,7 +377,7 @@ fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum)
/* Initialize first page of relation with special magic number */
buf = ExtendBufferedRel(EB_REL(rel), forkNum, NULL,
buf = ExtendBufferedRel(BMR_REL(rel), forkNum, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
Assert(BufferGetBlockNumber(buf) == 0);

View File

@ -451,7 +451,7 @@ static Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence,
ForkNumber forkNum, BlockNumber blockNum,
ReadBufferMode mode, BufferAccessStrategy strategy,
bool *hit);
static BlockNumber ExtendBufferedRelCommon(ExtendBufferedWhat eb,
static BlockNumber ExtendBufferedRelCommon(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
@ -459,7 +459,7 @@ static BlockNumber ExtendBufferedRelCommon(ExtendBufferedWhat eb,
BlockNumber extend_upto,
Buffer *buffers,
uint32 *extended_by);
static BlockNumber ExtendBufferedRelShared(ExtendBufferedWhat eb,
static BlockNumber ExtendBufferedRelShared(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
@ -809,7 +809,7 @@ ReadBufferWithoutRelcache(RelFileLocator rlocator, ForkNumber forkNum,
* Convenience wrapper around ExtendBufferedRelBy() extending by one block.
*/
Buffer
ExtendBufferedRel(ExtendBufferedWhat eb,
ExtendBufferedRel(BufferManagerRelation bmr,
ForkNumber forkNum,
BufferAccessStrategy strategy,
uint32 flags)
@ -817,7 +817,7 @@ ExtendBufferedRel(ExtendBufferedWhat eb,
Buffer buf;
uint32 extend_by = 1;
ExtendBufferedRelBy(eb, forkNum, strategy, flags, extend_by,
ExtendBufferedRelBy(bmr, forkNum, strategy, flags, extend_by,
&buf, &extend_by);
return buf;
@ -841,7 +841,7 @@ ExtendBufferedRel(ExtendBufferedWhat eb,
* be empty.
*/
BlockNumber
ExtendBufferedRelBy(ExtendBufferedWhat eb,
ExtendBufferedRelBy(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
@ -849,17 +849,17 @@ ExtendBufferedRelBy(ExtendBufferedWhat eb,
Buffer *buffers,
uint32 *extended_by)
{
Assert((eb.rel != NULL) != (eb.smgr != NULL));
Assert(eb.smgr == NULL || eb.relpersistence != 0);
Assert((bmr.rel != NULL) != (bmr.smgr != NULL));
Assert(bmr.smgr == NULL || bmr.relpersistence != 0);
Assert(extend_by > 0);
if (eb.smgr == NULL)
if (bmr.smgr == NULL)
{
eb.smgr = RelationGetSmgr(eb.rel);
eb.relpersistence = eb.rel->rd_rel->relpersistence;
bmr.smgr = RelationGetSmgr(bmr.rel);
bmr.relpersistence = bmr.rel->rd_rel->relpersistence;
}
return ExtendBufferedRelCommon(eb, fork, strategy, flags,
return ExtendBufferedRelCommon(bmr, fork, strategy, flags,
extend_by, InvalidBlockNumber,
buffers, extended_by);
}
@ -873,7 +873,7 @@ ExtendBufferedRelBy(ExtendBufferedWhat eb,
* crash recovery).
*/
Buffer
ExtendBufferedRelTo(ExtendBufferedWhat eb,
ExtendBufferedRelTo(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
@ -885,14 +885,14 @@ ExtendBufferedRelTo(ExtendBufferedWhat eb,
Buffer buffer = InvalidBuffer;
Buffer buffers[64];
Assert((eb.rel != NULL) != (eb.smgr != NULL));
Assert(eb.smgr == NULL || eb.relpersistence != 0);
Assert((bmr.rel != NULL) != (bmr.smgr != NULL));
Assert(bmr.smgr == NULL || bmr.relpersistence != 0);
Assert(extend_to != InvalidBlockNumber && extend_to > 0);
if (eb.smgr == NULL)
if (bmr.smgr == NULL)
{
eb.smgr = RelationGetSmgr(eb.rel);
eb.relpersistence = eb.rel->rd_rel->relpersistence;
bmr.smgr = RelationGetSmgr(bmr.rel);
bmr.relpersistence = bmr.rel->rd_rel->relpersistence;
}
/*
@ -901,21 +901,21 @@ ExtendBufferedRelTo(ExtendBufferedWhat eb,
* an smgrexists call.
*/
if ((flags & EB_CREATE_FORK_IF_NEEDED) &&
(eb.smgr->smgr_cached_nblocks[fork] == 0 ||
eb.smgr->smgr_cached_nblocks[fork] == InvalidBlockNumber) &&
!smgrexists(eb.smgr, fork))
(bmr.smgr->smgr_cached_nblocks[fork] == 0 ||
bmr.smgr->smgr_cached_nblocks[fork] == InvalidBlockNumber) &&
!smgrexists(bmr.smgr, fork))
{
LockRelationForExtension(eb.rel, ExclusiveLock);
LockRelationForExtension(bmr.rel, ExclusiveLock);
/* could have been closed while waiting for lock */
if (eb.rel)
eb.smgr = RelationGetSmgr(eb.rel);
if (bmr.rel)
bmr.smgr = RelationGetSmgr(bmr.rel);
/* recheck, fork might have been created concurrently */
if (!smgrexists(eb.smgr, fork))
smgrcreate(eb.smgr, fork, flags & EB_PERFORMING_RECOVERY);
if (!smgrexists(bmr.smgr, fork))
smgrcreate(bmr.smgr, fork, flags & EB_PERFORMING_RECOVERY);
UnlockRelationForExtension(eb.rel, ExclusiveLock);
UnlockRelationForExtension(bmr.rel, ExclusiveLock);
}
/*
@ -923,13 +923,13 @@ ExtendBufferedRelTo(ExtendBufferedWhat eb,
* kernel.
*/
if (flags & EB_CLEAR_SIZE_CACHE)
eb.smgr->smgr_cached_nblocks[fork] = InvalidBlockNumber;
bmr.smgr->smgr_cached_nblocks[fork] = InvalidBlockNumber;
/*
* Estimate how many pages we'll need to extend by. This avoids acquiring
* unnecessarily many victim buffers.
*/
current_size = smgrnblocks(eb.smgr, fork);
current_size = smgrnblocks(bmr.smgr, fork);
/*
* Since no-one else can be looking at the page contents yet, there is no
@ -948,7 +948,7 @@ ExtendBufferedRelTo(ExtendBufferedWhat eb,
if ((uint64) current_size + num_pages > extend_to)
num_pages = extend_to - current_size;
first_block = ExtendBufferedRelCommon(eb, fork, strategy, flags,
first_block = ExtendBufferedRelCommon(bmr, fork, strategy, flags,
num_pages, extend_to,
buffers, &extended_by);
@ -975,7 +975,7 @@ ExtendBufferedRelTo(ExtendBufferedWhat eb,
bool hit;
Assert(extended_by == 0);
buffer = ReadBuffer_common(eb.smgr, eb.relpersistence,
buffer = ReadBuffer_common(bmr.smgr, bmr.relpersistence,
fork, extend_to - 1, mode, strategy,
&hit);
}
@ -1019,7 +1019,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK)
flags |= EB_LOCK_FIRST;
return ExtendBufferedRel(EB_SMGR(smgr, relpersistence),
return ExtendBufferedRel(BMR_SMGR(smgr, relpersistence),
forkNum, strategy, flags);
}
@ -1779,7 +1779,7 @@ LimitAdditionalPins(uint32 *additional_pins)
* avoid duplicating the tracing and relpersistence related logic.
*/
static BlockNumber
ExtendBufferedRelCommon(ExtendBufferedWhat eb,
ExtendBufferedRelCommon(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
@ -1791,27 +1791,27 @@ ExtendBufferedRelCommon(ExtendBufferedWhat eb,
BlockNumber first_block;
TRACE_POSTGRESQL_BUFFER_EXTEND_START(fork,
eb.smgr->smgr_rlocator.locator.spcOid,
eb.smgr->smgr_rlocator.locator.dbOid,
eb.smgr->smgr_rlocator.locator.relNumber,
eb.smgr->smgr_rlocator.backend,
bmr.smgr->smgr_rlocator.locator.spcOid,
bmr.smgr->smgr_rlocator.locator.dbOid,
bmr.smgr->smgr_rlocator.locator.relNumber,
bmr.smgr->smgr_rlocator.backend,
extend_by);
if (eb.relpersistence == RELPERSISTENCE_TEMP)
first_block = ExtendBufferedRelLocal(eb, fork, flags,
if (bmr.relpersistence == RELPERSISTENCE_TEMP)
first_block = ExtendBufferedRelLocal(bmr, fork, flags,
extend_by, extend_upto,
buffers, &extend_by);
else
first_block = ExtendBufferedRelShared(eb, fork, strategy, flags,
first_block = ExtendBufferedRelShared(bmr, fork, strategy, flags,
extend_by, extend_upto,
buffers, &extend_by);
*extended_by = extend_by;
TRACE_POSTGRESQL_BUFFER_EXTEND_DONE(fork,
eb.smgr->smgr_rlocator.locator.spcOid,
eb.smgr->smgr_rlocator.locator.dbOid,
eb.smgr->smgr_rlocator.locator.relNumber,
eb.smgr->smgr_rlocator.backend,
bmr.smgr->smgr_rlocator.locator.spcOid,
bmr.smgr->smgr_rlocator.locator.dbOid,
bmr.smgr->smgr_rlocator.locator.relNumber,
bmr.smgr->smgr_rlocator.backend,
*extended_by,
first_block);
@ -1823,7 +1823,7 @@ ExtendBufferedRelCommon(ExtendBufferedWhat eb,
* shared buffers.
*/
static BlockNumber
ExtendBufferedRelShared(ExtendBufferedWhat eb,
ExtendBufferedRelShared(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
@ -1874,9 +1874,9 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
*/
if (!(flags & EB_SKIP_EXTENSION_LOCK))
{
LockRelationForExtension(eb.rel, ExclusiveLock);
if (eb.rel)
eb.smgr = RelationGetSmgr(eb.rel);
LockRelationForExtension(bmr.rel, ExclusiveLock);
if (bmr.rel)
bmr.smgr = RelationGetSmgr(bmr.rel);
}
/*
@ -1884,9 +1884,9 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
* kernel.
*/
if (flags & EB_CLEAR_SIZE_CACHE)
eb.smgr->smgr_cached_nblocks[fork] = InvalidBlockNumber;
bmr.smgr->smgr_cached_nblocks[fork] = InvalidBlockNumber;
first_block = smgrnblocks(eb.smgr, fork);
first_block = smgrnblocks(bmr.smgr, fork);
/*
* Now that we have the accurate relation size, check if the caller wants
@ -1918,7 +1918,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
if (extend_by == 0)
{
if (!(flags & EB_SKIP_EXTENSION_LOCK))
UnlockRelationForExtension(eb.rel, ExclusiveLock);
UnlockRelationForExtension(bmr.rel, ExclusiveLock);
*extended_by = extend_by;
return first_block;
}
@ -1929,7 +1929,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("cannot extend relation %s beyond %u blocks",
relpath(eb.smgr->smgr_rlocator, fork),
relpath(bmr.smgr->smgr_rlocator, fork),
MaxBlockNumber)));
/*
@ -1947,7 +1947,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
LWLock *partition_lock;
int existing_id;
InitBufferTag(&tag, &eb.smgr->smgr_rlocator.locator, fork, first_block + i);
InitBufferTag(&tag, &bmr.smgr->smgr_rlocator.locator, fork, first_block + i);
hash = BufTableHashCode(&tag);
partition_lock = BufMappingPartitionLock(hash);
@ -1996,7 +1996,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
if (valid && !PageIsNew((Page) buf_block))
ereport(ERROR,
(errmsg("unexpected data beyond EOF in block %u of relation %s",
existing_hdr->tag.blockNum, relpath(eb.smgr->smgr_rlocator, fork)),
existing_hdr->tag.blockNum, relpath(bmr.smgr->smgr_rlocator, fork)),
errhint("This has been seen to occur with buggy kernels; consider updating your system.")));
/*
@ -2030,7 +2030,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
victim_buf_hdr->tag = tag;
buf_state |= BM_TAG_VALID | BUF_USAGECOUNT_ONE;
if (eb.relpersistence == RELPERSISTENCE_PERMANENT || fork == INIT_FORKNUM)
if (bmr.relpersistence == RELPERSISTENCE_PERMANENT || fork == INIT_FORKNUM)
buf_state |= BM_PERMANENT;
UnlockBufHdr(victim_buf_hdr, buf_state);
@ -2054,7 +2054,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
*
* We don't need to set checksum for all-zero pages.
*/
smgrzeroextend(eb.smgr, fork, first_block, extend_by, false);
smgrzeroextend(bmr.smgr, fork, first_block, extend_by, false);
/*
* Release the file-extension lock; it's now OK for someone else to extend
@ -2064,7 +2064,7 @@ ExtendBufferedRelShared(ExtendBufferedWhat eb,
* take noticeable time.
*/
if (!(flags & EB_SKIP_EXTENSION_LOCK))
UnlockRelationForExtension(eb.rel, ExclusiveLock);
UnlockRelationForExtension(bmr.rel, ExclusiveLock);
pgstat_count_io_op_time(IOOBJECT_RELATION, io_context, IOOP_EXTEND,
io_start, extend_by);

View File

@ -308,7 +308,7 @@ LimitAdditionalLocalPins(uint32 *additional_pins)
* temporary buffers.
*/
BlockNumber
ExtendBufferedRelLocal(ExtendBufferedWhat eb,
ExtendBufferedRelLocal(BufferManagerRelation bmr,
ForkNumber fork,
uint32 flags,
uint32 extend_by,
@ -338,7 +338,7 @@ ExtendBufferedRelLocal(ExtendBufferedWhat eb,
MemSet((char *) buf_block, 0, BLCKSZ);
}
first_block = smgrnblocks(eb.smgr, fork);
first_block = smgrnblocks(bmr.smgr, fork);
if (extend_upto != InvalidBlockNumber)
{
@ -357,7 +357,7 @@ ExtendBufferedRelLocal(ExtendBufferedWhat eb,
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("cannot extend relation %s beyond %u blocks",
relpath(eb.smgr->smgr_rlocator, fork),
relpath(bmr.smgr->smgr_rlocator, fork),
MaxBlockNumber)));
for (int i = 0; i < extend_by; i++)
@ -371,7 +371,7 @@ ExtendBufferedRelLocal(ExtendBufferedWhat eb,
victim_buf_id = -buffers[i] - 1;
victim_buf_hdr = GetLocalBufferDescriptor(victim_buf_id);
InitBufferTag(&tag, &eb.smgr->smgr_rlocator.locator, fork, first_block + i);
InitBufferTag(&tag, &bmr.smgr->smgr_rlocator.locator, fork, first_block + i);
hresult = (LocalBufferLookupEnt *)
hash_search(LocalBufHash, (void *) &tag, HASH_ENTER, &found);
@ -411,7 +411,7 @@ ExtendBufferedRelLocal(ExtendBufferedWhat eb,
io_start = pgstat_prepare_io_time();
/* actually extend relation */
smgrzeroextend(eb.smgr, fork, first_block, extend_by, false);
smgrzeroextend(bmr.smgr, fork, first_block, extend_by, false);
pgstat_count_io_op_time(IOOBJECT_TEMP_RELATION, IOCONTEXT_NORMAL, IOOP_EXTEND,
io_start, extend_by);

View File

@ -612,7 +612,7 @@ fsm_readbuf(Relation rel, FSMAddress addr, bool extend)
static Buffer
fsm_extend(Relation rel, BlockNumber fsm_nblocks)
{
return ExtendBufferedRelTo(EB_REL(rel), FSM_FORKNUM, NULL,
return ExtendBufferedRelTo(BMR_REL(rel), FSM_FORKNUM, NULL,
EB_CREATE_FORK_IF_NEEDED |
EB_CLEAR_SIZE_CACHE,
fsm_nblocks,

View File

@ -423,7 +423,7 @@ extern PrefetchBufferResult PrefetchLocalBuffer(SMgrRelation smgr,
BlockNumber blockNum);
extern BufferDesc *LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum,
BlockNumber blockNum, bool *foundPtr);
extern BlockNumber ExtendBufferedRelLocal(ExtendBufferedWhat eb,
extern BlockNumber ExtendBufferedRelLocal(BufferManagerRelation bmr,
ForkNumber fork,
uint32 flags,
uint32 extend_by,

View File

@ -92,19 +92,19 @@ typedef enum ExtendBufferedFlags
} ExtendBufferedFlags;
/*
* To identify the relation - either relation or smgr + relpersistence has to
* be specified. Used via the EB_REL()/EB_SMGR() macros below. This allows us
* to use the same function for both crash recovery and normal operation.
* Some functions identify relations either by relation or smgr +
* relpersistence. Used via the BMR_REL()/BMR_SMGR() macros below. This
* allows us to use the same function for both recovery and normal operation.
*/
typedef struct ExtendBufferedWhat
typedef struct BufferManagerRelation
{
Relation rel;
struct SMgrRelationData *smgr;
char relpersistence;
} ExtendBufferedWhat;
} BufferManagerRelation;
#define EB_REL(p_rel) ((ExtendBufferedWhat){.rel = p_rel})
#define EB_SMGR(p_smgr, p_relpersistence) ((ExtendBufferedWhat){.smgr = p_smgr, .relpersistence = p_relpersistence})
#define BMR_REL(p_rel) ((BufferManagerRelation){.rel = p_rel})
#define BMR_SMGR(p_smgr, p_relpersistence) ((BufferManagerRelation){.smgr = p_smgr, .relpersistence = p_relpersistence})
/* forward declared, to avoid having to expose buf_internals.h here */
@ -185,18 +185,18 @@ extern void CheckBufferIsPinnedOnce(Buffer buffer);
extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation,
BlockNumber blockNum);
extern Buffer ExtendBufferedRel(ExtendBufferedWhat eb,
extern Buffer ExtendBufferedRel(BufferManagerRelation bmr,
ForkNumber forkNum,
BufferAccessStrategy strategy,
uint32 flags);
extern BlockNumber ExtendBufferedRelBy(ExtendBufferedWhat eb,
extern BlockNumber ExtendBufferedRelBy(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,
uint32 extend_by,
Buffer *buffers,
uint32 *extended_by);
extern Buffer ExtendBufferedRelTo(ExtendBufferedWhat eb,
extern Buffer ExtendBufferedRelTo(BufferManagerRelation bmr,
ForkNumber fork,
BufferAccessStrategy strategy,
uint32 flags,

View File

@ -319,6 +319,7 @@ BufferDesc
BufferDescPadded
BufferHeapTupleTableSlot
BufferLookupEnt
BufferManagerRelation
BufferStrategyControl
BufferTag
BufferUsage
@ -713,7 +714,6 @@ ExprEvalStep
ExprSetupInfo
ExprState
ExprStateEvalFunc
ExtendBufferedWhat
ExtensibleNode
ExtensibleNodeEntry
ExtensibleNodeMethods