[lustre-devel] [PATCH 20/37] lustre: llite: fix to free cl_dio_aio properly

James Simmons jsimmons at infradead.org
Wed Jul 15 13:45:01 PDT 2020


From: Wang Shilong <wshilong at ddn.com>

@cl_dio_aio is allocated by slab, we should use slab
free helper to free its memory.

Fixes: ebdbecbaf50b ("lustre: obdclass: use slab allocation for cl_dio_aio")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13134
Lustre-commit: f71a539c3e41b ("LU-13134 llite: fix to free cl_dio_aio properly")
Signed-off-by: Wang Shilong <wshilong at ddn.com>
Reviewed-on: https://review.whamcloud.com/39103
Reviewed-by: Patrick Farrell <farr0186 at gmail.com>
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: James Simmons <jsimmons at infradead.org>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/include/cl_object.h |  2 ++
 fs/lustre/llite/rw26.c        |  2 +-
 fs/lustre/obdclass/cl_io.c    | 10 ++++++++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h
index 8611285..e656c68 100644
--- a/fs/lustre/include/cl_object.h
+++ b/fs/lustre/include/cl_object.h
@@ -2538,6 +2538,8 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor,
 void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
 		     int ioret);
 struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb);
+void cl_aio_free(struct cl_dio_aio *aio);
+
 static inline void cl_sync_io_init(struct cl_sync_io *anchor, int nr)
 {
 	cl_sync_io_init_notify(anchor, nr, NULL, NULL);
diff --git a/fs/lustre/llite/rw26.c b/fs/lustre/llite/rw26.c
index 0971185..d0e3ff6 100644
--- a/fs/lustre/llite/rw26.c
+++ b/fs/lustre/llite/rw26.c
@@ -384,7 +384,7 @@ static ssize_t ll_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 			vio->u.write.vui_written += tot_bytes;
 			result = tot_bytes;
 		}
-		kfree(aio);
+		cl_aio_free(aio);
 	} else {
 		result = -EIOCBQUEUED;
 	}
diff --git a/fs/lustre/obdclass/cl_io.c b/fs/lustre/obdclass/cl_io.c
index 2f597d1..dcf940f 100644
--- a/fs/lustre/obdclass/cl_io.c
+++ b/fs/lustre/obdclass/cl_io.c
@@ -1106,6 +1106,13 @@ struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb)
 }
 EXPORT_SYMBOL(cl_aio_alloc);
 
+void cl_aio_free(struct cl_dio_aio *aio)
+{
+	if (aio)
+		kmem_cache_free(cl_dio_aio_kmem, aio);
+}
+EXPORT_SYMBOL(cl_aio_free);
+
 /**
  * Indicate that transfer of a single page completed.
  */
@@ -1143,8 +1150,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.
 		 */
-		if (aio)
-			kmem_cache_free(cl_dio_aio_kmem, aio);
+		cl_aio_free(aio);
 	}
 }
 EXPORT_SYMBOL(cl_sync_io_note);
-- 
1.8.3.1



More information about the lustre-devel mailing list