diff mbox series

[09/27] lustre: readahead: clip readahead with kms

Message ID 1681739243-29375-10-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS branch April 17, 2023 | expand

Commit Message

James Simmons April 17, 2023, 1:47 p.m. UTC
From: Qian Yingjin <qian@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@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49226
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/osc/osc_io.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

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;
 	}