From 19a02f41f298db0b3403c6659b3c3bb29bca551e Mon Sep 17 00:00:00 2001 From: Li Wei Date: Tue, 22 May 2012 12:22:27 +0800 Subject: [PATCH] LU-1415 tests: Cope with ZFS's delayed space updates Space-related updates, such as changes of dn_used and of ds_used_bytes, are invisible to opertions like dt_attr_get() and dt_statfs() until after corresponding transaction groups start to be synchronized. This patch makes sure the tests do a dt_sync() for each OST before checking space usage. Change-Id: Icff5106c0c4c493ef981bc14a0aabac8da16764d Signed-off-by: Li Wei Reviewed-on: http://review.whamcloud.com/2909 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Brian Behlendorf Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 3 +- lustre/tests/sanityn.sh | 68 +++++++++++++++++++++++------------------- lustre/tests/test-framework.sh | 5 ++++ 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index dffae2f..db3c780 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -4267,7 +4267,8 @@ run_test 65l "lfs find on -1 stripe dir ========================" test_66() { COUNT=${COUNT:-8} dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT - sync; sleep 1; sync + sync; sync_all_data; sync; sync_all_data + cancel_lru_locks osc BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'` [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT" } diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 4897ed7..f015397 100644 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -898,38 +898,44 @@ test_35() { # bug 17645 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client" test_36() { #bug 16417 - local SIZE - local SIZE_B - local i + local SIZE + local SIZE_B + local i - mkdir -p $DIR1/$tdir - $LFS setstripe -c -1 $DIR1/$tdir - i=0 - SIZE=50 - let SIZE_B=SIZE*1024*1024 - - while [ $i -le 10 ]; do - lctl mark "start test" - local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }') - dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE - sync - sleep 1 - local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }') - multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3 - read_pid=$! - rm -f $DIR1/$tdir/file000 - kill -USR1 $read_pid - wait $read_pid - sleep 1 - local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }') - echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)" - # this free space! not used - if [ $after_dd -ge $after ]; then - error "space leaked" - return 1; - fi - let i=i+1 - done + mkdir -p $DIR1/$tdir + $LFS setstripe -c -1 $DIR1/$tdir + i=0 + SIZE=50 + let SIZE_B=SIZE*1024*1024 + + while [ $i -le 10 ]; do + lctl mark "start test" + local before=$($LFS df | awk '{if ($1 ~/^filesystem/) \ + {print $5; exit} }') + dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE + sync # sync data from client's cache + sync_all_data # sync data from server's cache (delayed + # allocation) + sleep 1 + local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) \ + {print $5; exit} }') + multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3 + read_pid=$! + rm -f $DIR1/$tdir/file000 + kill -USR1 $read_pid + wait $read_pid + sleep 1 + local after=$($LFS df | awk '{if ($1 ~/^filesystem/) \ + {print $5; exit} }') + echo "*** cycle($i) *** before($before) after_dd($after_dd)" \ + "after($after)" + # this free space! not used + if [ $after_dd -ge $after ]; then + error "space leaked" + return 1; + fi + let i=i+1 + done } run_test 36 "handle ESTALE/open-unlink corectly" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 7953df3..fe080f5 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -1580,6 +1580,11 @@ wait_update_facet () { wait_update $(facet_active_host $facet) "$@" } +sync_all_data() { + do_node $(osts_nodes) "lctl set_param -n osd*.*OS*.force_sync 1" 2>&1 | + grep -v 'Found no match' +} + wait_delete_completed () { local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \ awk 'BEGIN{total=0}; {total+=$1}; END{print total}'` -- 1.8.3.1