From: Wang Shilong Date: Thu, 13 Jun 2019 01:35:12 +0000 (+0800) Subject: LU-12043 llite: make sure readahead cover current read X-Git-Tag: 2.12.57~144 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8fbef5ee761920faa3c84f142f56934d6266a409;hp=218fc688c11f081881b2cc1c1632ceaf9ec77a77;ds=sidebyside LU-12043 llite: make sure readahead cover current read When doing readahead, @ria_end_min is used to indicate how far we are expected to read to cover current read. update @ria_end_min unconditionally with IO end. also @ria_end_min is closed interval which should be calculated as start + count - 1; Change-Id: If7f8da44da31623a73b363d5a18c1ec8b54da745 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/35215 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Li Xi Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index df9b9a4..d8f4075 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -677,16 +677,8 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, /* at least to extend the readahead window to cover current read */ if (!hit && vio->vui_ra_valid && - vio->vui_ra_start + vio->vui_ra_count > ria->ria_start) { - unsigned long remainder; - - /* to the end of current read window. */ - mlen = vio->vui_ra_start + vio->vui_ra_count - ria->ria_start; - /* trim to RPC boundary */ - ras_align(ras, ria->ria_start, &remainder); - mlen = min(mlen, ras->ras_rpc_size - remainder); - ria->ria_end_min = ria->ria_start + mlen; - } + vio->vui_ra_start + vio->vui_ra_count > ria->ria_start) + ria->ria_end_min = vio->vui_ra_start + vio->vui_ra_count - 1; ria->ria_reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len, mlen); if (ria->ria_reserved < len) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 4dcc658..37e6ab7 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8617,6 +8617,26 @@ test_101g() { } run_test 101g "Big bulk(4/16 MiB) readahead" +test_101h() { + $LFS setstripe -i 0 -c 1 $DIR/$tfile + + dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 || + error "dd 70M file failed" + echo Cancel LRU locks on lustre client to flush the client cache + cancel_lru_locks osc + + echo "Reset readahead stats" + $LCTL set_param -n llite.*.read_ahead_stats 0 + + echo "Read 10M of data but cross 64M bundary" + dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1 + local miss=$($LCTL get_param -n llite.*.read_ahead_stats | + get_named_value 'misses' | cut -d" " -f1 | calc_total) + [ $miss -eq 1 ] || error "expected miss 1 but got $miss" + rm -f $p $DIR/$tfile +} +run_test 101h "Readahead should cover current read window" + setup_test102() { test_mkdir $DIR/$tdir chown $RUNAS_ID $DIR/$tdir