48#include "utils/wait_event_types.h"
50#ifdef USE_INJECTION_POINTS
96#ifdef USE_INJECTION_POINTS
200 elog(
ERROR,
"API violation: Only one IO can be handed out");
246 elog(
ERROR,
"release in unexpected state");
369 "updating state to %s",
378 ioh->
state = new_state;
399 bool needs_synchronous;
424 "prepared (synchronous: %d, in_batch: %d)",
427 if (!needs_synchronous)
553 elog(
PANIC,
"waiting for own IO in wrong state: %d",
639 "reclaiming: distilled_result: (status %s, id %u, error_data %d), raw_result: %d",
729 elog(
ERROR,
"no free IOs despite no in-flight IOs");
749 elog(
ERROR,
"shouldn't get here with io:%d in state %d",
756 "waiting for free io with %d in flight",
775 elog(
PANIC,
"no idle IO after waiting for IO to terminate");
796 Assert(*ref_generation != 0);
804#define PGAIO_HS_TOSTR_CASE(sym) case PGAIO_HS_##sym: return #sym
816#undef PGAIO_HS_TOSTR_CASE
971 elog(
ERROR,
"starting batch while batch already in progress");
1012 int total_submitted = 0;
1026 total_submitted += did_submit;
1028 Assert(total_submitted == did_submit);
1033 "aio: submitted %d IOs",
1093 elog(
WARNING,
"open AIO batch at end of (sub-)transaction");
1191#ifdef USE_INJECTION_POINTS
1199 pgaio_inj_cur_handle = ioh;
1207 pgaio_inj_cur_handle = NULL;
1217pgaio_inj_io_get(
void)
1219 return pgaio_inj_cur_handle;
void pgaio_io_process_completion(PgAioHandle *ioh, int result)
bool pgaio_wref_valid(PgAioWaitRef *iow)
int pgaio_io_get_id(PgAioHandle *ioh)
PgAioBackend * pgaio_my_backend
const char * pgaio_result_status_string(PgAioResultStatus rs)
PgAioHandle * pgaio_io_acquire(struct ResourceOwnerData *resowner, PgAioReturn *ret)
void assign_io_method(int newval, void *extra)
static void pgaio_io_update_state(PgAioHandle *ioh, PgAioHandleState new_state)
void pgaio_wref_clear(PgAioWaitRef *iow)
bool pgaio_io_needs_synchronous_execution(PgAioHandle *ioh)
static void pgaio_io_wait_for_free(void)
#define PGAIO_HS_TOSTR_CASE(sym)
static const char * pgaio_io_state_get_name(PgAioHandleState s)
void pgaio_io_release_resowner(dlist_node *ioh_node, bool on_error)
static void pgaio_io_resowner_register(PgAioHandle *ioh)
static PgAioHandle * pgaio_io_from_wref(PgAioWaitRef *iow, uint64 *ref_generation)
void pgaio_io_get_wref(PgAioHandle *ioh, PgAioWaitRef *iow)
void pgaio_closing_fd(int fd)
void pgaio_io_stage(PgAioHandle *ioh, PgAioOp op)
void pgaio_io_set_flag(PgAioHandle *ioh, PgAioHandleFlags flag)
bool pgaio_have_staged(void)
const IoMethodOps * pgaio_method_ops
bool pgaio_wref_check_done(PgAioWaitRef *iow)
static const IoMethodOps *const pgaio_method_ops_table[]
static void pgaio_io_reclaim(PgAioHandle *ioh)
ProcNumber pgaio_io_get_owner(PgAioHandle *ioh)
void pgaio_enter_batchmode(void)
void pgaio_submit_staged(void)
const char * pgaio_io_get_state_name(PgAioHandle *ioh)
const struct config_enum_entry io_method_options[]
bool pgaio_io_was_recycled(PgAioHandle *ioh, uint64 ref_generation, PgAioHandleState *state)
void pgaio_io_prepare_submit(PgAioHandle *ioh)
void pgaio_wref_wait(PgAioWaitRef *iow)
void pgaio_error_cleanup(void)
void pgaio_io_release(PgAioHandle *ioh)
int pgaio_wref_get_id(PgAioWaitRef *iow)
void AtEOXact_Aio(bool is_commit)
void pgaio_shutdown(int code, Datum arg)
bool check_io_max_concurrency(int *newval, void **extra, GucSource source)
static void pgaio_io_wait(PgAioHandle *ioh, uint64 ref_generation)
void pgaio_exit_batchmode(void)
PgAioHandle * pgaio_io_acquire_nb(struct ResourceOwnerData *resowner, PgAioReturn *ret)
#define DEFAULT_IO_METHOD
void pgaio_io_call_stage(PgAioHandle *ioh)
void pgaio_io_call_complete_local(PgAioHandle *ioh)
void pgaio_io_call_complete_shared(PgAioHandle *ioh)
@ PGAIO_HS_COMPLETED_SHARED
@ PGAIO_HS_COMPLETED_LOCAL
#define pgaio_io_call_inj(ioh, injection_point)
#define pgaio_debug(elevel, msg,...)
#define pgaio_debug_io(elevel, ioh, msg,...)
#define PGAIO_SUBMIT_BATCH_SIZE
void pgaio_io_perform_synchronously(PgAioHandle *ioh)
bool pgaio_io_has_target(PgAioHandle *ioh)
#define pg_read_barrier()
#define pg_write_barrier()
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
volatile uint32 CritSectionCount
#define GUC_check_errdetail
Assert(PointerIsAligned(start, uint64))
#define dclist_container(type, membername, ptr)
#define dclist_head_element(type, membername, lhead)
static void dclist_push_tail(dclist_head *head, dlist_node *node)
static uint32 dclist_count(const dclist_head *head)
static bool dclist_is_empty(const dclist_head *head)
static void dclist_delete_from(dclist_head *head, dlist_node *node)
static dlist_node * dclist_pop_head_node(dclist_head *head)
static void dclist_push_head(dclist_head *head, dlist_node *node)
#define dlist_container(type, membername, ptr)
void InjectionPointCached(const char *name)
const IoMethodOps pgaio_sync_ops
const IoMethodOps pgaio_worker_ops
#define START_CRIT_SECTION()
#define END_CRIT_SECTION()
static rewind_source * source
static int fd(const char *x, int i)
ResourceOwner CurrentResourceOwner
void ResourceOwnerRememberAioHandle(ResourceOwner owner, struct dlist_node *ioh_node)
void ResourceOwnerForgetAioHandle(ResourceOwner owner, struct dlist_node *ioh_node)
int(* submit)(uint16 num_staged_ios, PgAioHandle **staged_ios)
void(* wait_one)(PgAioHandle *ioh, uint64 ref_generation)
bool(* needs_synchronous_execution)(PgAioHandle *ioh)
dclist_head in_flight_ios
PgAioHandle * staged_ios[PGAIO_SUBMIT_BATCH_SIZE]
PgAioHandle * handed_out_io
PgAioTargetData target_data
struct ResourceOwnerData * resowner
PgAioResult distilled_result
PgAioReturn * report_return
PgAioTargetData target_data