PostgreSQL Source Code
git master
Loading...
Searching...
No Matches
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-2026, 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
"
19
#include "
storage/relfilelocator.h
"
20
21
22
typedef
struct
PgAioHandle
PgAioHandle
;
23
typedef
struct
PgAioHandleCallbacks
PgAioHandleCallbacks
;
24
typedef
struct
PgAioTargetInfo
PgAioTargetInfo
;
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
*/
32
typedef
struct
PgAioWaitRef
33
{
34
/* internal ID identifying the specific PgAioHandle */
35
uint32
aio_index
;
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
*/
45
uint32
generation_upper
;
46
uint32
generation_lower
;
47
}
PgAioWaitRef
;
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
*/
61
typedef
union
PgAioTargetData
62
{
63
struct
64
{
65
RelFileLocator
rlocator
;
/* physical relation identifier */
66
BlockNumber
blockNum
;
/* blknum relative to begin of reln */
67
BlockNumber
nblocks
;
68
ForkNumber
forkNum
:8;
/* don't waste 4 byte for four values */
69
bool
is_temp
:1;
/* proc can be inferred by owning AIO */
70
bool
skip_fsync
:1;
71
}
smgr
;
72
}
PgAioTargetData
;
73
74
75
/*
76
* The status of an AIO operation.
77
*/
78
typedef
enum
PgAioResultStatus
79
{
80
PGAIO_RS_UNKNOWN
,
/* not yet completed / uninitialized */
81
PGAIO_RS_OK
,
82
PGAIO_RS_PARTIAL
,
/* did not fully succeed, no warning/error */
83
PGAIO_RS_WARNING
,
/* [partially] succeeded, with a warning */
84
PGAIO_RS_ERROR
,
/* failed entirely */
85
}
PgAioResultStatus
;
86
87
88
/*
89
* Result of IO operation, visible only to the initiator of IO.
90
*
91
* We need to be careful about the size of PgAioResult, as it is embedded in
92
* every PgAioHandle, as well as every PgAioReturn. Currently we assume we can
93
* fit it into one 8 byte value, restricting the space for per-callback error
94
* data to PGAIO_RESULT_ERROR_BITS.
95
*/
96
#define PGAIO_RESULT_ID_BITS 6
97
#define PGAIO_RESULT_STATUS_BITS 3
98
#define PGAIO_RESULT_ERROR_BITS 23
99
typedef
struct
PgAioResult
100
{
101
/*
102
* This is of type PgAioHandleCallbackID, but can't use a bitfield of an
103
* enum, because some compilers treat enums as signed.
104
*/
105
uint32
id
:
PGAIO_RESULT_ID_BITS
;
106
107
/* of type PgAioResultStatus, see above */
108
uint32
status
:
PGAIO_RESULT_STATUS_BITS
;
109
110
/* meaning defined by callback->report */
111
uint32
error_data
:
PGAIO_RESULT_ERROR_BITS
;
112
113
int32
result
;
114
}
PgAioResult
;
115
116
117
StaticAssertDecl
(
PGAIO_RESULT_ID_BITS
+
118
PGAIO_RESULT_STATUS_BITS
+
119
PGAIO_RESULT_ERROR_BITS
== 32,
120
"PgAioResult bits divided up incorrectly"
);
121
StaticAssertDecl
(
sizeof
(
PgAioResult
) == 8,
122
"PgAioResult has unexpected size"
);
123
124
/*
125
* Combination of PgAioResult with minimal metadata about the IO.
126
*
127
* Contains sufficient information to be able, in case the IO [partially]
128
* fails, to log/raise an error under control of the IO issuing code.
129
*/
130
typedef
struct
PgAioReturn
131
{
132
PgAioResult
result
;
133
PgAioTargetData
target_data
;
134
}
PgAioReturn
;
135
136
137
#endif
/* AIO_TYPES_H */
PGAIO_RESULT_ID_BITS
#define PGAIO_RESULT_ID_BITS
Definition
aio_types.h:96
PGAIO_RESULT_STATUS_BITS
#define PGAIO_RESULT_STATUS_BITS
Definition
aio_types.h:97
PGAIO_RESULT_ERROR_BITS
#define PGAIO_RESULT_ERROR_BITS
Definition
aio_types.h:98
PgAioResultStatus
PgAioResultStatus
Definition
aio_types.h:79
PGAIO_RS_OK
@ PGAIO_RS_OK
Definition
aio_types.h:81
PGAIO_RS_UNKNOWN
@ PGAIO_RS_UNKNOWN
Definition
aio_types.h:80
PGAIO_RS_PARTIAL
@ PGAIO_RS_PARTIAL
Definition
aio_types.h:82
PGAIO_RS_ERROR
@ PGAIO_RS_ERROR
Definition
aio_types.h:84
PGAIO_RS_WARNING
@ PGAIO_RS_WARNING
Definition
aio_types.h:83
block.h
BlockNumber
uint32 BlockNumber
Definition
block.h:31
int32
int32_t int32
Definition
c.h:542
uint32
uint32_t uint32
Definition
c.h:546
StaticAssertDecl
#define StaticAssertDecl(condition, errmessage)
Definition
c.h:942
relfilelocator.h
ForkNumber
ForkNumber
Definition
relpath.h:56
PgAioHandleCallbacks
Definition
aio.h:214
PgAioHandle
Definition
aio_internal.h:103
PgAioResult
Definition
aio_types.h:100
PgAioResult::status
uint32 status
Definition
aio_types.h:108
PgAioResult::error_data
uint32 error_data
Definition
aio_types.h:111
PgAioResult::result
int32 result
Definition
aio_types.h:113
PgAioResult::id
uint32 id
Definition
aio_types.h:105
PgAioReturn
Definition
aio_types.h:131
PgAioReturn::result
PgAioResult result
Definition
aio_types.h:132
PgAioReturn::target_data
PgAioTargetData target_data
Definition
aio_types.h:133
PgAioTargetInfo
Definition
aio.h:159
PgAioWaitRef
Definition
aio_types.h:33
PgAioWaitRef::generation_upper
uint32 generation_upper
Definition
aio_types.h:45
PgAioWaitRef::aio_index
uint32 aio_index
Definition
aio_types.h:35
PgAioWaitRef::generation_lower
uint32 generation_lower
Definition
aio_types.h:46
RelFileLocator
Definition
relfilelocator.h:59
PgAioTargetData
Definition
aio_types.h:62
PgAioTargetData::skip_fsync
bool skip_fsync
Definition
aio_types.h:70
PgAioTargetData::blockNum
BlockNumber blockNum
Definition
aio_types.h:66
PgAioTargetData::rlocator
RelFileLocator rlocator
Definition
aio_types.h:65
PgAioTargetData::smgr
struct PgAioTargetData::@126 smgr
PgAioTargetData::nblocks
BlockNumber nblocks
Definition
aio_types.h:67
PgAioTargetData::is_temp
bool is_temp
Definition
aio_types.h:69
PgAioTargetData::forkNum
ForkNumber forkNum
Definition
aio_types.h:68
src
include
storage
aio_types.h
Generated on Tue Jan 27 2026 06:13:17 for PostgreSQL Source Code by
1.9.8