[lustre-devel] [PATCH 10/25] lustre: llite: Modify AIO/DIO reference counting

James Simmons jsimmons at infradead.org
Mon Aug 2 12:50:30 PDT 2021


From: Patrick Farrell <farr0186 at gmail.com>

For DIO pages, it's enough to have a reference on the
cl_object associated with the AIO.  This saves taking a
reference on the cl_object for each page, which saves about
5% of the time when doing DIO/AIO.

This is possible because the lifecycle of the aio struct is
always greater than that of the associated pages.

This patch reduces i/o time in ms/GiB by:
Write: 6 ms/GiB
Read: 1 ms/GiB

Totals:
Write: 198 ms/GiB
Read: 197 ms/GiB

mpirun -np 1  $IOR -w -r -t 64M -b 64G -o ./iorfile --posix.odirect

With previous patches in series:
write     5030 MiB/s
read      5174 MiB/s

Plus this patch:
write     5183 MiB/s
read      5200 MiB/s

WC-bug-id: https://jira.whamcloud.com/browse/LU-13799
Lustre-commit: b3de247b76b4101 ("LU-13799 llite: Modify AIO/DIO reference counting")
Signed-off-by: Patrick Farrell <farr0186 at gmail.com>
Reviewed-on: https://review.whamcloud.com/39442
Reviewed-by: Wang Shilong <wshilong at whamcloud.com>
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff at hpe.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/include/cl_object.h |  5 +++--
 fs/lustre/llite/file.c        |  5 +++--
 fs/lustre/obdclass/cl_io.c    | 12 ++++++++----
 fs/lustre/obdclass/cl_page.c  |  6 ++++--
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h
index 61a14f4..0f785e5 100644
--- a/fs/lustre/include/cl_object.h
+++ b/fs/lustre/include/cl_object.h
@@ -2593,8 +2593,8 @@ 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,
 			    long timeout, int ioret);
-struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb);
-void cl_aio_free(struct cl_dio_aio *aio);
+struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb, struct cl_object *obj);
+void cl_aio_free(const struct lu_env *env, struct cl_dio_aio *aio);
 
 static inline void cl_sync_io_init(struct cl_sync_io *anchor, int nr)
 {
@@ -2624,6 +2624,7 @@ struct cl_sync_io {
 struct cl_dio_aio {
 	struct cl_sync_io	cda_sync;
 	struct cl_page_list	cda_pages;
+	struct cl_object	*cda_obj;
 	struct kiocb		*cda_iocb;
 	ssize_t			cda_bytes;
 	unsigned int		cda_no_aio_complete:1;
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index b822ca5..1bf237b 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -1656,7 +1656,8 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 		if (!ll_sbi_has_parallel_dio(sbi))
 			is_parallel_dio = false;
 
-		ci_aio = cl_aio_alloc(args->u.normal.via_iocb);
+		ci_aio = cl_aio_alloc(args->u.normal.via_iocb,
+				      ll_i2info(inode)->lli_clob);
 		if (!ci_aio) {
 			rc = -ENOMEM;
 			goto out;
@@ -1814,7 +1815,7 @@ static void ll_heat_add(struct inode *inode, enum cl_io_type iot,
 		cl_sync_io_note(env, &io->ci_aio->cda_sync,
 				rc == -EIOCBQUEUED ? 0 : rc);
 		if (!is_aio) {
-			cl_aio_free(io->ci_aio);
+			cl_aio_free(env, io->ci_aio);
 			io->ci_aio = NULL;
 		}
 	}
diff --git a/fs/lustre/obdclass/cl_io.c b/fs/lustre/obdclass/cl_io.c
index 63ce39c..b5e7744b 100644
--- a/fs/lustre/obdclass/cl_io.c
+++ b/fs/lustre/obdclass/cl_io.c
@@ -1131,7 +1131,7 @@ static void cl_aio_end(const struct lu_env *env, struct cl_sync_io *anchor)
 					   ret ?: aio->cda_bytes, 0);
 }
 
-struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb)
+struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb, struct cl_object *obj)
 {
 	struct cl_dio_aio *aio;
 
@@ -1147,15 +1147,19 @@ struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb)
 		cl_page_list_init(&aio->cda_pages);
 		aio->cda_iocb = iocb;
 		aio->cda_no_aio_complete = 0;
+		cl_object_get(obj);
+		aio->cda_obj = obj;
 	}
 	return aio;
 }
 EXPORT_SYMBOL(cl_aio_alloc);
 
-void cl_aio_free(struct cl_dio_aio *aio)
+void cl_aio_free(const struct lu_env *env, struct cl_dio_aio *aio)
 {
-	if (aio)
+	if (aio) {
+		cl_object_put(env, aio->cda_obj);
 		kmem_cache_free(cl_dio_aio_kmem, aio);
+	}
 }
 EXPORT_SYMBOL(cl_aio_free);
 
@@ -1196,7 +1200,7 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
 		 * If anchor->csi_aio is set, we are responsible for freeing
 		 * memory here rather than when cl_sync_io_wait() completes.
 		 */
-		cl_aio_free(aio);
+		cl_aio_free(env, aio);
 	}
 }
 EXPORT_SYMBOL(cl_sync_io_note);
diff --git a/fs/lustre/obdclass/cl_page.c b/fs/lustre/obdclass/cl_page.c
index 1c9e91d..41bd767 100644
--- a/fs/lustre/obdclass/cl_page.c
+++ b/fs/lustre/obdclass/cl_page.c
@@ -147,7 +147,8 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *cl_page,
 	cl_page->cp_layer_count = 0;
 	lu_object_ref_del_at(&obj->co_lu, &cl_page->cp_obj_ref,
 			     "cl_page", cl_page);
-	cl_object_put(env, obj);
+	if (cl_page->cp_type != CPT_TRANSIENT)
+		cl_object_put(env, obj);
 	lu_ref_fini(&cl_page->cp_reference);
 	__cl_page_free(cl_page, bufsize);
 }
@@ -227,7 +228,8 @@ struct cl_page *cl_page_alloc(const struct lu_env *env, struct cl_object *o,
 		BUILD_BUG_ON((1 << CP_TYPE_BITS) < CPT_NR); /* cp_type */
 		refcount_set(&cl_page->cp_ref, 1);
 		cl_page->cp_obj = o;
-		cl_object_get(o);
+		if (type != CPT_TRANSIENT)
+			cl_object_get(o);
 		lu_object_ref_add_at(&o->co_lu, &cl_page->cp_obj_ref,
 				     "cl_page", cl_page);
 		cl_page->cp_vmpage = vmpage;
-- 
1.8.3.1



More information about the lustre-devel mailing list