#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.
Definition at line 1319 of file aio.c.
References Assert(), io_method_options, lengthof, newval, pgaio_method_ops, and pgaio_method_ops_table.
Definition at line 1190 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().
Definition at line 1328 of file aio.c.
References GUC_check_errdetail, and newval.
Definition at line 1217 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().
Definition at line 1078 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().
Definition at line 1162 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().
Definition at line 1089 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().
Definition at line 1104 of file aio.c.
References Assert(), PgAioBackend::in_batchmode, PgAioBackend::num_staged_ios, and pgaio_my_backend.
Referenced by ReadBuffersCanStartIO().
Definition at line 159 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().
Definition at line 185 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().
Definition at line 888 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().
Definition at line 339 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().
Definition at line 352 of file aio.c.
References PgAioHandle::owner_procno.
Referenced by buffer_readv_complete(), and smgr_aio_reopen().
Definition at line 925 of file aio.c.
References pgaio_io_state_get_name(), and PgAioHandle::state.
Referenced by pg_get_aios(), and pgaio_io_wait().
Definition at line 363 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().
Definition at line 480 of file aio.c.
References PgAioHandle::flags, IoMethodOps::needs_synchronous_execution, PGAIO_HF_SYNCHRONOUS, and pgaio_method_ops.
Referenced by pgaio_io_stage().
Definition at line 507 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().
Definition at line 525 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().
Definition at line 672 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().
Definition at line 237 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().
Definition at line 263 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().
Definition at line 406 of file aio.c.
References Assert(), CurrentResourceOwner, ResourceOwnerRememberAioHandle(), PgAioHandle::resowner, and PgAioHandle::resowner_node.
Referenced by pgaio_io_acquire_nb().
Definition at line 327 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().
Definition at line 421 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().
Definition at line 905 of file aio.c.
References PGAIO_HS_TOSTR_CASE.
Referenced by pgaio_io_get_state_name(), and pgaio_io_update_state().
Definition at line 383 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().
Definition at line 576 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().
Definition at line 758 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().
Definition at line 556 of file aio.c.
References PgAioHandle::generation, pg_read_barrier, and PgAioHandle::state.
Referenced by pgaio_io_wait(), and pgaio_wref_check_done().
Definition at line 931 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().
Definition at line 1285 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().
Definition at line 1120 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().
Definition at line 1002 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().
Definition at line 961 of file aio.c.
References PgAioWaitRef::aio_index, and PG_UINT32_MAX.
Referenced by AsyncReadBuffers(), BufferManagerShmemInit(), InitLocalBuffers(), StartReadBuffersImpl(), TerminateBufferIO(), and TerminateLocalBufferIO().
Definition at line 977 of file aio.c.
References PgAioWaitRef::aio_index, Assert(), and pgaio_wref_valid().
Definition at line 968 of file aio.c.
References PgAioWaitRef::aio_index, and PG_UINT32_MAX.
Referenced by InvalidateLocalBuffer(), pgaio_wref_get_id(), ProcessReadBuffersResult(), StartLocalBufferIO(), WaitIO(), and WaitReadBuffers().
Definition at line 988 of file aio.c.
References pgaio_io_from_wref(), and pgaio_io_wait().
Referenced by InvalidateLocalBuffer(), read_rel_block_ll(), StartLocalBufferIO(), WaitIO(), and WaitReadBuffers().
Definition at line 75 of file aio.c.
Referenced by AioHandleDataShmemSize(), AioHandleIOVShmemSize(), AioHandleShmemSize(), AioShmemInit(), AioShmemSize(), and pgaio_io_wait_for_free().
Definition at line 74 of file aio.c.
Referenced by pgaio_workers_enabled(), read_stream_begin_impl(), StartReadBuffersImpl(), and WaitReadBuffers().
Definition at line 64 of file aio.c.
Referenced by assign_io_method().
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().
Definition at line 93 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().
Definition at line 84 of file aio.c.
Referenced by assign_io_method().
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().