PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "miscadmin.h"
#include "storage/freespace.h"
#include "storage/fsm_internals.h"
#include "storage/smgr.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | FSMAddress |
Macros | |
#define | FSM_CATEGORIES 256 |
#define | FSM_CAT_STEP (BLCKSZ / FSM_CATEGORIES) |
#define | MaxFSMRequestSize MaxHeapTupleSize |
#define | FSM_TREE_DEPTH ((SlotsPerFSMPage >= 1626) ? 3 : 4) |
#define | FSM_ROOT_LEVEL (FSM_TREE_DEPTH - 1) |
#define | FSM_BOTTOM_LEVEL 0 |
Variables | |
static const FSMAddress | FSM_ROOT_ADDRESS = {FSM_ROOT_LEVEL, 0} |
#define FSM_BOTTOM_LEVEL 0 |
Definition at line 78 of file freespace.c.
#define FSM_CAT_STEP (BLCKSZ / FSM_CATEGORIES) |
Definition at line 65 of file freespace.c.
#define FSM_CATEGORIES 256 |
Definition at line 64 of file freespace.c.
#define FSM_ROOT_LEVEL (FSM_TREE_DEPTH - 1) |
Definition at line 77 of file freespace.c.
#define FSM_TREE_DEPTH ((SlotsPerFSMPage >= 1626) ? 3 : 4) |
Definition at line 75 of file freespace.c.
#define MaxFSMRequestSize MaxHeapTupleSize |
Definition at line 66 of file freespace.c.
BlockNumber FreeSpaceMapPrepareTruncateRel | ( | Relation | rel, |
BlockNumber | nblocks | ||
) |
Definition at line 275 of file freespace.c.
References buf, BUFFER_LOCK_EXCLUSIVE, BufferGetPage(), BufferIsValid(), END_CRIT_SECTION, FSM_FORKNUM, fsm_get_location(), fsm_logical_to_physical(), fsm_readbuf(), fsm_truncate_avail(), InRecovery, InvalidBlockNumber, LockBuffer(), log_newpage_buffer(), MarkBufferDirty(), RelationGetSmgr(), RelationNeedsWAL, smgrexists(), smgrnblocks(), START_CRIT_SECTION, UnlockReleaseBuffer(), and XLogHintBitIsNeeded.
Referenced by RelationTruncate(), and smgr_redo().
void FreeSpaceMapVacuum | ( | Relation | rel | ) |
Definition at line 358 of file freespace.c.
References FSM_ROOT_ADDRESS, fsm_vacuum_page(), and InvalidBlockNumber.
Referenced by brin_vacuum_scan(), and IndexFreeSpaceMapVacuum().
void FreeSpaceMapVacuumRange | ( | Relation | rel, |
BlockNumber | start, | ||
BlockNumber | end | ||
) |
Definition at line 377 of file freespace.c.
References FSM_ROOT_ADDRESS, fsm_vacuum_page(), and start.
Referenced by brin_doinsert(), brin_doupdate(), brin_getinsertbuffer(), lazy_scan_heap(), RelationAddBlocks(), RelationTruncate(), smgr_redo(), and terminate_brin_buildstate().
|
static |
Definition at line 926 of file freespace.c.
References BlockNumberIsValid(), MAIN_FORKNUM, RelationGetNumberOfBlocks, RelationGetSmgr(), and SMgrRelationData::smgr_cached_nblocks.
Referenced by fsm_search(), and RecordAndGetPageWithFreeSpace().
|
static |
Definition at line 629 of file freespace.c.
References BMR_REL, EB_CLEAR_SIZE_CACHE, EB_CREATE_FORK_IF_NEEDED, ExtendBufferedRelTo(), FSM_FORKNUM, and RBM_ZERO_ON_ERROR.
Referenced by fsm_readbuf().
|
static |
Definition at line 535 of file freespace.c.
References Assert, FSM_BOTTOM_LEVEL, FSMAddress::level, FSMAddress::logpageno, and SlotsPerFSMPage.
Referenced by fsm_search(), and fsm_vacuum_page().
|
static |
Definition at line 506 of file freespace.c.
References Assert, FSM_BOTTOM_LEVEL, FSMAddress::level, FSMAddress::logpageno, and SlotsPerFSMPage.
Referenced by fsm_search(), and RecordAndGetPageWithFreeSpace().
|
static |
Definition at line 491 of file freespace.c.
References FSM_BOTTOM_LEVEL, FSMAddress::level, FSMAddress::logpageno, and SlotsPerFSMPage.
Referenced by FreeSpaceMapPrepareTruncateRel(), fsm_vacuum_page(), GetRecordedFreeSpace(), RecordAndGetPageWithFreeSpace(), RecordPageWithFreeSpace(), and XLogRecordPageWithFreeSpace().
|
static |
Definition at line 517 of file freespace.c.
References Assert, FSM_ROOT_LEVEL, FSMAddress::level, FSMAddress::logpageno, and SlotsPerFSMPage.
Referenced by fsm_search(), and fsm_vacuum_page().
|
static |
Definition at line 455 of file freespace.c.
References FSM_TREE_DEPTH, FSMAddress::level, FSMAddress::logpageno, and SlotsPerFSMPage.
Referenced by FreeSpaceMapPrepareTruncateRel(), fsm_readbuf(), and XLogRecordPageWithFreeSpace().
|
static |
Definition at line 554 of file freespace.c.
References buf, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetPage(), fsm_extend(), FSM_FORKNUM, fsm_logical_to_physical(), InvalidBlockNumber, InvalidBuffer, LockBuffer(), PageInit(), PageIsNew(), RBM_ZERO_ON_ERROR, ReadBufferExtended(), RelationGetSmgr(), SMgrRelationData::smgr_cached_nblocks, smgrexists(), and smgrnblocks().
Referenced by FreeSpaceMapPrepareTruncateRel(), fsm_search(), fsm_set_and_search(), fsm_vacuum_page(), and GetRecordedFreeSpace().
|
static |
Definition at line 678 of file freespace.c.
References buf, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_SHARE, BUFFER_LOCK_UNLOCK, BufferGetPage(), BufferIsValid(), FSM_BOTTOM_LEVEL, fsm_does_block_exist(), fsm_get_child(), fsm_get_heap_blk(), fsm_get_max_avail(), fsm_get_parent(), fsm_readbuf(), FSM_ROOT_ADDRESS, FSM_ROOT_LEVEL, fsm_search_avail(), fsm_set_and_search(), fsm_set_avail(), InvalidBlockNumber, FSMAddress::level, LockBuffer(), MarkBufferDirtyHint(), ReleaseBuffer(), and UnlockReleaseBuffer().
Referenced by GetPageWithFreeSpace(), and RecordAndGetPageWithFreeSpace().
|
static |
Definition at line 646 of file freespace.c.
References buf, BUFFER_LOCK_EXCLUSIVE, BufferGetPage(), FSM_BOTTOM_LEVEL, fsm_readbuf(), fsm_search_avail(), fsm_set_avail(), FSMAddress::level, LockBuffer(), MarkBufferDirtyHint(), and UnlockReleaseBuffer().
Referenced by fsm_search(), RecordAndGetPageWithFreeSpace(), and RecordPageWithFreeSpace().
Definition at line 392 of file freespace.c.
References Assert, FSM_CAT_STEP, and MaxFSMRequestSize.
Referenced by RecordAndGetPageWithFreeSpace(), RecordPageWithFreeSpace(), and XLogRecordPageWithFreeSpace().
Definition at line 418 of file freespace.c.
References FSM_CAT_STEP, and MaxFSMRequestSize.
Referenced by GetRecordedFreeSpace().
Definition at line 432 of file freespace.c.
References elog, ERROR, FSM_CAT_STEP, and MaxFSMRequestSize.
Referenced by GetPageWithFreeSpace(), and RecordAndGetPageWithFreeSpace().
|
static |
Definition at line 812 of file freespace.c.
References Assert, buf, BUFFER_LOCK_EXCLUSIVE, BUFFER_LOCK_UNLOCK, BufferGetPage(), BufferIsValid(), CHECK_FOR_INTERRUPTS, FSM_BOTTOM_LEVEL, fsm_get_avail(), fsm_get_child(), fsm_get_location(), fsm_get_max_avail(), fsm_get_parent(), fsm_readbuf(), fsm_set_avail(), FSMAddress::level, LockBuffer(), FSMAddress::logpageno, MarkBufferDirtyHint(), PageGetContents(), ReleaseBuffer(), SlotsPerFSMPage, and start.
Referenced by FreeSpaceMapVacuum(), and FreeSpaceMapVacuumRange().
BlockNumber GetPageWithFreeSpace | ( | Relation | rel, |
Size | spaceNeeded | ||
) |
Definition at line 137 of file freespace.c.
References fsm_search(), and fsm_space_needed_to_cat().
Referenced by brin_getinsertbuffer(), GetFreeIndexPage(), and RelationGetBufferForTuple().
Size GetRecordedFreeSpace | ( | Relation | rel, |
BlockNumber | heapBlk | ||
) |
Definition at line 244 of file freespace.c.
References buf, BufferGetPage(), BufferIsValid(), fsm_get_avail(), fsm_get_location(), fsm_readbuf(), fsm_space_cat_to_avail(), and ReleaseBuffer().
Referenced by lazy_scan_new_or_empty(), pg_freespace(), and statapprox_heap().
BlockNumber RecordAndGetPageWithFreeSpace | ( | Relation | rel, |
BlockNumber | oldPage, | ||
Size | oldSpaceAvail, | ||
Size | spaceNeeded | ||
) |
Definition at line 154 of file freespace.c.
References fsm_does_block_exist(), fsm_get_heap_blk(), fsm_get_location(), fsm_search(), fsm_set_and_search(), fsm_space_avail_to_cat(), and fsm_space_needed_to_cat().
Referenced by brin_getinsertbuffer(), and RelationGetBufferForTuple().
void RecordPageWithFreeSpace | ( | Relation | rel, |
BlockNumber | heapBlk, | ||
Size | spaceAvail | ||
) |
Definition at line 194 of file freespace.c.
References fsm_get_location(), fsm_set_and_search(), and fsm_space_avail_to_cat().
Referenced by brin_doinsert(), brin_doupdate(), brin_initialize_empty_new_buffer(), brin_page_cleanup(), lazy_scan_heap(), lazy_scan_new_or_empty(), lazy_vacuum_heap_rel(), RecordFreeIndexPage(), RecordUsedIndexPage(), RelationAddBlocks(), RelationGetBufferForTuple(), and terminate_brin_buildstate().
void XLogRecordPageWithFreeSpace | ( | RelFileLocator | rlocator, |
BlockNumber | heapBlk, | ||
Size | spaceAvail | ||
) |
Definition at line 211 of file freespace.c.
References buf, BUFFER_LOCK_EXCLUSIVE, BufferGetPage(), FSM_FORKNUM, fsm_get_location(), fsm_logical_to_physical(), fsm_set_avail(), fsm_space_avail_to_cat(), InvalidBuffer, LockBuffer(), MarkBufferDirtyHint(), PageInit(), PageIsNew(), RBM_ZERO_ON_ERROR, UnlockReleaseBuffer(), and XLogReadBufferExtended().
Referenced by heap_xlog_insert(), heap_xlog_multi_insert(), heap_xlog_prune_freeze(), heap_xlog_update(), and heap_xlog_visible().
|
static |
Definition at line 91 of file freespace.c.
Referenced by FreeSpaceMapVacuum(), FreeSpaceMapVacuumRange(), and fsm_search().