|
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/injection_point.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 1322 of file aio.c.
References Assert(), lengthof, newval, pgaio_method_ops, and pgaio_method_ops_table.
| void AtEOXact_Aio | ( | bool | is_commit | ) |
Definition at line 1193 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 1331 of file aio.c.
References GUC_check_errdetail, and newval.
| void pgaio_closing_fd | ( | int | fd | ) |
Definition at line 1220 of file aio.c.
References dlist_iter::cur, dclist_container, dclist_count(), dclist_foreach, dclist_is_empty(), DEBUG2, fd(), PgAioHandle::generation, PgAioBackend::in_flight_ios, PgAioBackend::num_staged_ios, pgaio_debug, pgaio_debug_io, pgaio_io_uses_fd(), pgaio_io_wait(), pgaio_method_ops, pgaio_my_backend, pgaio_submit_staged(), and IoMethodOps::wait_on_fd_before_close.
Referenced by CloseTransientFile(), FileClose(), FreeDesc(), and LruDelete().
| void pgaio_enter_batchmode | ( | void | ) |
Definition at line 1081 of file aio.c.
References elog, ERROR, PgAioBackend::in_batchmode, and pgaio_my_backend.
Referenced by batch_start(), read_rel_block_ll(), and read_stream_look_ahead().
| void pgaio_error_cleanup | ( | void | ) |
Definition at line 1165 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 1092 of file aio.c.
References Assert(), PgAioBackend::in_batchmode, pgaio_my_backend, and pgaio_submit_staged().
Referenced by batch_end(), read_rel_block_ll(), and read_stream_look_ahead().
| bool pgaio_have_staged | ( | void | ) |
Definition at line 1107 of file aio.c.
References Assert(), PgAioBackend::in_batchmode, PgAioBackend::num_staged_ios, and pgaio_my_backend.
Referenced by ReadBuffersCanStartIO().
| PgAioHandle * pgaio_io_acquire | ( | struct ResourceOwnerData * | resowner, |
| PgAioReturn * | ret | ||
| ) |
Definition at line 162 of file aio.c.
References pgaio_io_acquire_nb(), and pgaio_io_wait_for_free().
Referenced by AsyncReadBuffers(), handle_get(), handle_get_and_error(), handle_get_release(), handle_get_twice(), and read_rel_block_ll().
| PgAioHandle * pgaio_io_acquire_nb | ( | struct ResourceOwnerData * | resowner, |
| PgAioReturn * | ret | ||
| ) |
Definition at line 188 of file aio.c.
References Assert(), dclist_container, dclist_is_empty(), dclist_pop_head_node(), elog, ERROR, PgAioBackend::handed_out_io, HOLD_INTERRUPTS, 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, RESUME_INTERRUPTS, PgAioHandle::state, and PgAioResult::status.
Referenced by AsyncReadBuffers(), and pgaio_io_acquire().
|
static |
Definition at line 891 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 342 of file aio.c.
References Assert(), PgAioCtl::io_handle_count, PgAioCtl::io_handles, and pgaio_ctl.
Referenced by pg_get_aios(), pgaio_io_wait(), pgaio_io_wait_for_free(), and pgaio_worker_submission_queue_insert().
| ProcNumber pgaio_io_get_owner | ( | PgAioHandle * | ioh | ) |
Definition at line 355 of file aio.c.
References PgAioHandle::owner_procno.
Referenced by buffer_readv_complete(), and smgr_aio_reopen().
| const char * pgaio_io_get_state_name | ( | PgAioHandle * | ioh | ) |
Definition at line 928 of file aio.c.
References pgaio_io_state_get_name(), and PgAioHandle::state.
Referenced by pg_get_aios(), and pgaio_io_wait().
| void pgaio_io_get_wref | ( | PgAioHandle * | ioh, |
| PgAioWaitRef * | iow | ||
| ) |
Definition at line 366 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.
Referenced by AsyncReadBuffers(), buffer_stage_common(), and read_rel_block_ll().
| bool pgaio_io_needs_synchronous_execution | ( | PgAioHandle * | ioh | ) |
Definition at line 483 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 510 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 528 of file aio.c.
References Assert(), ConditionVariableBroadcast(), CritSectionCount, PgAioHandle::cv, INJECTION_POINT, MyProcNumber, PgAioHandle::owner_procno, PGAIO_HS_COMPLETED_IO, PGAIO_HS_COMPLETED_SHARED, PGAIO_HS_SUBMITTED, pgaio_io_call_complete_shared(), pgaio_io_reclaim(), pgaio_io_update_state(), PgAioHandle::result, and PgAioHandle::state.
Referenced by IoWorkerMain(), and pgaio_io_perform_synchronously().
|
static |
Definition at line 675 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, HOLD_INTERRUPTS, 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, RESUME_INTERRUPTS, 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 240 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.
Referenced by AsyncReadBuffers(), handle_get_release(), and handle_release_last().
| void pgaio_io_release_resowner | ( | dlist_node * | ioh_node, |
| bool | on_error | ||
| ) |
Definition at line 266 of file aio.c.
References Assert(), dlist_container, elog, ERROR, PgAioBackend::handed_out_io, HOLD_INTERRUPTS, 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, RESUME_INTERRUPTS, PgAioHandle::state, and WARNING.
Referenced by ResourceOwnerReleaseInternal().
|
static |
Definition at line 409 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 330 of file aio.c.
References Assert(), flag(), PgAioHandle::flags, PGAIO_HS_HANDED_OUT, and PgAioHandle::state.
Referenced by AsyncReadBuffers(), mdstartreadv(), and read_rel_block_ll().
| void pgaio_io_stage | ( | PgAioHandle * | ioh, |
| PgAioOp | op | ||
| ) |
Definition at line 424 of file aio.c.
References Assert(), DEBUG3, PgAioBackend::handed_out_io, HOLD_INTERRUPTS, 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, RESUME_INTERRUPTS, PgAioBackend::staged_ios, and PgAioHandle::state.
Referenced by pgaio_io_start_readv(), and pgaio_io_start_writev().
|
static |
Definition at line 908 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 386 of file aio.c.
References Assert(), DEBUG5, INTERRUPTS_CAN_BE_PROCESSED, 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 579 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_get_id(), pgaio_io_get_state_name(), pgaio_io_reclaim(), pgaio_io_was_recycled(), pgaio_method_ops, and IoMethodOps::wait_one.
Referenced by pgaio_closing_fd(), pgaio_io_wait_for_free(), pgaio_shutdown(), and pgaio_wref_wait().
|
static |
Definition at line 761 of file aio.c.
References dclist_count(), dclist_head_element, dclist_is_empty(), DEBUG2, elog, ereport, errdetail_internal(), errmsg_internal(), 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, pg_read_barrier, 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 559 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 934 of file aio.c.
References PGAIO_RS_ERROR, PGAIO_RS_OK, PGAIO_RS_PARTIAL, PGAIO_RS_UNKNOWN, and PGAIO_RS_WARNING.
Referenced by pg_get_aios(), pgaio_io_call_complete_local(), pgaio_io_call_complete_shared(), and pgaio_io_reclaim().
| void pgaio_shutdown | ( | int | code, |
| Datum | arg | ||
| ) |
Definition at line 1288 of file aio.c.
References Assert(), AtEOXact_Aio(), dclist_count(), dclist_head_element, dclist_is_empty(), DEBUG2, PgAioHandle::generation, PgAioBackend::handed_out_io, PgAioBackend::in_flight_ios, pgaio_debug_io, pgaio_io_wait(), and pgaio_my_backend.
Referenced by pgaio_init_backend().
| void pgaio_submit_staged | ( | void | ) |
Definition at line 1123 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 AsyncReadBuffers(), pgaio_closing_fd(), pgaio_error_cleanup(), pgaio_exit_batchmode(), pgaio_io_acquire_nb(), pgaio_io_release_resowner(), pgaio_io_stage(), pgaio_io_wait_for_free(), and ReadBuffersCanStartIO().
| bool pgaio_wref_check_done | ( | PgAioWaitRef * | iow | ) |
Definition at line 1005 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().
Referenced by WaitReadBuffers().
| void pgaio_wref_clear | ( | PgAioWaitRef * | iow | ) |
Definition at line 964 of file aio.c.
References PgAioWaitRef::aio_index, and PG_UINT32_MAX.
Referenced by AsyncReadBuffers(), BufferManagerShmemInit(), InitLocalBuffers(), StartReadBuffersImpl(), TerminateBufferIO(), and TerminateLocalBufferIO().
| int pgaio_wref_get_id | ( | PgAioWaitRef * | iow | ) |
Definition at line 980 of file aio.c.
References PgAioWaitRef::aio_index, Assert(), and pgaio_wref_valid().
| bool pgaio_wref_valid | ( | PgAioWaitRef * | iow | ) |
Definition at line 971 of file aio.c.
References PgAioWaitRef::aio_index, and PG_UINT32_MAX.
Referenced by InvalidateLocalBuffer(), pgaio_wref_get_id(), ProcessReadBuffersResult(), StartLocalBufferIO(), WaitIO(), and WaitReadBuffers().
| void pgaio_wref_wait | ( | PgAioWaitRef * | iow | ) |
Definition at line 991 of file aio.c.
References pgaio_io_from_wref(), and pgaio_io_wait().
Referenced by InvalidateLocalBuffer(), read_rel_block_ll(), StartLocalBufferIO(), WaitIO(), and WaitReadBuffers().
| StaticAssertDecl | ( | lengthof(io_method_options) | = =lengthof(pgaio_method_ops_table)+1, |
| "io_method_options out of sync with pgaio_method_ops_table" | |||
| ) |
| int io_max_concurrency = -1 |
Definition at line 75 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 74 of file aio.c.
Referenced by pgaio_workers_enabled(), read_stream_begin_impl(), StartReadBuffersImpl(), and WaitReadBuffers().
| const struct config_enum_entry io_method_options[] |
| PgAioCtl* pgaio_ctl |
Definition at line 78 of file aio.c.
Referenced by AioShmemInit(), IoWorkerMain(), pg_get_aios(), pgaio_init_backend(), pgaio_io_from_wref(), pgaio_io_get_handle_data(), pgaio_io_get_id(), pgaio_io_get_iovec(), pgaio_io_get_iovec_length(), 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 96 of file aio.c.
Referenced by AioShmemInit(), AioShmemSize(), assign_io_method(), pgaio_closing_fd(), pgaio_init_backend(), pgaio_io_needs_synchronous_execution(), pgaio_io_wait(), and pgaio_submit_staged().
|
static |
Definition at line 84 of file aio.c.
Referenced by assign_io_method().
| PgAioBackend* pgaio_my_backend |
Definition at line 81 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_start(), 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().