Whamcloud - gitweb
LU-1415 tests: Cope with ZFS's delayed space updates
authorLi Wei <liwei@whamcloud.com>
Tue, 22 May 2012 04:22:27 +0000 (12:22 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Jul 2012 16:41:27 +0000 (12:41 -0400)
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 <liwei@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/2909
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh
lustre/tests/sanityn.sh
lustre/tests/test-framework.sh

index dffae2f..db3c780 100644 (file)
@@ -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"
 }
index 4897ed7..f015397 100644 (file)
@@ -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"
 
index 7953df3..fe080f5 100644 (file)
@@ -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}'`