Whamcloud - gitweb
LU-13814 clio: add cl_sync_io_note batch 00/52100/17
authorPatrick Farrell <pfarrell@whamcloud.com>
Sun, 24 Sep 2023 20:57:35 +0000 (16:57 -0400)
committerPatrick Farrell <pfarrell@whamcloud.com>
Tue, 26 Sep 2023 18:58:30 +0000 (14:58 -0400)
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
Test-Parameters: forjanitoronly
Test-Parameters: fortestonly
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I5191424a88376e8e9a69e99ad2e785357f35fa0c

lustre/include/cl_object.h
lustre/obdclass/cl_io.c

index 0dc942c..2306b40 100644 (file)
@@ -2550,6 +2550,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 8344166..40358c7 100644 (file)
@@ -1674,19 +1674,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)) {
@@ -1740,6 +1751,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