1/*-------------------------------------------------------------------------
4 * AIO - Low Level IO Handling
6 * Functions related to associating IO operations to IO Handles and IO-method
7 * independent support functions for actually performing IO.
10 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
11 * Portions Copyright (c) 1994, Regents of the University of California
14 * src/backend/storage/aio/aio_io.c
16 *-------------------------------------------------------------------------
32/* --------------------------------------------------------------------------------
33 * Public IO related functions operating on IO Handles
34 * --------------------------------------------------------------------------------
38 * Scatter/gather IO needs to associate an iovec with the Handle. To support
39 * worker mode this data needs to be in shared memory.
65/* --------------------------------------------------------------------------------
66 * "Start" routines for individual IO operations
68 * These are called by the code actually initiating an IO, to associate the IO
69 * specific data with an AIO handle.
71 * Each of the "start" routines first needs to call pgaio_io_before_start(),
72 * then fill IO specific fields in the handle and then finally call
74 * --------------------------------------------------------------------------------
105/* --------------------------------------------------------------------------------
106 * Internal IO related functions operating on IO Handles
107 * --------------------------------------------------------------------------------
111 * Execute IO operation synchronously. This is implemented here, not in
112 * method_sync.c, because other IO methods also might use it / fall back to
141 elog(
ERROR,
"trying to execute invalid IO operation");
144 ioh->
result = result < 0 ? -errno : result;
152 * Helper function to be called by IO operation preparation functions, before
153 * any data in the handle is set. Mostly to centralize assertions.
164 * Otherwise the FDs referenced by the IO could be closed due to interrupt
171 * Could be made part of the public interface, but it's not clear there's
172 * really a use case for that.
189 return NULL;
/* silence compiler */
193 * Used to determine if an IO needs to be waited upon before the file
194 * descriptor can be closed.
211 return false;
/* silence compiler */
215 * Return the iovec and its length. Currently only expected to be used by
216 * debugging infrastructure
void pgaio_io_process_completion(PgAioHandle *ioh, int result)
PgAioBackend * pgaio_my_backend
void pgaio_io_stage(PgAioHandle *ioh, PgAioOp op)
void pgaio_io_perform_synchronously(PgAioHandle *ioh)
const char * pgaio_io_get_op_name(PgAioHandle *ioh)
void pgaio_io_start_readv(PgAioHandle *ioh, int fd, int iovcnt, uint64 offset)
PgAioOpData * pgaio_io_get_op_data(PgAioHandle *ioh)
bool pgaio_io_uses_fd(PgAioHandle *ioh, int fd)
static void pgaio_io_before_start(PgAioHandle *ioh)
PgAioOp pgaio_io_get_op(PgAioHandle *ioh)
int pgaio_io_get_iovec_length(PgAioHandle *ioh, struct iovec **iov)
void pgaio_io_start_writev(PgAioHandle *ioh, int fd, int iovcnt, uint64 offset)
int pgaio_io_get_iovec(PgAioHandle *ioh, struct iovec **iov)
bool pgaio_io_has_target(PgAioHandle *ioh)
Assert(PointerIsAligned(start, uint64))
#define INTERRUPTS_CAN_BE_PROCESSED()
#define START_CRIT_SECTION()
#define END_CRIT_SECTION()
static ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
static ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
static int fd(const char *x, int i)
PgAioHandle * handed_out_io
struct PgAioOpData::@126 read
struct PgAioOpData::@127 write
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)