From: Wang Shilong Date: Wed, 25 Mar 2020 01:14:07 +0000 (+0800) Subject: LU-13386 llite: allow current readahead to exceed reservation X-Git-Tag: 2.13.54~227 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=777b04a09356afe425e9dc3dd3de385109990b52 LU-13386 llite: allow current readahead to exceed reservation ll_ra_count_get() is designed to allow over reservation for performance reasons, this could happen that multiple threads consuming a small readahead window limit, it will fallback to small 4K read which hurts performances. Fixes: 8fbef5e("LU-12043 llite: make sure readahead cover current read") Change-Id: Ied4ee0ffcd55c568c70f7d3074e810cd0034ef04 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/38047 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 6161bdc..b6559b4 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -729,9 +729,12 @@ 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_idx + vio->vui_ra_pages > ria->ria_start_idx) + vio->vui_ra_start_idx + vio->vui_ra_pages > ria->ria_start_idx) { ria->ria_end_idx_min = vio->vui_ra_start_idx + vio->vui_ra_pages - 1; + pages_min = vio->vui_ra_start_idx + vio->vui_ra_pages - + ria->ria_start_idx; + } ria->ria_reserved = ll_ra_count_get(ll_i2sbi(inode), ria, pages, pages_min); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a073da0..4d50dcf 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9273,6 +9273,30 @@ test_101h() { } run_test 101h "Readahead should cover current read window" +test_101i() { + dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || + error "dd 10M file failed" + + local max_per_file_mb=$($LCTL get_param -n \ + llite.*.max_read_ahead_per_file_mb 2>/dev/null) + cancel_lru_locks osc + stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb" + $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 || + error "set max_read_ahead_per_file_mb to 1 failed" + + echo "Reset readahead stats" + $LCTL set_param llite.*.read_ahead_stats=0 + + dd if=$DIR/$tfile of=/dev/null bs=2M + + $LCTL get_param llite.*.read_ahead_stats + local miss=$($LCTL get_param -n llite.*.read_ahead_stats | + awk '/misses/ { print $2 }') + [ $miss -eq 5 ] || error "expected misses 5 but got $miss" + rm -f $DIR/$tfile +} +run_test 101i "allow current readahead to exceed reservation" + setup_test102() { test_mkdir $DIR/$tdir chown $RUNAS_ID $DIR/$tdir