[lustre-devel] [PATCH 11/22] lustre: llite: fix read if readahead window smaller than rpc size

James Simmons jsimmons at infradead.org
Tue Jun 2 17:59:50 PDT 2020


From: Wang Shilong <wshilong at ddn.com>

Readahead always try to align readahead with RPC size, but this
could introduce a problem if readahead window is smaller than RPC size.

With current codes, it will fallback a lot of 4k read because
RPC aligned window start plus window pages will be behind of
current read. Fix this to align with readahead window rather
than RPC size in this case.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13412
Lustre-commit: 33d08805f27bb ("LU-13412 llite: fix read if readahead window smaller than rpc size")
Signed-off-by: Wang Shilong <wshilong at ddn.com>
Reviewed-on: https://review.whamcloud.com/38132
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Gu Zheng <gzheng at ddn.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/llite/rw.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c
index fd0bed6..ff8f3c6 100644
--- a/fs/lustre/llite/rw.c
+++ b/fs/lustre/llite/rw.c
@@ -350,7 +350,11 @@ static unsigned long ria_page_count(struct ra_io_arg *ria)
 
 static pgoff_t ras_align(struct ll_readahead_state *ras, pgoff_t index)
 {
-	return index - (index % ras->ras_rpc_pages);
+	unsigned opt_size = min(ras->ras_window_pages, ras->ras_rpc_pages);
+
+	if (opt_size == 0)
+		opt_size = 1;
+	return index - (index % opt_size);
 }
 
 /* Check whether the index is in the defined ra-window */
-- 
1.8.3.1



More information about the lustre-devel mailing list