PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
aio_types.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * aio_types.h
4 * AIO related types that are useful to include separately, to reduce the
5 * "include burden".
6 *
7 *
8 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
9 * Portions Copyright (c) 1994, Regents of the University of California
10 *
11 * src/include/storage/aio_types.h
12 *
13 *-------------------------------------------------------------------------
14 */
15#ifndef AIO_TYPES_H
16#define AIO_TYPES_H
17
18#include "storage/block.h"
20
21
22typedef struct PgAioHandle PgAioHandle;
25
26/*
27 * A reference to an IO that can be used to wait for the IO (using
28 * pgaio_wref_wait()) to complete.
29 *
30 * These can be passed across process boundaries.
31 */
32typedef struct PgAioWaitRef
33{
34 /* internal ID identifying the specific PgAioHandle */
36
37 /*
38 * IO handles are reused. To detect if a handle was reused, and thereby
39 * avoid unnecessarily waiting for a newer IO, each time the handle is
40 * reused a generation number is increased.
41 *
42 * To avoid requiring alignment sufficient for an int64, split the
43 * generation into two.
44 */
48
49
50/*
51 * Information identifying what the IO is being performed on.
52 *
53 * This needs sufficient information to
54 *
55 * a) Reopen the file for the IO if the IO is executed in a context that
56 * cannot use the FD provided initially (e.g. because the IO is executed in
57 * a worker process).
58 *
59 * b) Describe the object the IO is performed on in log / error messages.
60 */
61typedef union PgAioTargetData
62{
63 /* just as an example placeholder for later */
64 struct
65 {
67 } wal;
69
70
71/*
72 * The status of an AIO operation.
73 */
75{
76 PGAIO_RS_UNKNOWN, /* not yet completed / uninitialized */
78 PGAIO_RS_PARTIAL, /* did not fully succeed, but no error */
81
82
83/*
84 * Result of IO operation, visible only to the initiator of IO.
85 */
86typedef struct PgAioResult
87{
88 /*
89 * This is of type PgAioHandleCallbackID, but can't use a bitfield of an
90 * enum, because some compilers treat enums as signed.
91 */
93
94 /* of type PgAioResultStatus, see above */
96
97 /* meaning defined by callback->error */
99
102
103
104/*
105 * Combination of PgAioResult with minimal metadata about the IO.
106 *
107 * Contains sufficient information to be able, in case the IO [partially]
108 * fails, to log/raise an error under control of the IO issuing code.
109 */
110typedef struct PgAioReturn
111{
115
116
117#endif /* AIO_TYPES_H */
union PgAioTargetData PgAioTargetData
struct PgAioResult PgAioResult
PgAioResultStatus
Definition: aio_types.h:75
@ PGAIO_RS_OK
Definition: aio_types.h:77
@ PGAIO_RS_UNKNOWN
Definition: aio_types.h:76
@ PGAIO_RS_PARTIAL
Definition: aio_types.h:78
@ PGAIO_RS_ERROR
Definition: aio_types.h:79
struct PgAioWaitRef PgAioWaitRef
struct PgAioReturn PgAioReturn
int32_t int32
Definition: c.h:498
uint32_t uint32
Definition: c.h:502
uint32 status
Definition: aio_types.h:95
uint32 error_data
Definition: aio_types.h:98
int32 result
Definition: aio_types.h:100
uint32 id
Definition: aio_types.h:92
PgAioResult result
Definition: aio_types.h:112
PgAioTargetData target_data
Definition: aio_types.h:113
uint32 generation_upper
Definition: aio_types.h:45
uint32 aio_index
Definition: aio_types.h:35
uint32 generation_lower
Definition: aio_types.h:46
uint32 queue_id
Definition: aio_types.h:66
struct PgAioTargetData::@124 wal