[lustre-devel] [PATCH 09/27] lustre: readahead: clip readahead with kms

James Simmons jsimmons at infradead.org
Mon Apr 17 06:47:05 PDT 2023


From: Qian Yingjin <qian at ddn.com>

During I/O test, it found that the read-ahead pages reach 255 for
small files with only several KiB. The amount of read data reaches
more than 1MiB.
The reason is that the granted DLM extent lock is [0, EOF], which
is larger than the requested extent. During readahead, the OSC
layer will also return [0, EOF] extent which will clip into stripe
size (1MiB) regardless the actual object size.
In this patch, the readahead range is clipped to the known min
size (kms) on OSC layer during readahead. By this way, the
read-ahead data will not beyong the last page of the file.

This patch also fixes multiop to return successfully when reaching
EOF instead of exiting with ENODATA during read.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16338
Lustre-commit: b33808d3aebb06cf0 ("LU-16338 readahead: clip readahead with kms")
Signed-off-by: Qian Yingjin <qian at ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49226
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/osc/osc_io.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/lustre/osc/osc_io.c b/fs/lustre/osc/osc_io.c
index c9a3175..d0ee748 100644
--- a/fs/lustre/osc/osc_io.c
+++ b/fs/lustre/osc/osc_io.c
@@ -83,6 +83,8 @@ static int osc_io_read_ahead(const struct lu_env *env,
 	oio->oi_is_readahead = true;
 	dlmlock = osc_dlmlock_at_pgoff(env, osc, start, 0);
 	if (dlmlock) {
+		struct lov_oinfo *oinfo = osc->oo_oinfo;
+
 		LASSERT(dlmlock->l_ast_data == osc);
 		if (dlmlock->l_req_mode != LCK_PR) {
 			struct lustre_handle lockh;
@@ -100,6 +102,9 @@ static int osc_io_read_ahead(const struct lu_env *env,
 		ra->cra_oio = oio;
 		if (ra->cra_end_idx != CL_PAGE_EOF)
 			ra->cra_contention = true;
+		ra->cra_end_idx = min_t(pgoff_t, ra->cra_end_idx,
+					cl_index(osc2cl(osc),
+						 oinfo->loi_kms - 1));
 		result = 0;
 	}
 
-- 
1.8.3.1



More information about the lustre-devel mailing list