Skip to content

Commit 8fbef5e

Browse files
Wang ShilongOleg Drokin
authored andcommitted
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 <[email protected]> Reviewed-on: https://review.whamcloud.com/35215 Tested-by: jenkins <[email protected]> Tested-by: Maloo <[email protected]> Reviewed-by: Patrick Farrell <[email protected]> Reviewed-by: Li Xi <[email protected]> Reviewed-by: Oleg Drokin <[email protected]>
1 parent 218fc68 commit 8fbef5e

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

lustre/llite/rw.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,16 +677,8 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io,
677677

678678
/* at least to extend the readahead window to cover current read */
679679
if (!hit && vio->vui_ra_valid &&
680-
vio->vui_ra_start + vio->vui_ra_count > ria->ria_start) {
681-
unsigned long remainder;
682-
683-
/* to the end of current read window. */
684-
mlen = vio->vui_ra_start + vio->vui_ra_count - ria->ria_start;
685-
/* trim to RPC boundary */
686-
ras_align(ras, ria->ria_start, &remainder);
687-
mlen = min(mlen, ras->ras_rpc_size - remainder);
688-
ria->ria_end_min = ria->ria_start + mlen;
689-
}
680+
vio->vui_ra_start + vio->vui_ra_count > ria->ria_start)
681+
ria->ria_end_min = vio->vui_ra_start + vio->vui_ra_count - 1;
690682

691683
ria->ria_reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len, mlen);
692684
if (ria->ria_reserved < len)

lustre/tests/sanity.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8617,6 +8617,26 @@ test_101g() {
86178617
}
86188618
run_test 101g "Big bulk(4/16 MiB) readahead"
86198619

8620+
test_101h() {
8621+
$LFS setstripe -i 0 -c 1 $DIR/$tfile
8622+
8623+
dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
8624+
error "dd 70M file failed"
8625+
echo Cancel LRU locks on lustre client to flush the client cache
8626+
cancel_lru_locks osc
8627+
8628+
echo "Reset readahead stats"
8629+
$LCTL set_param -n llite.*.read_ahead_stats 0
8630+
8631+
echo "Read 10M of data but cross 64M bundary"
8632+
dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
8633+
local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8634+
get_named_value 'misses' | cut -d" " -f1 | calc_total)
8635+
[ $miss -eq 1 ] || error "expected miss 1 but got $miss"
8636+
rm -f $p $DIR/$tfile
8637+
}
8638+
run_test 101h "Readahead should cover current read window"
8639+
86208640
setup_test102() {
86218641
test_mkdir $DIR/$tdir
86228642
chown $RUNAS_ID $DIR/$tdir

0 commit comments

Comments
 (0)