/*------------------------------------------------------------------------- * * cfs_sync.h * The CFS side of the checkpointer sync queue (see cfs_sync.c): the * file-tag layout shared with storage/sync, the fsync/unlink request * registration API and the four callbacks sync.c dispatches to. * * Kept free of the smgr bridge: the storage layer and the bgworker * register sidecar writes through this header alone. * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 2026, Diasoft * * src/include/storage/cfs/cfs_sync.h * *------------------------------------------------------------------------- */ #ifndef CFS_SYNC_H #define CFS_SYNC_H #include "postgres.h" #include "storage/cfs/cfs_path.h" #include "storage/relfilelocator.h" #include "storage/sync.h" /* * The CFS sync handler reuses the standard FileTag structure. The 'segno' * field stores the CfsFileKind value (CFS_FILE_DATA / CFS_FILE_MAP / * CFS_FILE_JOURNAL), and 'forknum' is always MAIN_FORKNUM. * ---------------------------------------------------------------- */ /* Populate a file tag describing one CFS sidecar file. */ #define INIT_CFS_FILETAG(a,xx_rlocator,xx_kind) \ ( \ memset(&(a), 0, sizeof(FileTag)), \ (a).handler = SYNC_HANDLER_CFS, \ (a).rlocator = (xx_rlocator), \ (a).forknum = MAIN_FORKNUM, \ (a).segno = (uint64) (xx_kind) \ ) /* * CFS sidecar files (.cfp/.cfsmap/.cfsjrn) register fsync and unlink * requests through the standard sync queue so that the checkpointer * fsyncs them at checkpoint time, exactly like md.c does for base * relation segments. * ---------------------------------------------------------------- */ /* fsync a CFS sidecar file identified by ftag; write path into *path. */ extern int cfs_syncfiletag(const FileTag *ftag, char *path); /* Unlink a CFS sidecar file identified by ftag; write path into *path. */ extern int cfs_unlinkfiletag(const FileTag *ftag, char *path); /* Check whether two CFS file tags refer to the same relation. */ extern bool cfs_filetagmatches(const FileTag *ftag, const FileTag *candidate); /* * cfs_register_dirty_file — register an fsync request for one sidecar * kind of a relation fork. Called by the storage layer after a write * to .cfp / .cfsjrn (TEMP relations are never registered). */ extern void cfs_register_dirty_file(RelFileLocatorBackend rlocator, ForkNumber forknum, CfsFileKind kind); /* * cfs_register_unlink_file — schedule the removal of a sidecar file after * the next checkpoint (used by cfs_smgr_unlink for permanent relations). */ extern void cfs_register_unlink_file(RelFileLocatorBackend rlocator, ForkNumber forknum, CfsFileKind kind); /* * cfs_forget_sync_requests — drop all pending fsync/unlink requests for * a relation fork (used when the relation is dropped immediately). */ extern void cfs_forget_sync_requests(RelFileLocatorBackend rlocator, ForkNumber forknum); /* * cfs_forget_database_sync_requests — drop all pending fsync/unlink * requests for every sidecar file of a whole database (used when the * database is dropped; the mirror of ForgetDatabaseSyncRequests()). */ extern void cfs_forget_database_sync_requests(Oid dbid); #endif /* CFS_SYNC_H */