Whamcloud - gitweb
LU-13814 clio: add cl_sync_io_note batch 00/52100/30
authorPatrick Farrell <pfarrell@whamcloud.com>
Tue, 22 Apr 2025 19:15:40 +0000 (15:15 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 May 2025 21:10:18 +0000 (21:10 +0000)
Batched cl_sync_io_note will be needed shortly in the
series, so add the functionality here.  This will be used
in an upcoming patch, but is separate to keep the patches
short.

Test-Parameters: trivial
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I5191424a88376e8e9a69e99ad2e785357f35fa0c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52100
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: Marc Vef <mvef@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/cl_object.h
lustre/obdclass/cl_io.c

index ddb8da1..ff70422 100644 (file)
@@ -2507,6 +2507,8 @@ void cl_sync_io_init_notify(struct cl_sync_io *anchor, int nr, void *dio_aio,
 
 int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor,
                    long timeout);
+void __cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
+                      int count, int ioret);
 void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
                     int ioret);
 int cl_sync_io_wait_recycle(const struct lu_env *env, struct cl_sync_io *anchor,
index 38513b1..37abb87 100644 (file)
@@ -1789,19 +1789,30 @@ EXPORT_SYMBOL(ll_dio_user_copy);
 /*
  * Indicate that transfer of a single page completed.
  */
-void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
-                    int ioret)
+void __cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
+                      int count, int ioret)
 {
+       int sync_nr;
+
        ENTRY;
 
        if (anchor->csi_sync_rc == 0 && ioret < 0)
                anchor->csi_sync_rc = ioret;
+
+       /* because there is no atomic_sub_and_lock, we have to do this slightly
+        * awkward subtraction when we have count > 1, handling all but 1 of
+        * our 'count' entries
+        */
+       if (count > 1)
+               sync_nr = atomic_sub_return(count - 1, &anchor->csi_sync_nr);
+       else
+               sync_nr = atomic_read(&anchor->csi_sync_nr);
        /*
         * Synchronous IO done without releasing page lock (e.g., as a part of
         * ->{prepare,commit}_write(). Completion is used to signal the end of
         * IO.
         */
-       LASSERT(atomic_read(&anchor->csi_sync_nr) > 0);
+       LASSERT(sync_nr > 0);
        LASSERT(atomic_read(&anchor->csi_complete) == 0);
        if (atomic_dec_and_lock(&anchor->csi_sync_nr,
                                &anchor->csi_waitq.lock)) {
@@ -1855,6 +1866,13 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
        }
        EXIT;
 }
+EXPORT_SYMBOL(__cl_sync_io_note);
+
+void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
+                    int ioret)
+{
+       __cl_sync_io_note(env, anchor, 1, ioret);
+}
 EXPORT_SYMBOL(cl_sync_io_note);
 
 /* this function waits for completion of outstanding io and then re-initializes