Skip to content

Commit b8fd1a0

Browse files
committed
Add buffer_std flag to MarkBufferDirtyHint().
MarkBufferDirtyHint() writes WAL, and should know if it's got a standard buffer or not. Currently, the only callers where buffer_std is false are related to the FSM. In passing, rename XLOG_HINT to XLOG_FPI, which is more descriptive. Back-patch to 9.3.
1 parent 2bc4ab4 commit b8fd1a0

File tree

15 files changed

+29
-29
lines changed

15 files changed

+29
-29
lines changed

src/backend/access/hash/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ hashgettuple(PG_FUNCTION_ARGS)
287287
/*
288288
* Since this can be redone later if needed, mark as a hint.
289289
*/
290-
MarkBufferDirtyHint(buf);
290+
MarkBufferDirtyHint(buf, true);
291291
}
292292

293293
/*

src/backend/access/heap/pruneheap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,
262262
{
263263
((PageHeader) page)->pd_prune_xid = prstate.new_prune_xid;
264264
PageClearFull(page);
265-
MarkBufferDirtyHint(buffer);
265+
MarkBufferDirtyHint(buffer, true);
266266
}
267267
}
268268

src/backend/access/nbtree/nbtinsert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
413413
* crucial. Be sure to mark the proper buffer dirty.
414414
*/
415415
if (nbuf != InvalidBuffer)
416-
MarkBufferDirtyHint(nbuf);
416+
MarkBufferDirtyHint(nbuf, true);
417417
else
418-
MarkBufferDirtyHint(buf);
418+
MarkBufferDirtyHint(buf, true);
419419
}
420420
}
421421
}

src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ btvacuumpage(BTVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
10521052
opaque->btpo_cycleid == vstate->cycleid)
10531053
{
10541054
opaque->btpo_cycleid = 0;
1055-
MarkBufferDirtyHint(buf);
1055+
MarkBufferDirtyHint(buf, true);
10561056
}
10571057
}
10581058

src/backend/access/nbtree/nbtutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ _bt_killitems(IndexScanDesc scan, bool haveLock)
17891789
if (killedsomething)
17901790
{
17911791
opaque->btpo_flags |= BTP_HAS_GARBAGE;
1792-
MarkBufferDirtyHint(so->currPos.buf);
1792+
MarkBufferDirtyHint(so->currPos.buf, true);
17931793
}
17941794

17951795
if (!haveLock)

src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
8282
appendStringInfo(buf, "restore point: %s", xlrec->rp_name);
8383

