1/*-------------------------------------------------------------------------
4 * storage manager switch public interface declarations.
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/storage/smgr.h
12 *-------------------------------------------------------------------------
23 * smgr.c maintains a table of SMgrRelation objects, which are essentially
24 * cached file handles. An SMgrRelation is created (if not already present)
25 * by smgropen(), and destroyed by smgrdestroy(). Note that neither of these
26 * operations imply I/O, they just create or destroy a hashtable entry. (But
27 * smgrdestroy() may release associated resources, such as OS-level file
30 * An SMgrRelation may be "pinned", to prevent it from being destroyed while
31 * it's in use. We use this to prevent pointers in relcache to smgr from being
32 * invalidated. SMgrRelations that are not pinned are deleted at end of
37 /* rlocator is the hashtable lookup key, so it must be first! */
41 * The following fields are reset to InvalidBlockNumber upon a cache flush
42 * event, and hold the last known size for each fork. This information is
43 * currently only reliable during recovery, since there is no cache
44 * invalidation for fork extension.
49 /* additional public fields may someday exist here */
52 * Fields below here are intended to be private to smgr.c and its
53 * submodules. Do not touch them from elsewhere.
58 * for md.c; per-fork arrays of the number of open segments
59 * (md_num_open_segs) and the segments themselves (md_seg_fds).
65 * Pinning support. If unpinned (ie. pincount == 0), 'node' is a list
66 * link in list of all unpinned SMgrRelations.
74 #define SmgrIsTemp(smgr) \
75 RelFileLocatorBackendIsTemp((smgr)->smgr_rlocator)
93 BlockNumber blocknum,
const void *buffer,
bool skipFsync);
127 smgrreadv(reln, forknum, blocknum, &buffer, 1);
132 const void *buffer,
bool skipFsync)
134 smgrwritev(reln, forknum, blocknum, &buffer, 1, skipFsync);
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
void smgrstartreadv(PgAioHandle *ioh, SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void **buffers, BlockNumber nblocks)
void smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, BlockNumber nblocks)
void smgrrelease(SMgrRelation reln)
SMgrRelation smgropen(RelFileLocator rlocator, ProcNumber backend)
void smgrdestroyall(void)
void smgrreleaseall(void)
void smgrpin(SMgrRelation reln)
void smgrunpin(SMgrRelation reln)
void smgrdosyncall(SMgrRelation *rels, int nrels)
void smgrimmedsync(SMgrRelation reln, ForkNumber forknum)
void smgrcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo)
BlockNumber smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
void smgrclose(SMgrRelation reln)
static void smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void *buffer, bool skipFsync)
uint32 smgrmaxcombine(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum)
struct SMgrRelationData SMgrRelationData
void smgrzeroextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nblocks, bool skipFsync)
void smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *old_nblocks, BlockNumber *nblocks)
PGDLLIMPORT const PgAioTargetInfo aio_smgr_target_info
bool ProcessBarrierSmgrRelease(void)
static void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void *buffer)
void smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void *buffer, bool skipFsync)
void smgrwritev(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const void **buffers, BlockNumber nblocks, bool skipFsync)
void smgrreleaserellocator(RelFileLocatorBackend rlocator)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
SMgrRelationData * SMgrRelation
void smgrreadv(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void **buffers, BlockNumber nblocks)
void smgrdounlinkall(SMgrRelation *rels, int nrels, bool isRedo)
void smgrregistersync(SMgrRelation reln, ForkNumber forknum)
bool smgrprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nblocks)
void pgaio_io_set_target_smgr(PgAioHandle *ioh, SMgrRelationData *smgr, ForkNumber forknum, BlockNumber blocknum, int nblocks, bool skip_fsync)
int md_num_open_segs[MAX_FORKNUM+1]
BlockNumber smgr_targblock
BlockNumber smgr_cached_nblocks[MAX_FORKNUM+1]
struct _MdfdVec * md_seg_fds[MAX_FORKNUM+1]
RelFileLocatorBackend smgr_rlocator