Whamcloud - gitweb
Landing b_bug974 onto HEAD (20040213_1538).
[fs/lustre-release.git] / lustre / tests / sanity.sh
index b49cd49..ec166e4 100644 (file)
@@ -14,7 +14,7 @@ ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
 
 SRCDIR=`dirname $0`
-PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
+export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
 
 TMP=${TMP:-/tmp}
 
@@ -628,6 +628,17 @@ test_24m() {
 }
 run_test 24m "Renaming a file to a hard link to itself ========="
 
+test_24n() {
+    f="$DIR/f24n"
+    # this stats the old file after it was renamed, so it should fail
+    touch ${f}
+    $CHECKSTAT ${f}
+    mv ${f} ${f}.rename
+    $CHECKSTAT ${f}.rename
+    $CHECKSTAT -a ${f}
+}
+run_test 24n "Statting the old file after renameing (Posix rename 2)"
+
 test_25a() {
        echo '== symlink sanity ============================================='
        mkdir $DIR/d25
@@ -745,11 +756,11 @@ test_27g() {
        $MCREATE $DIR/d27/fnone || error
        pass
        log "== test 27h: lfind with no objects ============================"
-       $LFIND $DIR/d27/fnone 2>&1 | grep -q "no stripe info" || error
+       $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error
        pass
        log "== test 27i: lfind with some objects =========================="
        touch $DIR/d27/fsome || error
-       $LFIND $DIR/d27/fsome | grep -q obdidx || error
+       $LFIND $DIR/d27/fsome | grep obdidx || error
 }
 run_test 27g "test lfind ======================================="
 
@@ -1034,20 +1045,20 @@ test_32q() {
        mkdir -p $DIR/d32q
         touch $DIR/d32q/under_the_mount
        mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
-       ls $DIR/d32q/under_the_mount &&  error || true
+       ls $DIR/d32q/under_the_mount && error || true
        umount $DIR/d32q || error
 }
-run_test 32q "stat follows mountpoints in Lustre ========================="
+run_test 32q "stat follows mountpoints in Lustre (should return error)"
 
 test_32r() {
        [ -e $DIR/d32r ] && rm -fr $DIR/d32r
        mkdir -p $DIR/d32r
         touch $DIR/d32r/under_the_mount
        mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
-       ls $DIR/d32r | grep -q under_the_mount &&  error || true
+       ls $DIR/d32r | grep -q under_the_mount && error || true
        umount $DIR/d32r || error
 }
-run_test 32r "opendir follows mountpoints in Lustre ========================="
+run_test 32r "opendir follows mountpoints in Lustre (should return error)"
 
 #   chmod 444 /mnt/lustre/somefile
 #   open(/mnt/lustre/somefile, O_RDWR)
@@ -1070,7 +1081,7 @@ test_33a() {
         $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
         $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
 }
-run_test 33a "test open file(mode=0444) with O_RDWR (should return error) ===="
+run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
 
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
@@ -1294,7 +1305,7 @@ test_42c() {
             error "$BEFOREWRITES < $AFTERWRITES on truncate"
         rm $file
 }
-run_test 42c "test partial truncate of file with cached dirty data ===="
+run_test 42c "test partial truncate of file with cached dirty data"
 
 test_42d() {
         trunc_test 42d 0
@@ -1302,7 +1313,7 @@ test_42d() {
             error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
         rm $file
 }
-run_test 42d "test complete truncate of file with cached dirty data ===="
+run_test 42d "test complete truncate of file with cached dirty data"
 
 test_43() {
        mkdir $DIR/d43
@@ -1311,7 +1322,7 @@ test_43() {
        $DIR/d43/f && error || true
        exec 100<&-
 }
-run_test 43 "execution of file opened for write should return -ETXTBSY=="
+run_test 43 "execution of file opened for write should return -ETXTBSY"
 
 test_43a() {
         mkdir -p $DIR/d43
@@ -1324,7 +1335,7 @@ test_43a() {
         kill -USR1 $MULTIPID || return 2
         wait $MULTIPID || return 3
 }
-run_test 43a "open(RDWR) of file being executed should return -ETXTBSY=="
+run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
 
 test_43b() {
         mkdir -p $DIR/d43
@@ -1337,16 +1348,16 @@ test_43b() {
         kill -USR1 $MULTIPID || return 2
         wait $MULTIPID || return 3
 }
-run_test 43b "truncate of file being executed should return -ETXTBSY===="
+run_test 43b "truncate of file being executed should return -ETXTBSY"
 
 test_43c() {
        local testdir="$DIR/d43c"
        mkdir -p $testdir
        cp $SHELL $testdir/
-       ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |  \
+       ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
                ( cd $testdir && md5sum -c)
 }
-run_test 43c "md5sum of copy into lustre================================"
+run_test 43c "md5sum of copy into lustre========================"
 
 test_44() {
        [  "$STRIPECOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
@@ -1403,6 +1414,8 @@ do_dirty_record() {
 }
 test_45() {
        f="$DIR/f45"
+       # Obtain grants from OST if it supports it
+       echo blah > ${f}_grant
        stop_kupdated
        sync
        do_dirty_record "echo blah > $f"
@@ -1455,7 +1468,7 @@ test_48() {
         mkdir $DIR/d48 || error "recreate diectory failed"
         ls || error "can't list after recreate directory"
 }
-run_test 48 "Access renamed current working directory ========="
+run_test 48 "Access renamed current working directory =========="
 
 test_50() {
        # bug 1485
@@ -1521,7 +1534,7 @@ test_52b() {
 run_test 52b "immutable flag test (should return errors) ======="
 
 test_53() {
-        for i in /proc/fs/lustre/osc/OSC*mds1 ; do
+        for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
                 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
                 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
                 mds_last=`cat $i/prealloc_last_id`
@@ -1558,30 +1571,33 @@ test_56() {
         rm -rf $DIR/d56
         mkdir $DIR/d56
         mkdir $DIR/d56/dir
-        for i in `seq 1 3` ; do
+        NUMFILES=3
+        NUMFILESx2=$(($NUMFILES * 2))
+        for i in `seq 1 $NUMFILES` ; do
                 touch $DIR/d56/file$i
                 touch $DIR/d56/dir/file$i
         done
 
         # test lfs find with --recursive
-        FILENUM=`$LFIND --recursive $DIR/d56 | grep obdidx | wc -l`
-        [ $FILENUM -eq 6 ] || error \
-                "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected 6"
-        FILENUM=`$LFIND $DIR/d56 | grep obdidx | wc -l`
-        [ $FILENUM -eq 3 ] || error \
-                "lfs find $DIR/d56 without --recursive wrong: found $FILENUM, expected 3"
+        FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx`
+        [ $FILENUM -eq $NUMFILESx2 ] || error \
+                "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
+        FILENUM=`$LFIND $DIR/d56 | grep -c obdidx`
+        [ $FILENUM -eq $NUMFILES ] || error \
+                "lfs find $DIR/d56 without --recursive wrong: found $FILENUM,
+               expected $NUMFILES"
         echo "lfs find --recursive passed."
 
         # test lfs find with file instead of dir
-        FILENUM=`$LFIND $DIR/d56/file1 | grep obdidx | wc -l`
+        FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx`
         [ $FILENUM  -eq 1 ] || error \
                  "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1"
         echo "lfs find file passed."
 
         #test lfs find with --verbose
-        [ `$LFIND --verbose $DIR/d56 | grep lmm_magic | wc -l` -eq 3 ] ||\
-                error "lfs find --verbose $DIR/d56 wrong: should find 3 lmm_magic info"
-        [ `$LFIND $DIR/d56 | grep lmm_magic | wc -l` -eq 0 ] || error \
+        [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
+                error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
+        [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
                 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
         echo "lfs find --verbose passed."
 
@@ -1591,17 +1607,72 @@ test_56() {
 
         [  "$STRIPECOUNT" -lt 2 ] && \
                 echo "skipping other lfs find --obd test" && return
-        FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[\t ]*1[\t ]/p' | wc -l`
-        OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[\t ]*1:/p' | awk '{print $2}'`
+        FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[      ]*1[    ]/p' | wc -l`
+        OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[      ]*1:/p' | awk '{print $2}'`
         FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l`
-        [ $FOUND -eq $FILENUM ] ||\
+        [ $FOUND -eq $FILENUM ] || \
                 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
-        [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[\t ]*1[\t ]/d' | \
-                sed -n '/^[\t ]*[0-9][0-9]*[\t ]/p' | wc -l` -eq 0 ] || \
+        [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[      ]*1[    ]/d' | \
+                sed -n '/^[     ]*[0-9][0-9]*[  ]/p' | wc -l` -eq 0 ] || \
                 error "lfs find --obd wrong: should not show file on other obd"
         echo "lfs find --obd passed."
 }
-run_test 56 "check lfs find====================================="
+run_test 56 "check lfs find ===================================="
+
+test_57a() {
+       # note test will not do anything if MDS is not local
+       for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
+               dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
+               DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
+               [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
+               rm $TMP/t57a.dump
+       done
+}
+run_test 57a "verify MDS filesystem created with large inodes =="
+
+test_57b() {
+       FILECOUNT=100
+       FILE1=$DIR/d57b/f1
+       FILEN=$DIR/d57b/f$FILECOUNT
+       rm -rf $DIR/d57b || error "removing $DIR/d57b"
+       mkdir -p $DIR/d57b || error "creating $DIR/d57b"
+       echo "mcreating $FILECOUNT files"
+       createmany -m $DIR/d57b/f 1 $FILECOUNT || \
+               error "creating files in $DIR/d57b"
+
+       # verify that files do not have EAs yet
+       $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
+       $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
+
+       MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
+       MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
+       echo "opening files to create objects/EAs"
+       for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
+               $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
+       done
+
+       # verify that files have EAs now
+       $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
+       $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
+
+       MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
+       MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
+       if [ "$MDCFREE" != "$MDCFREE2" ]; then
+               if [ "$MDSFREE" != "$MDSFREE2" ]; then
+                       error "MDC before $MDCFREE != after $MDCFREE2"
+               else
+                       echo "MDC before $MDCFREE != after $MDCFREE2"
+                       echo "unable to confirm if MDS has large inodes"
+               fi
+       fi
+       rm -rf $DIR/d57b
+}
+run_test 57b "default LOV EAs are stored inside large inodes ==="
+
+test_58() {
+       wiretest
+}
+run_test 58 "verify cross-platform wire constants =============="
 
 test_59() {
        echo "touch 130 files"
@@ -1631,7 +1702,7 @@ test_61() {
        multiop $f OSMWUc || error
        sync
 }
-run_test 61 "mmap() writes don't make sync hang =========="
+run_test 61 "mmap() writes don't make sync hang ================"
 
 # bug 2330 - insufficient obd_match error checking causes LBUG
 test_62() {
@@ -1639,8 +1710,8 @@ test_62() {
         echo foo > $f
         cancel_lru_locks OSC
         echo 0x405 > /proc/sys/lustre/fail_loc
-        cat $f && error # expect -EIO
-        multiop $f Owc && error
+        cat $f && error "cat succeeded, expect -EIO"
+        multiop $f Owc && error "multiop succeeded, expect -EIO"
         echo 0 > /proc/sys/lustre/fail_loc
 }
 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
@@ -1665,6 +1736,17 @@ test_63() {
 }
 run_test 63 "Verify osic_wait interruption does not crash ======"
 
+test_64a () {
+       df $DIR
+       grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
+}
+run_test 64a "verify filter grant calculations (in kernel) ======"
+
+test_64b () {
+       sh oos.sh $MOUNT
+}
+run_test 64b "check out-of-space detection on client ============"
+
 # on the LLNL clusters, runas will still pick up root's $TMP settings,
 # which will not be writable for the runas user, and then you get a CVS
 # error message with a corrupt path string (CVS bug) and panic.