8484
}
85-
else if (info == XLOG_HINT)
85+
else if (info == XLOG_FPI)
8686
{
8787
BkpBlock *bkp = (BkpBlock *) rec;
8888

89-
appendStringInfo(buf, "page hint: %s block %u",
89+
appendStringInfo(buf, "full-page image: %s block %u",
9090
relpathperm(bkp->node, bkp->fork),
9191
bkp->block);
9292
}

src/backend/access/transam/xlog.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7681,12 +7681,9 @@ XLogRestorePoint(const char *rpName)
76817681
* records. In that case, multiple copies of the same block would be recorded
76827682
* in separate WAL records by different backends, though that is still OK from
76837683
* a correctness perspective.
7684-
*
7685-
* Note that this only works for buffers that fit the standard page model,
7686-
* i.e. those for which buffer_std == true
76877684
*/
76887685
XLogRecPtr
7689-
XLogSaveBufferForHint(Buffer buffer)
7686+
XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
76907687
{
76917688
XLogRecPtr recptr = InvalidXLogRecPtr;
76927689
XLogRecPtr lsn;
@@ -7708,7 +7705,7 @@ XLogSaveBufferForHint(Buffer buffer)
77087705
* and reset rdata for any actual WAL record insert.
77097706
*/
77107707
rdata[0].buffer = buffer;
7711-
rdata[0].buffer_std = true;
7708+
rdata[0].buffer_std = buffer_std;
77127709

77137710
/*
77147711
* Check buffer while not holding an exclusive lock.
@@ -7722,6 +7719,9 @@ XLogSaveBufferForHint(Buffer buffer)
77227719
* Copy buffer so we don't have to worry about concurrent hint bit or
77237720
* lsn updates. We assume pd_lower/upper cannot be changed without an
77247721
* exclusive lock, so the contents bkp are not racy.
7722+
*
7723+
* With buffer_std set to false, XLogCheckBuffer() sets hole_length and
7724+
* hole_offset to 0; so the following code is safe for either case.
77257725
*/
77267726
memcpy(copied_buffer, origdata, bkpb.hole_offset);
77277727
memcpy(copied_buffer + bkpb.hole_offset,
@@ -7744,7 +7744,7 @@ XLogSaveBufferForHint(Buffer buffer)
77447744
rdata[1].buffer = InvalidBuffer;
77457745
rdata[1].next = NULL;
77467746

7747-
recptr = XLogInsert(RM_XLOG_ID, XLOG_HINT, rdata);
7747+
recptr = XLogInsert(RM_XLOG_ID, XLOG_FPI, rdata);
77487748
}
77497749

77507750
return recptr;
@@ -8109,14 +8109,14 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
81098109
{
81108110
/* nothing to do here */
81118111
}
8112-
else if (info == XLOG_HINT)
8112+
else if (info == XLOG_FPI)
81138113
{
81148114
char *data;
81158115
BkpBlock bkpb;
81168116

81178117
/*
8118-
* Hint bit records contain a backup block stored "inline" in the
8119-
* normal data since the locking when writing hint records isn't
8118+
* Full-page image (FPI) records contain a backup block stored "inline"
8119+
* in the normal data since the locking when writing hint records isn't
81208120
* sufficient to use the normal backup block mechanism, which assumes
81218121
* exclusive lock on the buffer supplied.
81228122
*

src/backend/commands/sequence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ read_seq_tuple(SeqTable elm, Relation rel, Buffer *buf, HeapTuple seqtuple)
11181118
HeapTupleHeaderSetXmax(seqtuple->t_data, InvalidTransactionId);
11191119
seqtuple->t_data->t_infomask &= ~HEAP_XMAX_COMMITTED;
11201120
seqtuple->t_data->t_infomask |= HEAP_XMAX_INVALID;
1121-
MarkBufferDirtyHint(*buf);
1121+
MarkBufferDirtyHint(*buf, true);
11221122
}
11231123

11241124
seq = (Form_pg_sequence) GETSTRUCT(seqtuple);

src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,7 @@ IncrBufferRefCount(Buffer buffer)
25872587
* (due to a race condition), so it cannot be used for important changes.
25882588
*/
25892589
void
2590-
MarkBufferDirtyHint(Buffer buffer)
2590+
MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
25912591
{
25922592
volatile BufferDesc *bufHdr;
25932593
Page page = BufferGetPage(buffer);
@@ -2671,7 +2671,7 @@ MarkBufferDirtyHint(Buffer buffer)
26712671
* rather than full transactionids.
26722672
*/
26732673
MyPgXact->delayChkpt = delayChkpt = true;
2674-
lsn = XLogSaveBufferForHint(buffer);
2674+
lsn = XLogSaveBufferForHint(buffer, buffer_std);
26752675
}
26762676

26772677
LockBufHdr(bufHdr);

src/backend/storage/freespace/freespace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
216216
PageInit(page, BLCKSZ, 0);
217217

218218
if (fsm_set_avail(page, slot, new_cat))
219-
MarkBufferDirtyHint(buf);
219+
MarkBufferDirtyHint(buf, false);
220220
UnlockReleaseBuffer(buf);
221221
}
222222

@@ -286,7 +286,7 @@ FreeSpaceMapTruncateRel(Relation rel, BlockNumber nblocks)
286286
return; /* nothing to do; the FSM was already smaller */
287287
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
288288
fsm_truncate_avail(BufferGetPage(buf), first_removed_slot);
289-
MarkBufferDirtyHint(buf);
289+
MarkBufferDirtyHint(buf, false);
290290
UnlockReleaseBuffer(buf);
291291

292292
new_nfsmblocks = fsm_logical_to_physical(first_removed_address) + 1;
@@ -619,7 +619,7 @@ fsm_set_and_search(Relation rel, FSMAddress addr, uint16 slot,
619619
page = BufferGetPage(buf);
620620

621621
if (fsm_set_avail(page, slot, newValue))
622-
MarkBufferDirtyHint(buf);
622+
MarkBufferDirtyHint(buf, false);
623623

624624
if (minValue != 0)
625625
{
@@ -770,7 +770,7 @@ fsm_vacuum_page(Relation rel, FSMAddress addr, bool *eof_p)
770770
{
771771
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
772772
fsm_set_avail(BufferGetPage(buf), slot, child_avail);
773-
MarkBufferDirtyHint(buf);
773+
MarkBufferDirtyHint(buf, false);
774774
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
775775
}
776776
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy