Whamcloud - gitweb
LU-14 utils: allow formatting OST without VIRGIN flag
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 75e3bc1..9280dbd 100644 (file)
@@ -990,7 +990,7 @@ max_pages_per_rpc() {
 
 test_24v() {
        local NRFILES=100000
-       local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
+       local FREE_INODES=$(mdt_free_inodes 0)
        [ $FREE_INODES -lt $NRFILES ] && \
                skip "not enough free inodes $FREE_INODES required $NRFILES" &&
                return
@@ -1050,6 +1050,9 @@ test_24x() {
        mkdir -p $remote_dir/tgt_dir
        touch $remote_dir/tgt_file
 
+       mrename $remote_dir $DIR/ &&
+               error "rename dir cross MDT works!"
+
        mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
                error "rename dir cross MDT works!"
 
@@ -1355,9 +1358,9 @@ exhaust_precreations() {
        # on the mdt's osc
        local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
        local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
-        osc.$mdtosc_proc1.prealloc_last_id)
+                       osc.$mdtosc_proc1.prealloc_last_id)
        local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
-        osc.$mdtosc_proc1.prealloc_next_id)
+                       osc.$mdtosc_proc1.prealloc_next_id)
 
        local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
        do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
@@ -6338,7 +6341,15 @@ test_102l() {
 
        return 0;
 }
-run_test 102l "listxattr filter test =================================="
+run_test 102l "listxattr size test =================================="
+
+test_102m() { # LU-3403 llite: error of listxattr when buffer is small
+       local path=$DIR/$tfile
+       touch $path
+
+       listxattr_size_check $path || error "listattr_size_check $path failed"
+}
+run_test 102m "Ensure listxattr fails on small bufffer ========"
 
 cleanup_test102
 
@@ -8026,10 +8037,14 @@ test_130d() {
        $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
                skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
-       dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
+
+       local actual_stripecnt=$($GETSTRIPE -c $fm_file)
+       dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
+               error "dd failed on $fm_file"
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
-       filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
+       filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
+               grep -v "ext:" | grep -v "found"`
 
        last_lun=`echo $filefrag_op | cut -d: -f5`
 
@@ -8053,7 +8068,7 @@ test_130d() {
                (( tot_len += ext_len ))
                last_lun=$frag_lun
        done
-       if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
+       if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
                cleanup_130
                error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
                return
@@ -10763,14 +10778,15 @@ test_213() {
 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
 
 test_214() { # for bug 20133
-       test_mkdir -p $DIR/d214p/d214c
+       mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
        for (( i=0; i < 340; i++ )) ; do
-               touch $DIR/d214p/d214c/a$i
+               touch $DIR/$tdir/d214c/a$i
        done
 
-       ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
-       mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
+       ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
+       mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
        ls $DIR/d214c || error "ls $DIR/d214c failed"
+       rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
        rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
 }
 run_test 214 "hash-indexed directory test - bug 20133"
@@ -11430,26 +11446,13 @@ test_229() { # LU-2482, LU-3448
        [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
        stat $DIR/$tfile || error "failed to stat released file"
 
-       $TRUNCATE $DIR/$tfile 200000 &&
-               error "truncate of released file should fail"
-
-       # Ensure that nothing happened anyway.
-       $CHECKSTAT -s 0 $DIR/$tfile ||
-               error "released file size should not change"
-
-       # Stripe count should be no change after truncate
-       stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe failed"
-       [ $stripe_count -eq 2 ] || error "after trunc: ($stripe_count)"
-
        chown $RUNAS_ID $DIR/$tfile ||
                error "chown $RUNAS_ID $DIR/$tfile failed"
 
        chgrp $RUNAS_ID $DIR/$tfile ||
                error "chgrp $RUNAS_ID $DIR/$tfile failed"
 
-       touch $DIR/$tfile ||
-               error "touch $DIR/$tfile failed"
-
+       touch $DIR/$tfile || error "touch $DIR/$tfile failed"
        rm $DIR/$tfile || error "failed to remove released file"
 }
 run_test 229 "getstripe/stat/rm/attr changes work on released files"
@@ -11600,11 +11603,12 @@ test_234() {
        touch $DIR/$tdir/$tfile || error "touch failed"
        # OBD_FAIL_LLITE_XATTR_ENOMEM
        $LCTL set_param fail_loc=0x1405
-       setfattr -n user.attr -v value $DIR/$tdir/$tfile &&
-               error "setfattr should have failed with ENOMEM"
-       # attr pre-2.4.44-7 had a bug with rc
-       getfattr -n user.attr $DIR/$tdir/$tfile &&
-               error "getfattr should have failed with ENOMEM"
+       if [ ! -f /etc/SuSE-release ]; then
+               # attr pre-2.4.44-7 had a bug with rc
+               # LU-3703 - SLES clients have older attr
+               getfattr -n user.attr $DIR/$tdir/$tfile &&
+                       error "getfattr should have failed with ENOMEM"
+       fi
        $LCTL set_param fail_loc=0x0
        rm -rf $DIR/$tdir
 
@@ -11629,6 +11633,32 @@ test_235() {
 }
 run_test 235 "LU-1715: flock deadlock detection does not work properly"
 
+#LU-2935
+test_236() {
+       check_swap_layouts_support && return 0
+       test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+
+       local ref1=/etc/passwd
+       local ref2=/etc/group
+       local file1=$DIR/$tdir/f1
+       local file2=$DIR/$tdir/f2
+
+       $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
+       cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
+       $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
+       cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
+       exec {FD}<>$file2
+       rm $file2
+       $LFS swap_layouts $file1 /proc/self/fd/${FD} ||
+               error "cannot swap layouts of '$file1' and /proc/self/fd/${FD}"
+       exec {FD}>&-
+       cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
+
+       #cleanup
+       rm -rf $DIR/$tdir
+}
+run_test 236 "Layout swap on open unlinked file"
+
 #
 # tests that do cleanup/setup should be run at the end
 #