src/backend/storage/freespace/freespace.c
void
XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
							Size spaceAvail)
{
	int			new_cat = fsm_space_avail_to_cat(spaceAvail);
	FSMAddress	addr;
	uint16		slot;
	BlockNumber blkno;
	Buffer		buf;
	Page		page;

	/* Get the location of the FSM byte representing the heap block */
	addr = fsm_get_location(heapBlk, &slot);
	blkno = fsm_logical_to_physical(addr);

	/* If the page doesn't exist already, extend */
	buf = XLogReadBufferExtended(rnode, FSM_FORKNUM, blkno, RBM_ZERO_ON_ERROR);
	LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);

	page = BufferGetPage(buf);
	if (PageIsNew(page))
		PageInit(page, BLCKSZ, 0);

	if (fsm_set_avail(page, slot, new_cat))
		MarkBufferDirtyHint(buf, false);
	UnlockReleaseBuffer(buf);
}
/*
 * XLogRecordPageWithFreeSpace - like RecordPageWithFreeSpace, for use in
 *		WAL replay
 */
like RecordPageWithFreeSpace, for use in
WAL replay
like RecordPageWithFreeSpace for use in WAL replay
void
XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
							Size spaceAvail)
{
	int			new_cat = fsm_space_avail_to_cat(spaceAvail);
	FSMAddress	addr;
	uint16		slot;
	BlockNumber blkno;
	Buffer		buf;
	Page		page;
	addr = fsm_get_location(heapBlk, &slot);
	blkno = fsm_logical_to_physical(addr);
	buf = XLogReadBufferExtended(rnode, FSM_FORKNUM, blkno, RBM_ZERO_ON_ERROR);
	LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
	page = BufferGetPage(buf);
	if (PageIsNew(page))
		PageInit(page, BLCKSZ, 0);
	if (fsm_set_avail(page, slot, new_cat))
		MarkBufferDirtyHint(buf, false);
	UnlockReleaseBuffer(buf);
}
void XLogRecordPageWithFreeSpace ( RelFileNode rnode , BlockNumber heapBlk , Size spaceAvail ) { int new_cat = fsm_space_avail_to_cat ( spaceAvail ) ; FSMAddress addr ; uint16 slot ; BlockNumber blkno ; Buffer buf ; Page page ; addr = fsm_get_location ( heapBlk , & slot ) ; blkno = fsm_logical_to_physical ( addr ) ; buf = XLogReadBufferExtended ( rnode , FSM_FORKNUM , blkno , RBM_ZERO_ON_ERROR ) ; LockBuffer ( buf , BUFFER_LOCK_EXCLUSIVE ) ; page = BufferGetPage ( buf ) ; if ( PageIsNew ( page ) ) PageInit ( page , BLCKSZ , 0 ) ; if ( fsm_set_avail ( page , slot , new_cat ) ) MarkBufferDirtyHint ( buf , false ) ; UnlockReleaseBuffer ( buf ) ; }
XLogRecordPageWithFreeSpace - like RecordPageWithFreeSpace, for use in
              WAL replay
XLogRecordPageWithFreeSpace - like RecordPageWithFreeSpace for use in WAL replay
/* Get the location of the FSM byte representing the heap block */ /* If the page doesn't exist already, extend */