From d4a54de84c0554a21b215621b4df5fdd93e38f74 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 31 May 2019 19:52:31 -0400 Subject: [PATCH] LU-12367 llite: Fix page count for unaligned reads When a read is unaligned on both the first and last page, the calculation used to determine count of pages for readahead misses that we access both of those pages. Increase the calculated count by 1 in this case. This case is covered by the generic readahead tests added in LU-12645. Signed-off-by: Patrick Farrell Change-Id: Idb28d300a232026a9d916d010ee8ebf209283242 Reviewed-on: https://review.whamcloud.com/35015 Tested-by: jenkins Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/llite/vvp_io.c | 7 +++++++ lustre/tests/sanity.sh | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 2c0157f..ead8099 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -817,6 +817,13 @@ static int vvp_io_read_start(const struct lu_env *env, vio->vui_ra_valid = true; vio->vui_ra_start = cl_index(obj, pos); vio->vui_ra_count = cl_index(obj, tot + PAGE_SIZE - 1); + /* If both start and end are unaligned, we read one more page + * than the index math suggests. */ + if (pos % PAGE_SIZE != 0 && (pos + tot) % PAGE_SIZE != 0) + vio->vui_ra_count++; + + CDEBUG(D_READA, "tot %ld, ra_start %lu, ra_count %lu\n", tot, + vio->vui_ra_start, vio->vui_ra_count); } /* BUG: 5972 */ diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index dffdca6..3924119 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8465,12 +8465,14 @@ test_101c() { cancel_lru_locks osc $LCTL set_param osc.*.rpc_stats 0 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180 + $LCTL get_param osc.*.rpc_stats for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do local stats=$($LCTL get_param -n $osc_rpc_stats) local lines=$(echo "$stats" | awk 'END {print NR;}') local size if [ $lines -le 20 ]; then + echo "continue debug" continue fi for size in 1 2 4 8; do -- 1.8.3.1