Whamcloud - gitweb
LU-13386 llite: allow current readahead to exceed reservation 47/38047/4
authorWang Shilong <wshilong@ddn.com>
Wed, 25 Mar 2020 01:14:07 +0000 (09:14 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 7 Apr 2020 17:21:43 +0000 (17:21 +0000)
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 <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/38047
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/rw.c
lustre/tests/sanity.sh

index 6161bdc..b6559b4 100644 (file)
@@ -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);
index a073da0..4d50dcf 100755 (executable)
@@ -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