aio: Rename pgaio_io_prep_* to pgaio_io_start_*
authorAndres Freund <[email protected]>
Wed, 26 Mar 2025 20:10:29 +0000 (16:10 -0400)
committerAndres Freund <[email protected]>
Wed, 26 Mar 2025 20:10:29 +0000 (16:10 -0400)
The old naming pattern (mirroring liburing's naming) was inconsistent with
the (not yet introduced) callers. It seems better to get rid of the
inconsistency now than to grow more users of the odd naming.

Reported-by: Noah Misch <[email protected]>
Discussion: https://postgr.es/m/20250326001915[email protected]

src/backend/storage/aio/aio.c
src/backend/storage/aio/aio_callback.c
src/backend/storage/aio/aio_io.c
src/backend/storage/aio/aio_target.c
src/include/storage/aio.h
src/include/storage/aio_internal.h

index 1fd82842718b59194d24ad67ded996c105146de1..116bf97d3efa9dcd53eb80c0b15d79f29b551711 100644 (file)
@@ -127,25 +127,25 @@ static PgAioHandle *pgaio_inj_cur_handle;
  * To react to the completion of the IO as soon as it is known to have
  * completed, callbacks can be registered with pgaio_io_register_callbacks().
  *
- * To actually execute IO using the returned handle, the pgaio_io_prep_*()
- * family of functions is used. In many cases the pgaio_io_prep_*() call will
+ * To actually execute IO using the returned handle, the pgaio_io_start_*()
+ * family of functions is used. In many cases the pgaio_io_start_*() call will
  * not be done directly by code that acquired the handle, but by lower level
  * code that gets passed the handle. E.g. if code in bufmgr.c wants to perform
  * AIO, it typically will pass the handle to smgr.c, which will pass it on to
- * md.c, on to fd.c, which then finally calls pgaio_io_prep_*().  This
+ * md.c, on to fd.c, which then finally calls pgaio_io_start_*().  This
  * forwarding allows the various layers to react to the IO's completion by
  * registering callbacks. These callbacks in turn can translate a lower
  * layer's result into a result understandable by a higher layer.
  *
- * During pgaio_io_prep_*() the IO is staged (i.e. prepared for execution but
+ * During pgaio_io_start_*() the IO is staged (i.e. prepared for execution but
  * not submitted to the kernel). Unless in batchmode
  * (c.f. pgaio_enter_batchmode()), the IO will also get submitted for
  * execution. Note that, whether in batchmode or not, the IO might even
  * complete before the functions return.
  *
- * After pgaio_io_prep_*() the AioHandle is "consumed" and may not be
+ * After pgaio_io_start_*() the AioHandle is "consumed" and may not be
  * referenced by the IO issuing code. To e.g. wait for IO, references to the
- * IO can be established with pgaio_io_get_wref() *before* pgaio_io_prep_*()
+ * IO can be established with pgaio_io_get_wref() *before* pgaio_io_start_*()
  * is called.  pgaio_wref_wait() can be used to wait for the IO to complete.
  *
  *
@@ -391,7 +391,7 @@ pgaio_io_resowner_register(PgAioHandle *ioh)
 /*
  * Stage IO for execution and, if appropriate, submit it immediately.
  *
- * Should only be called from pgaio_io_prep_*().
+ * Should only be called from pgaio_io_start_*().
  */
 void
 pgaio_io_stage(PgAioHandle *ioh, PgAioOp op)
@@ -421,7 +421,7 @@ pgaio_io_stage(PgAioHandle *ioh, PgAioOp op)
    needs_synchronous = pgaio_io_needs_synchronous_execution(ioh);
 
    pgaio_debug_io(DEBUG3, ioh,
-                  "prepared (synchronous: %d, in_batch: %d)",
+                  "staged (synchronous: %d, in_batch: %d)",
                   needs_synchronous, pgaio_my_backend->in_batchmode);
 
    if (!needs_synchronous)
index d6b53165ccfe10952f09e217dab73db469b0c7b1..413ea3247c2bef62727a9ad4522abc0ebacfa452 100644 (file)
@@ -54,7 +54,7 @@ static const PgAioHandleCallbacksEntry aio_handle_cbs[] = {
  * registered for each IO.
  *
  * Callbacks need to be registered before [indirectly] calling
- * pgaio_io_prep_*(), as the IO may be executed immediately.
+ * pgaio_io_start_*(), as the IO may be executed immediately.
  *
  * A callback can be passed a small bit of data, e.g. to indicate whether to
  * zero a buffer if it is invalid.
index cc6d999a6fb2929bc62bf1ad6947f98d8e902277..195276f630e3a9bf169296d88fc73a0290c6cf5f 100644 (file)
@@ -25,7 +25,7 @@
 #include "utils/wait_event.h"
 
 
-static void pgaio_io_before_prep(PgAioHandle *ioh);
+static void pgaio_io_before_start(PgAioHandle *ioh);
 
 
 
@@ -63,22 +63,22 @@ pgaio_io_get_op_data(PgAioHandle *ioh)
 
 
 /* --------------------------------------------------------------------------------
- * "Preparation" routines for individual IO operations
+ * "Start" routines for individual IO operations
  *
  * These are called by the code actually initiating an IO, to associate the IO
  * specific data with an AIO handle.
  *
- * Each of the preparation routines first needs to call
- * pgaio_io_before_prep(), then fill IO specific fields in the handle and then
- * finally call pgaio_io_stage().
+ * Each of the "start" routines first needs to call pgaio_io_before_start(),
+ * then fill IO specific fields in the handle and then finally call
+ * pgaio_io_stage().
  * --------------------------------------------------------------------------------
  */
 
 void
-pgaio_io_prep_readv(PgAioHandle *ioh,
-                   int fd, int iovcnt, uint64 offset)
+pgaio_io_start_readv(PgAioHandle *ioh,
+                    int fd, int iovcnt, uint64 offset)
 {
-   pgaio_io_before_prep(ioh);
+   pgaio_io_before_start(ioh);
 
    ioh->op_data.read.fd = fd;
    ioh->op_data.read.offset = offset;
@@ -88,10 +88,10 @@ pgaio_io_prep_readv(PgAioHandle *ioh,
 }
 
 void
-pgaio_io_prep_writev(PgAioHandle *ioh,
-                    int fd, int iovcnt, uint64 offset)
+pgaio_io_start_writev(PgAioHandle *ioh,
+                     int fd, int iovcnt, uint64 offset)
 {
-   pgaio_io_before_prep(ioh);
+   pgaio_io_before_start(ioh);
 
    ioh->op_data.write.fd = fd;
    ioh->op_data.write.offset = offset;
@@ -153,7 +153,7 @@ pgaio_io_perform_synchronously(PgAioHandle *ioh)
  * any data in the handle is set.  Mostly to centralize assertions.
  */
 static void
-pgaio_io_before_prep(PgAioHandle *ioh)
+pgaio_io_before_start(PgAioHandle *ioh)
 {
    Assert(ioh->state == PGAIO_HS_HANDED_OUT);
    Assert(pgaio_my_backend->handed_out_io == ioh);
index b01406a6a520934c335b8d4d8f06e71590236975..536c7f91f5e79a56f4d5ed8de3e806f6b06af74f 100644 (file)
@@ -55,7 +55,7 @@ pgaio_io_get_target_name(PgAioHandle *ioh)
 /*
  * Assign a target to the IO.
  *
- * This has to be called exactly once before pgaio_io_prep_*() is called.
+ * This has to be called exactly once before pgaio_io_start_*() is called.
  */
 void
 pgaio_io_set_target(PgAioHandle *ioh, PgAioTargetID targetid)
@@ -101,7 +101,7 @@ pgaio_io_can_reopen(PgAioHandle *ioh)
 
 /*
  * Internal: Before executing an IO outside of the context of the process the
- * IO has been prepared in, the file descriptor has to be reopened - any FD
+ * IO has been staged in, the file descriptor has to be reopened - any FD
  * referenced in the IO itself, won't be valid in the separate process.
  */
 void
index 7b6b7d20a85d672a31c6cfe1900a41942168ff67..25da0a31d182d6cdd30ece972c14678ef486a076 100644 (file)
@@ -277,10 +277,10 @@ extern int    pgaio_io_get_iovec(PgAioHandle *ioh, struct iovec **iov);
 extern PgAioOp pgaio_io_get_op(PgAioHandle *ioh);
 extern PgAioOpData *pgaio_io_get_op_data(PgAioHandle *ioh);
 
-extern void pgaio_io_prep_readv(PgAioHandle *ioh,
-                               int fd, int iovcnt, uint64 offset);
-extern void pgaio_io_prep_writev(PgAioHandle *ioh,
+extern void pgaio_io_start_readv(PgAioHandle *ioh,
                                 int fd, int iovcnt, uint64 offset);
+extern void pgaio_io_start_writev(PgAioHandle *ioh,
+                                 int fd, int iovcnt, uint64 offset);
 
 /* functions in aio_target.c */
 extern void pgaio_io_set_target(PgAioHandle *ioh, PgAioTargetID targetid);
index d5f6441687098338774577b73c438ee97f61ce25..d7109706151cc85e1b73ef5fcbb12dc2c9044e31 100644 (file)
@@ -42,13 +42,13 @@ typedef enum PgAioHandleState
 
    /*
     * Returned by pgaio_io_acquire(). The next state is either DEFINED (if
-    * pgaio_io_prep_*() is called), or IDLE (if pgaio_io_release() is
+    * pgaio_io_start_*() is called), or IDLE (if pgaio_io_release() is
     * called).
     */
    PGAIO_HS_HANDED_OUT,
 
    /*
-    * pgaio_io_prep_*() has been called, but IO is not yet staged. At this
+    * pgaio_io_start_*() has been called, but IO is not yet staged. At this
     * point the handle has all the information for the IO to be executed.
     */
    PGAIO_HS_DEFINED,