From: Patrick Farrell Date: Sun, 24 Sep 2023 20:57:35 +0000 (-0400) Subject: LU-13814 clio: add cl_sync_io_note batch X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d6f97f09c89d9d9a8804d6a1971616ea86778afa;p=fs%2Flustre-release.git LU-13814 clio: add cl_sync_io_note batch 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 Change-Id: I5191424a88376e8e9a69e99ad2e785357f35fa0c --- diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 0dc942c..2306b40 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -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, diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index 8344166..40358c7 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -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