From 304fb2b16d1a4d583f9749b1029d00ff51202adc Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Tue, 22 Apr 2025 15:15:40 -0400 Subject: [PATCH] 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 Signed-off-by: Patrick Farrell Change-Id: I5191424a88376e8e9a69e99ad2e785357f35fa0c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52100 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Qian Yingjin Reviewed-by: Marc Vef Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 2 ++ lustre/obdclass/cl_io.c | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index ddb8da1..ff70422 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -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, diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index 38513b1..37abb87 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -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 -- 1.8.3.1