+test_101e() {
+ local file=$DIR/$tfile
+ local size=500 #KB
+ local count=100
+ local blksize=1024
+
+ local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
+ local need_space=$((count * size))
+ [ $space -gt $need_space ] ||
+ { skip_env "Need free space $need_space, have $space" && return; }
+
+ echo Creating $count ${size}K test files
+ for ((i = 0; i < $count; i++)); do
+ dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
+ done
+
+ 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
+
+ for ((i = 0; i < $count; i++)); do
+ dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
+ done
+
+ local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
+ get_named_value 'misses' | cut -d" " -f1 | calc_total)
+
+ for ((i = 0; i < $count; i++)); do
+ rm -rf ${file}_${i} 2>/dev/null
+ done
+
+ #10000 means 20% reads are missing in readahead
+ [ $miss -lt 10000 ] || error "misses too much for small reads"
+}
+run_test 101e "check read-ahead for small read(1k) for small files(500k)"
+
+cleanup_test101f() {
+ trap 0
+ $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
+ rm -rf $DIR/$tfile 2>/dev/null
+}
+
+test_101f() {
+ local file=$DIR/$tfile
+ local nreads=1000
+
+ MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
+ $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
+ dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
+ trap cleanup_test101f EXIT
+
+ 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
+ # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
+ # readahead should read in 2M file on second read, so only miss
+ # 2 pages.
+ echo Random 4K reads on 2M file for 1000 times
+ $READS -f $file -s 2097152 -b 4096 -n $nreads
+
+ echo checking missing pages
+ local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
+ get_named_value 'misses' | cut -d" " -f1 | calc_total)
+
+ [ $miss -lt 3 ] || error "misses too much pages!"
+ cleanup_test101f
+}
+run_test 101f "check read-ahead for max_read_ahead_whole_mb"
+