Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8fd1a0

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

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-
elseif (info==XLOG_HINT)
85+
elseif (info==XLOG_FPI)
8686
{
8787
BkpBlock*bkp= (BkpBlock*)rec;
8888

89-
appendStringInfo(buf,"pagehint: %s block %u",
89+
appendStringInfo(buf,"full-pageimage: %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(Bufferbuffer)
7686+
XLogSaveBufferForHint(Bufferbuffer,boolbuffer_std)
76907687
{
76917688
XLogRecPtrrecptr=InvalidXLogRecPtr;
76927689
XLogRecPtrlsn;
@@ -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
returnrecptr;
@@ -8109,14 +8109,14 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
81098109
{
81108110
/* nothing to do here */
81118111
}
8112-
elseif (info==XLOG_HINT)
8112+
elseif (info==XLOG_FPI)
81138113
{
81148114
char*data;
81158115
BkpBlockbkpb;
81168116

81178117
/*
8118-
*Hint bitrecords 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 thenormal 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(Bufferbuffer)
2590+
MarkBufferDirtyHint(Bufferbuffer,boolbuffer_std)
25912591
{
25922592
volatileBufferDesc*bufHdr;
25932593
Pagepage=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
}

‎src/backend/storage/freespace/fsmpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext,
284284
exclusive_lock_held= true;
285285
}
286286
fsm_rebuild_page(page);
287-
MarkBufferDirtyHint(buf);
287+
MarkBufferDirtyHint(buf, false);
288288
gotorestart;
289289
}
290290
}

‎src/backend/utils/time/tqual.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ SetHintBits(HeapTupleHeader tuple, Buffer buffer,
121121
}
122122

123123
tuple->t_infomask |=infomask;
124-
MarkBufferDirtyHint(buffer);
124+
MarkBufferDirtyHint(buffer, true);
125125
}
126126

127127
/*

‎src/include/access/xlog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ extern bool XLogNeedsFlush(XLogRecPtr RecPtr);
267267
externintXLogFileInit(XLogSegNosegno,bool*use_existent,booluse_lock);
268268
externintXLogFileOpen(XLogSegNosegno);
269269

270-
externXLogRecPtrXLogSaveBufferForHint(Bufferbuffer);
270+
externXLogRecPtrXLogSaveBufferForHint(Bufferbuffer,boolbuffer_std);
271271

272272
externvoidCheckXLogRemoved(XLogSegNosegno,TimeLineIDtli);
273273
externvoidXLogSetAsyncXactLSN(XLogRecPtrrecord);

‎src/include/catalog/pg_control.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef struct CheckPoint
6767
#defineXLOG_RESTORE_POINT0x70
6868
#defineXLOG_FPW_CHANGE0x80
6969
#defineXLOG_END_OF_RECOVERY0x90
70-
#defineXLOG_HINT0xA0
70+
#defineXLOG_FPI0xA0
7171

7272

7373
/*

‎src/include/storage/bufmgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ extern Size BufferShmemSize(void);
204204
externvoidBufferGetTag(Bufferbuffer,RelFileNode*rnode,
205205
ForkNumber*forknum,BlockNumber*blknum);
206206

207-
externvoidMarkBufferDirtyHint(Bufferbuffer);
207+
externvoidMarkBufferDirtyHint(Bufferbuffer,boolbuffer_std);
208208

209209
externvoidUnlockBuffers(void);
210210
externvoidLockBuffer(Bufferbuffer,intmode);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp