mirror of https://github.com/postgres/postgres
This commit just does the minimal wiring up of the AIO subsystem, added in the next commit, to the rest of the system. The next commit contains more details about motivation and architecture. This commit is kept separate to make it easier to review, separating the changes across the tree, from the implementation of the new subsystem. We discussed squashing this commit with the main commit before merging AIO, but there has been a mild preference for keeping it separate. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://postgr.es/m/uvrtrknj4kdytuboidbhwclo4gxhswwcpgadptsjvjqcluzmah%40brqs62irg4dtpull/207/head
parent
65db3963ae
commit
02844012b3
@ -0,0 +1,90 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* aio.c |
||||
* AIO - Core Logic |
||||
* |
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* IDENTIFICATION |
||||
* src/backend/storage/aio/aio.c |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#include "postgres.h" |
||||
|
||||
#include "lib/ilist.h" |
||||
#include "storage/aio.h" |
||||
#include "storage/aio_subsys.h" |
||||
#include "utils/guc.h" |
||||
#include "utils/guc_hooks.h" |
||||
|
||||
|
||||
/* Options for io_method. */ |
||||
const struct config_enum_entry io_method_options[] = { |
||||
{"sync", IOMETHOD_SYNC, false}, |
||||
{NULL, 0, false} |
||||
}; |
||||
|
||||
/* GUCs */ |
||||
int io_method = DEFAULT_IO_METHOD; |
||||
int io_max_concurrency = -1; |
||||
|
||||
|
||||
|
||||
/*
|
||||
* Release IO handle during resource owner cleanup. |
||||
*/ |
||||
void |
||||
pgaio_io_release_resowner(dlist_node *ioh_node, bool on_error) |
||||
{ |
||||
} |
||||
|
||||
/*
|
||||
* Perform AIO related cleanup after an error. |
||||
* |
||||
* This should be called early in the error recovery paths, as later steps may |
||||
* need to issue AIO (e.g. to record a transaction abort WAL record). |
||||
*/ |
||||
void |
||||
pgaio_error_cleanup(void) |
||||
{ |
||||
} |
||||
|
||||
/*
|
||||
* Perform AIO related checks at (sub-)transactional boundaries. |
||||
* |
||||
* This should be called late during (sub-)transactional commit/abort, after |
||||
* all steps that might need to perform AIO, so that we can verify that the |
||||
* AIO subsystem is in a valid state at the end of a transaction. |
||||
*/ |
||||
void |
||||
AtEOXact_Aio(bool is_commit) |
||||
{ |
||||
} |
||||
|
||||
void |
||||
assign_io_method(int newval, void *extra) |
||||
{ |
||||
} |
||||
|
||||
bool |
||||
check_io_max_concurrency(int *newval, void **extra, GucSource source) |
||||
{ |
||||
if (*newval == -1) |
||||
{ |
||||
/*
|
||||
* Auto-tuning will be applied later during startup, as auto-tuning |
||||
* depends on the value of various GUCs. |
||||
*/ |
||||
return true; |
||||
} |
||||
else if (*newval == 0) |
||||
{ |
||||
GUC_check_errdetail("Only -1 or values bigger than 0 are valid."); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
@ -0,0 +1,37 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* aio_init.c |
||||
* AIO - Subsystem Initialization |
||||
* |
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* IDENTIFICATION |
||||
* src/backend/storage/aio/aio_init.c |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
|
||||
#include "postgres.h" |
||||
|
||||
#include "storage/aio_subsys.h" |
||||
|
||||
|
||||
|
||||
Size |
||||
AioShmemSize(void) |
||||
{ |
||||
Size sz = 0; |
||||
|
||||
return sz; |
||||
} |
||||
|
||||
void |
||||
AioShmemInit(void) |
||||
{ |
||||
} |
||||
|
||||
void |
||||
pgaio_init_backend(void) |
||||
{ |
||||
} |
||||
@ -1,5 +1,7 @@ |
||||
# Copyright (c) 2024-2025, PostgreSQL Global Development Group |
||||
|
||||
backend_sources += files( |
||||
'aio.c', |
||||
'aio_init.c', |
||||
'read_stream.c', |
||||
) |
||||
|
||||
@ -0,0 +1,38 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* aio.h |
||||
* Main AIO interface |
||||
* |
||||
* |
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/storage/aio.h |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef AIO_H |
||||
#define AIO_H |
||||
|
||||
|
||||
|
||||
/* Enum for io_method GUC. */ |
||||
typedef enum IoMethod |
||||
{ |
||||
IOMETHOD_SYNC = 0, |
||||
} IoMethod; |
||||
|
||||
/* We'll default to synchronous execution. */ |
||||
#define DEFAULT_IO_METHOD IOMETHOD_SYNC |
||||
|
||||
|
||||
struct dlist_node; |
||||
extern void pgaio_io_release_resowner(struct dlist_node *ioh_node, bool on_error); |
||||
|
||||
|
||||
/* GUCs */ |
||||
extern PGDLLIMPORT int io_method; |
||||
extern PGDLLIMPORT int io_max_concurrency; |
||||
|
||||
|
||||
#endif /* AIO_H */ |
||||
@ -0,0 +1,33 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* aio_subsys.h |
||||
* Interaction with AIO as a subsystem, rather than actually issuing AIO |
||||
* |
||||
* This header is for AIO related functionality that's being called by files |
||||
* that don't perform AIO, but interact with the AIO subsystem in some |
||||
* form. E.g. postmaster.c and shared memory initialization need to initialize |
||||
* AIO but don't perform AIO. |
||||
* |
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/storage/aio_subsys.h |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef AIO_SUBSYS_H |
||||
#define AIO_SUBSYS_H |
||||
|
||||
|
||||
/* aio_init.c */ |
||||
extern Size AioShmemSize(void); |
||||
extern void AioShmemInit(void); |
||||
|
||||
extern void pgaio_init_backend(void); |
||||
|
||||
|
||||
/* aio.c */ |
||||
extern void pgaio_error_cleanup(void); |
||||
extern void AtEOXact_Aio(bool is_commit); |
||||
|
||||
#endif /* AIO_SUBSYS_H */ |
||||
Loading…
Reference in new issue