From: Wang Shilong Date: Fri, 3 Apr 2020 13:14:25 +0000 (+0800) Subject: LU-13412 llite: fix read if readahead window smaller than rpc size X-Git-Tag: 2.13.54~17 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=33d08805f27bb9a4c374754505f2ef5431b9fd31 LU-13412 llite: fix read if readahead window smaller than rpc size 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. Change-Id: I0cd33ac7f92a75f38c926db33630f3036bbfd6c7 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/38132 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Gu Zheng Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 6cf2c74..29ec2b7 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -348,7 +348,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 */