From 31856874bff8cc69f0357495978b3e74fc833936 Mon Sep 17 00:00:00 2001 From: grev Date: Fri, 29 May 2009 16:38:12 +0000 Subject: [PATCH] b=19414 i=Brian cmd3-33 read-ahead test --- lustre/tests/sanity.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ lustre/tests/sanityN.sh | 18 +++-------------- lustre/tests/test-framework.sh | 13 ++++++++++++ 3 files changed, 61 insertions(+), 15 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 33024f1..723c4da 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3940,6 +3940,51 @@ test_101b() { } run_test 101b "check stride-io mode read-ahead =================" +set_read_ahead() { + lctl get_param -n llite.*.max_read_ahead_mb | head -n 1 + lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1 +} + +test_101d() { + local file=$DIR/$tfile + local size=${FILESIZE_101c:-500} + local ra_MB=${READAHEAD_MB:-40} + + local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }') + [ $space -gt $((size / 1024)) ] || + { skip "Need free space ${size}M, have $space" && return; } + + echo Creating ${size}M test file $file + dd if=/dev/zero of=$file bs=1M count=$size + echo Cancel LRU locks on lustre client to flush the client cache + cancel_lru_locks osc + + echo Disable read-ahead + local old_READAHEAD=$(set_read_ahead 0) + + echo Reading the test file $file with read-ahead disabled + time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size") + + echo Cancel LRU locks on lustre client to flush the client cache + cancel_lru_locks osc + echo Enable read-ahead with ${ra_MB}MB + set_read_ahead $ra_MB + + echo Reading the test file $file with read-ahead enabled + time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size") + + echo read-ahead disabled time read $time_ra_OFF + echo read-ahead enabled time read $time_ra_ON + + set_read_ahead $old_READAHEAD + rm -f $file + + [ $time_ra_ON -lt $time_ra_OFF ] || + error "read-ahead enabled time read (${time_ra_ON}s) is more than + read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M" +} +run_test 101d "file read with and without read-ahead enabled =================" + export SETUP_TEST102=no setup_test102() { [ "$SETUP_TEST102" = "yes" ] && return diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh index 7f22445..c322f95 100644 --- a/lustre/tests/sanityN.sh +++ b/lustre/tests/sanityN.sh @@ -713,17 +713,6 @@ print_jbd_stat () { do_facet $SINGLEMDS cat /proc/fs/jbd/$dev/info | head -1 } -do_and_time () { - local cmd=$1 - - local start_ts=`date +%s` - - $cmd - - current_ts=`date +%s` - ELAPSED=`expr $current_ts - $start_ts` -} - # commit on sharing tests test_33a() { remote_mds_nodsh && skip "remote MDS with nodsh" && return @@ -750,17 +739,16 @@ test_33a() { avgjbd=0 avgtime=0 for i in 1 2 3; do - do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i" jbdold=$(print_jbd_stat) echo "=== START createmany $jbdold" - do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles" + local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > /dev/null 2>&1") jbdnew=$(print_jbd_stat) jbd=$((`echo $jbdnew | cut -d" " -f1` - `echo $jbdold | cut -d" " -f1`)) - echo "=== END createmany $jbdnew : $jbd transactions nfiles $nfiles time $ELAPSED COS=$COS" + echo "=== END createmany $jbdnew : $jbd transactions nfiles $nfiles time $elapsed COS=$COS" avgjbd=$(( avgjbd + jbd )) - avgtime=$(( avgtime + ELAPSED )) + avgtime=$(( avgtime + elapsed )) done eval cos${COS}_jbd=$((avgjbd / 3)) eval cos${COS}_time=$((avgtime / 3)) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 74613ab..3e3f074 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -2521,6 +2521,19 @@ multiop_bg_pause() { return 0 } +do_and_time () { + local cmd=$1 + local rc + + SECONDS=0 + eval '$cmd' + + [ ${PIPESTATUS[0]} -eq 0 ] || rc=1 + + echo $SECONDS + return $rc +} + inodes_available () { local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1 echo $IFree -- 1.8.3.1