PostgreSQL Source Code git master
|
#include "postgres.h"
#include "lib/ilist.h"
#include "miscadmin.h"
#include "port/atomics.h"
#include "storage/aio.h"
#include "storage/aio_internal.h"
#include "storage/aio_subsys.h"
#include "utils/guc.h"
#include "utils/guc_hooks.h"
#include "utils/resowner.h"
#include "utils/wait_event_types.h"
Go to the source code of this file.
Macros | |
#define | PGAIO_HS_TOSTR_CASE(sym) case PGAIO_HS_##sym: return #sym |
Variables | |
const struct config_enum_entry | io_method_options [] |
int | io_method = DEFAULT_IO_METHOD |
int | io_max_concurrency = -1 |
PgAioCtl * | pgaio_ctl |
PgAioBackend * | pgaio_my_backend |
static const IoMethodOps *const | pgaio_method_ops_table [] |
const IoMethodOps * | pgaio_method_ops |
#define PGAIO_HS_TOSTR_CASE | ( | sym | ) | case PGAIO_HS_##sym: return #sym |
void assign_io_method | ( | int | newval, |
void * | extra | ||
) |
Definition at line 1156 of file aio.c.
References Assert(), io_method_options, lengthof, newval, pgaio_method_ops, and pgaio_method_ops_table.
void AtEOXact_Aio | ( | bool | is_commit | ) |
Definition at line 1080 of file aio.c.
References Assert(), elog, PgAioBackend::in_batchmode, PgAioBackend::num_staged_ios, pgaio_error_cleanup(), pgaio_my_backend, and WARNING.
Referenced by AbortSubTransaction(), AbortTransaction(), CommitTransaction(), pgaio_shutdown(), and PrepareTransaction().
bool check_io_max_concurrency | ( | int * | newval, |
void ** | extra, | ||
GucSource | source | ||
) |
Definition at line 1165 of file aio.c.
References GUC_check_errdetail, and newval.
void pgaio_closing_fd | ( | int | fd | ) |
Definition at line 1107 of file aio.c.
References pgaio_my_backend, and pgaio_submit_staged().
void pgaio_enter_batchmode | ( | void | ) |
Definition at line 968 of file aio.c.
References elog, ERROR, PgAioBackend::in_batchmode, and pgaio_my_backend.
void pgaio_error_cleanup | ( | void | ) |
Definition at line 1052 of file aio.c.
References Assert(), PgAioBackend::in_batchmode, PgAioBackend::num_staged_ios, pgaio_my_backend, and pgaio_submit_staged().
Referenced by AbortSubTransaction(), AbortTransaction(), AtEOXact_Aio(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), pgarch_archiveXlog(), WalSndErrorCleanup(), WalSummarizerMain(), and WalWriterMain().
void pgaio_exit_batchmode | ( | void | ) |
Definition at line 979 of file aio.c.
References Assert(), PgAioBackend::in_batchmode, pgaio_my_backend, and pgaio_submit_staged().
bool pgaio_have_staged | ( | void | ) |
Definition at line 994 of file aio.c.
References Assert(), PgAioBackend::in_batchmode, PgAioBackend::num_staged_ios, and pgaio_my_backend.
PgAioHandle * pgaio_io_acquire | ( | struct ResourceOwnerData * | resowner, |
PgAioReturn * | ret | ||
) |
Definition at line 165 of file aio.c.
References pgaio_io_acquire_nb(), and pgaio_io_wait_for_free().
PgAioHandle * pgaio_io_acquire_nb | ( | struct ResourceOwnerData * | resowner, |
PgAioReturn * | ret | ||
) |
Definition at line 191 of file aio.c.
References Assert(), dclist_container, dclist_is_empty(), dclist_pop_head_node(), elog, ERROR, PgAioBackend::handed_out_io, PgAioBackend::idle_ios, MyProcNumber, PgAioBackend::num_staged_ios, PgAioHandle::owner_procno, PGAIO_HS_HANDED_OUT, PGAIO_HS_IDLE, pgaio_io_resowner_register(), pgaio_io_update_state(), pgaio_my_backend, PGAIO_RS_UNKNOWN, PGAIO_SUBMIT_BATCH_SIZE, pgaio_submit_staged(), PgAioHandle::report_return, PgAioReturn::result, PgAioHandle::state, and PgAioResult::status.
Referenced by pgaio_io_acquire().
|
static |
Definition at line 785 of file aio.c.
References PgAioWaitRef::aio_index, Assert(), PgAioWaitRef::generation_lower, PgAioWaitRef::generation_upper, PgAioCtl::io_handle_count, PgAioCtl::io_handles, and pgaio_ctl.
Referenced by pgaio_wref_check_done(), and pgaio_wref_wait().
int pgaio_io_get_id | ( | PgAioHandle * | ioh | ) |
Definition at line 322 of file aio.c.
References Assert(), PgAioCtl::io_handle_count, PgAioCtl::io_handles, and pgaio_ctl.
Referenced by pgaio_io_wait_for_free(), and pgaio_worker_submission_queue_insert().
ProcNumber pgaio_io_get_owner | ( | PgAioHandle * | ioh | ) |
Definition at line 335 of file aio.c.
References PgAioHandle::owner_procno.
const char * pgaio_io_get_state_name | ( | PgAioHandle * | ioh | ) |
Definition at line 822 of file aio.c.
References pgaio_io_state_get_name(), and PgAioHandle::state.
void pgaio_io_get_wref | ( | PgAioHandle * | ioh, |
PgAioWaitRef * | iow | ||
) |
Definition at line 346 of file aio.c.
References PgAioWaitRef::aio_index, Assert(), PgAioHandle::generation, PgAioWaitRef::generation_lower, PgAioWaitRef::generation_upper, PgAioCtl::io_handles, pgaio_ctl, PGAIO_HS_DEFINED, PGAIO_HS_HANDED_OUT, PGAIO_HS_STAGED, and PgAioHandle::state.
bool pgaio_io_needs_synchronous_execution | ( | PgAioHandle * | ioh | ) |
Definition at line 447 of file aio.c.
References PgAioHandle::flags, IoMethodOps::needs_synchronous_execution, PGAIO_HF_SYNCHRONOUS, and pgaio_method_ops.
Referenced by pgaio_io_stage().
void pgaio_io_prepare_submit | ( | PgAioHandle * | ioh | ) |
Definition at line 474 of file aio.c.
References dclist_push_tail(), PgAioBackend::in_flight_ios, PgAioHandle::node, PGAIO_HS_SUBMITTED, pgaio_io_update_state(), and pgaio_my_backend.
Referenced by pgaio_io_stage(), and pgaio_worker_submit().
void pgaio_io_process_completion | ( | PgAioHandle * | ioh, |
int | result | ||
) |
Definition at line 492 of file aio.c.
References Assert(), ConditionVariableBroadcast(), CritSectionCount, PgAioHandle::cv, MyProcNumber, PgAioHandle::owner_procno, PGAIO_HS_COMPLETED_IO, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_SUBMITTED, pgaio_io_call_complete_shared(), pgaio_io_call_inj, pgaio_io_reclaim(), pgaio_io_update_state(), PgAioHandle::result, and PgAioHandle::state.
Referenced by IoWorkerMain(), and pgaio_io_perform_synchronously().
|
static |
Definition at line 621 of file aio.c.
References Assert(), dclist_delete_from(), dclist_push_head(), DEBUG4, PgAioHandle::distilled_result, PgAioResult::error_data, PgAioHandle::flags, PgAioHandle::generation, PgAioHandle::handle_data_len, PgAioResult::id, PgAioBackend::idle_ios, PgAioBackend::in_flight_ios, MyProcNumber, PgAioHandle::node, PgAioHandle::num_callbacks, PgAioHandle::op, PgAioHandle::owner_procno, pg_write_barrier, pgaio_debug_io, PGAIO_HS_COMPLETED_LOCAL, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_HANDED_OUT, PGAIO_HS_IDLE, pgaio_io_call_complete_local(), pgaio_io_update_state(), pgaio_my_backend, PGAIO_OP_INVALID, pgaio_result_status_string(), PGAIO_RS_UNKNOWN, PGAIO_TID_INVALID, PgAioHandle::report_return, ResourceOwnerForgetAioHandle(), PgAioHandle::resowner, PgAioHandle::resowner_node, PgAioHandle::result, PgAioReturn::result, PgAioHandle::state, PgAioResult::status, PgAioHandle::target, PgAioHandle::target_data, and PgAioReturn::target_data.
Referenced by pgaio_io_process_completion(), pgaio_io_release(), pgaio_io_release_resowner(), pgaio_io_wait(), pgaio_io_wait_for_free(), and pgaio_wref_check_done().
void pgaio_io_release | ( | PgAioHandle * | ioh | ) |
Definition at line 234 of file aio.c.
References Assert(), elog, ERROR, PgAioBackend::handed_out_io, PGAIO_HS_HANDED_OUT, pgaio_io_reclaim(), pgaio_my_backend, PgAioHandle::resowner, and PgAioHandle::state.
void pgaio_io_release_resowner | ( | dlist_node * | ioh_node, |
bool | on_error | ||
) |
Definition at line 254 of file aio.c.
References Assert(), dlist_container, elog, ERROR, PgAioBackend::handed_out_io, PGAIO_HS_COMPLETED_IO, PGAIO_HS_COMPLETED_LOCAL, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_DEFINED, PGAIO_HS_HANDED_OUT, PGAIO_HS_IDLE, PGAIO_HS_STAGED, PGAIO_HS_SUBMITTED, pgaio_io_reclaim(), pgaio_my_backend, pgaio_submit_staged(), PgAioHandle::report_return, ResourceOwnerForgetAioHandle(), PgAioHandle::resowner, PgAioHandle::resowner_node, PgAioHandle::state, and WARNING.
Referenced by ResourceOwnerReleaseInternal().
|
static |
Definition at line 382 of file aio.c.
References Assert(), CurrentResourceOwner, ResourceOwnerRememberAioHandle(), PgAioHandle::resowner, and PgAioHandle::resowner_node.
Referenced by pgaio_io_acquire_nb().
void pgaio_io_set_flag | ( | PgAioHandle * | ioh, |
PgAioHandleFlags | flag | ||
) |
Definition at line 310 of file aio.c.
References Assert(), flag(), PgAioHandle::flags, PGAIO_HS_HANDED_OUT, and PgAioHandle::state.
void pgaio_io_stage | ( | PgAioHandle * | ioh, |
PgAioOp | op | ||
) |
Definition at line 397 of file aio.c.
References Assert(), DEBUG3, PgAioBackend::handed_out_io, PgAioBackend::in_batchmode, PgAioBackend::num_staged_ios, PgAioHandle::op, pgaio_debug_io, PGAIO_HS_DEFINED, PGAIO_HS_HANDED_OUT, PGAIO_HS_STAGED, pgaio_io_call_stage(), pgaio_io_has_target(), pgaio_io_needs_synchronous_execution(), pgaio_io_perform_synchronously(), pgaio_io_prepare_submit(), pgaio_io_update_state(), pgaio_my_backend, PGAIO_SUBMIT_BATCH_SIZE, pgaio_submit_staged(), PgAioHandle::result, PgAioBackend::staged_ios, and PgAioHandle::state.
Referenced by pgaio_io_prep_readv(), and pgaio_io_prep_writev().
|
static |
Definition at line 802 of file aio.c.
References PGAIO_HS_TOSTR_CASE.
Referenced by pgaio_io_get_state_name(), and pgaio_io_update_state().
|
inlinestatic |
Definition at line 366 of file aio.c.
References DEBUG5, pg_write_barrier, pgaio_debug_io, pgaio_io_state_get_name(), and PgAioHandle::state.
Referenced by pgaio_io_acquire_nb(), pgaio_io_prepare_submit(), pgaio_io_process_completion(), pgaio_io_reclaim(), and pgaio_io_stage().
|
static |
Definition at line 536 of file aio.c.
References Assert(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSleep(), PgAioHandle::cv, elog, ERROR, PgAioHandle::flags, IsUnderPostmaster, MyProcNumber, PgAioHandle::owner_procno, PANIC, PGAIO_HF_SYNCHRONOUS, PGAIO_HS_COMPLETED_IO, PGAIO_HS_COMPLETED_LOCAL, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_DEFINED, PGAIO_HS_HANDED_OUT, PGAIO_HS_IDLE, PGAIO_HS_STAGED, PGAIO_HS_SUBMITTED, pgaio_io_reclaim(), pgaio_io_was_recycled(), pgaio_method_ops, and IoMethodOps::wait_one.
Referenced by pgaio_io_wait_for_free(), pgaio_shutdown(), and pgaio_wref_wait().
|
static |
Definition at line 693 of file aio.c.
References dclist_count(), dclist_head_element, DEBUG2, elog, ERROR, PgAioHandle::generation, i, PgAioBackend::idle_ios, PgAioBackend::in_flight_ios, PgAioBackend::io_handle_off, PgAioCtl::io_handles, io_max_concurrency, PgAioBackend::num_staged_ios, PANIC, pgaio_ctl, pgaio_debug, pgaio_debug_io, PGAIO_HS_COMPLETED_IO, PGAIO_HS_COMPLETED_LOCAL, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_DEFINED, PGAIO_HS_HANDED_OUT, PGAIO_HS_IDLE, PGAIO_HS_STAGED, PGAIO_HS_SUBMITTED, pgaio_io_get_id(), pgaio_io_reclaim(), pgaio_io_wait(), pgaio_my_backend, pgaio_submit_staged(), and PgAioHandle::state.
Referenced by pgaio_io_acquire().
bool pgaio_io_was_recycled | ( | PgAioHandle * | ioh, |
uint64 | ref_generation, | ||
PgAioHandleState * | state | ||
) |
Definition at line 523 of file aio.c.
References PgAioHandle::generation, pg_read_barrier, and PgAioHandle::state.
Referenced by pgaio_io_wait(), and pgaio_wref_check_done().
const char * pgaio_result_status_string | ( | PgAioResultStatus | rs | ) |
Definition at line 828 of file aio.c.
References PGAIO_RS_ERROR, PGAIO_RS_OK, PGAIO_RS_PARTIAL, and PGAIO_RS_UNKNOWN.
Referenced by pgaio_io_call_complete_local(), pgaio_io_call_complete_shared(), and pgaio_io_reclaim().
void pgaio_shutdown | ( | int | code, |
Datum | arg | ||
) |
Definition at line 1127 of file aio.c.
References Assert(), AtEOXact_Aio(), dclist_head_element, dclist_is_empty(), PgAioHandle::generation, PgAioBackend::handed_out_io, PgAioBackend::in_flight_ios, pgaio_io_wait(), and pgaio_my_backend.
Referenced by pgaio_init_backend().
void pgaio_submit_staged | ( | void | ) |
Definition at line 1010 of file aio.c.
References Assert(), DEBUG4, END_CRIT_SECTION, PgAioBackend::num_staged_ios, pgaio_debug, pgaio_method_ops, pgaio_my_backend, PgAioBackend::staged_ios, START_CRIT_SECTION, and IoMethodOps::submit.
Referenced by pgaio_closing_fd(), pgaio_error_cleanup(), pgaio_exit_batchmode(), pgaio_io_acquire_nb(), pgaio_io_release_resowner(), pgaio_io_stage(), and pgaio_io_wait_for_free().
bool pgaio_wref_check_done | ( | PgAioWaitRef * | iow | ) |
Definition at line 897 of file aio.c.
References MyProcNumber, PgAioHandle::owner_procno, PGAIO_HS_COMPLETED_LOCAL, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_IDLE, pgaio_io_from_wref(), pgaio_io_reclaim(), and pgaio_io_was_recycled().
void pgaio_wref_clear | ( | PgAioWaitRef * | iow | ) |
Definition at line 856 of file aio.c.
References PgAioWaitRef::aio_index, and PG_UINT32_MAX.
int pgaio_wref_get_id | ( | PgAioWaitRef * | iow | ) |
Definition at line 872 of file aio.c.
References PgAioWaitRef::aio_index, Assert(), and pgaio_wref_valid().
bool pgaio_wref_valid | ( | PgAioWaitRef * | iow | ) |
Definition at line 863 of file aio.c.
References PgAioWaitRef::aio_index, and PG_UINT32_MAX.
Referenced by pgaio_wref_get_id().
void pgaio_wref_wait | ( | PgAioWaitRef * | iow | ) |
Definition at line 883 of file aio.c.
References pgaio_io_from_wref(), and pgaio_io_wait().
int io_max_concurrency = -1 |
Definition at line 73 of file aio.c.
Referenced by AioHandleDataShmemSize(), AioHandleIOVShmemSize(), AioHandleShmemSize(), AioShmemInit(), AioShmemSize(), and pgaio_io_wait_for_free().
int io_method = DEFAULT_IO_METHOD |
Definition at line 72 of file aio.c.
Referenced by pgaio_workers_enabled().
const struct config_enum_entry io_method_options[] |
Definition at line 65 of file aio.c.
Referenced by assign_io_method().
PgAioCtl* pgaio_ctl |
Definition at line 76 of file aio.c.
Referenced by AioShmemInit(), IoWorkerMain(), pgaio_init_backend(), pgaio_io_from_wref(), pgaio_io_get_handle_data(), pgaio_io_get_id(), pgaio_io_get_iovec(), pgaio_io_get_wref(), pgaio_io_perform_synchronously(), pgaio_io_set_handle_data_32(), pgaio_io_set_handle_data_64(), and pgaio_io_wait_for_free().
const IoMethodOps* pgaio_method_ops |
Definition at line 88 of file aio.c.
Referenced by AioShmemInit(), AioShmemSize(), assign_io_method(), pgaio_init_backend(), pgaio_io_needs_synchronous_execution(), pgaio_io_wait(), and pgaio_submit_staged().
|
static |
Definition at line 82 of file aio.c.
Referenced by assign_io_method().
PgAioBackend* pgaio_my_backend |
Definition at line 79 of file aio.c.
Referenced by AtEOXact_Aio(), pgaio_closing_fd(), pgaio_enter_batchmode(), pgaio_error_cleanup(), pgaio_exit_batchmode(), pgaio_have_staged(), pgaio_init_backend(), pgaio_io_acquire_nb(), pgaio_io_before_prep(), pgaio_io_prepare_submit(), pgaio_io_reclaim(), pgaio_io_release(), pgaio_io_release_resowner(), pgaio_io_stage(), pgaio_io_wait_for_free(), pgaio_shutdown(), and pgaio_submit_staged().