Whamcloud - gitweb
LU-12043 llite: make sure readahead cover current read 15/35215/4
authorWang Shilong <wshilong@ddn.com>
Thu, 13 Jun 2019 01:35:12 +0000 (09:35 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 17 Jul 2019 06:21:45 +0000 (06:21 +0000)
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 <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/35215
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/rw.c
lustre/tests/sanity.sh

index df9b9a4..d8f4075 100644 (file)
@@ -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)
index 4dcc658..37e6ab7 100644 (file)
@@ -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