/*------------------------------------------------------------------------- * * cfs_io.h * Raw file I/O primitives shared by every CFS module: the whole-file * pread/pwrite loops with short-transfer retries and the descriptor * size query. Deliberately free of any CFS domain type — this is the * lowest layer of the subsystem, so headers like cfs_journal.h / * cfs_map_file.h / cfs_cfp.h can use it without pulling in * cfs_storage.h (the journal -> storage -> journal include cycle the * review called out). * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 2026, Diasoft * * src/include/storage/cfs/cfs_io.h * *------------------------------------------------------------------------- */ #ifndef CFS_IO_H #define CFS_IO_H #include "postgres.h" #include "storage/cfs/cfs.h" struct iovec; /* avoid including port/pg_iovec.h here */ /* * cfs_pwrite_all — write 'len' bytes to 'fd' at 'offset', retrying short * writes. Returns CFS_STORAGE_OK or CFS_STORAGE_ERROR. On failure a * WARNING with the errno context is emitted here; the caller is expected * to raise an ERROR with the file path for context. */ extern int cfs_pwrite_all(int fd, const void *buf, size_t len, off_t offset); /* * cfs_pwritev_all — the scatter/gather form of cfs_pwrite_all(): write * 'iovcnt' iovecs to 'fd' at 'offset' via pg_pwritev_with_retry (the * portable port in pg_iovec.h, never a raw pwritev), retrying short * writes and EINTR, with the same cfs_debug_fail_pwrite fault injection * and WARNING-on-failure contract as cfs_pwrite_all. Used by the D4 * vector write of RAW records (header + caller's page + zero padding), * which must not copy an 8 KiB page into a scratch buffer. */ extern int cfs_pwritev_all(int fd, const struct iovec *iov, int iovcnt, off_t offset); /* * cfs_pread_all — read exactly 'len' bytes from 'fd' at 'offset' into * buf. Returns CFS_STORAGE_OK, CFS_STORAGE_NOENT on unexpected EOF, or * CFS_STORAGE_ERROR. Also used by the shared map pool (cfs_map_pool.c) * to load .cfsmap segments. */ extern int cfs_pread_all(int fd, void *buf, size_t len, off_t offset); /* Return the current size of an open file descriptor, or -1. */ extern off_t cfs_fd_size(int fd); #endif /* CFS_IO_H */