Whamcloud - gitweb
LU-4322 tests: disable sanity 101a in DNE
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 9e1deb6..306157f 100644 (file)
@@ -788,7 +788,7 @@ run_test 24c "rename directory to non-existent target"
 test_24d() {
        test_mkdir $DIR/$tdir
        test_mkdir $DIR/$tdir/d$testnum.1
-       test_mkdir $DIR/$tdir/d$ttestnum.2
+       test_mkdir $DIR/$tdir/d$testnum.2
        mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
        $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
        $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
@@ -1126,6 +1126,7 @@ run_test 24z "rename one remote dir to another remote dir should fail"
 test_24A() { # LU-3182
        local NFILES=5000
 
+       rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
        createmany -m $DIR/$tdir/$tfile $NFILES
        local t=`ls $DIR/$tdir | wc -l`
@@ -1283,10 +1284,10 @@ test_27k() { # bug 2844
        [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
        $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
        BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
-       [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
+       [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
        dd if=/dev/zero of=$FILE bs=4k count=1
        BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
-       [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
+       [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
 }
 run_test 27k "limit i_blksize for broken user apps ============="
 
@@ -1717,26 +1718,7 @@ check_seq_oid()
                local dev=$(ostdevname $ost)
                local oid_hex
 
-               if [ $(facet_fstype ost$ost) != ldiskfs ]; then
-                       echo "Currently only works with ldiskfs-based OSTs"
-                       continue
-               fi
-
-                log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
-
-                #don't unmount/remount the OSTs if we don't need to do that
-               # LU-2577 changes filter_fid to be smaller, so debugfs needs
-               # update too, until that use mount/ll_decode_filter_fid/mount
-               local dir=$(facet_mntpt ost$ost)
-               local opts=${OST_MOUNT_OPTS}
-
-               if !  do_facet ost$ost test -b ${dev}; then
-                       opts=$(csa_add "$opts" -o loop)
-               fi
-
-               stop ost$ost
-               do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir ||
-                       { error "mounting $dev as $FSTYPE failed"; return 3; }
+               log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
 
                seq=$(echo $seq | sed -e "s/^0x//g")
                if [ $seq == 0 ]; then
@@ -1744,25 +1726,48 @@ check_seq_oid()
                else
                        oid_hex=$(echo $hex | sed -e "s/^0x//g")
                fi
-               local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid_hex)
-               local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
-               do_facet ost$ost umount -d $dir
-               start ost$ost $dev $OST_MOUNT_OPTS
+               local obj_file="O/$seq/d$((oid %32))/$oid_hex"
 
-               # re-enable when debugfs will understand new filter_fid
-               #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
-                #           $dev 2>/dev/null" | grep "parent=")
+               local ff
+               #
+               # Don't unmount/remount the OSTs if we don't need to do that.
+               # LU-2577 changes filter_fid to be smaller, so debugfs needs
+               # update too, until that use mount/ll_decode_filter_fid/mount.
+               # Re-enable when debugfs will understand new filter_fid.
+               #
+               if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
+                       ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
+                               $dev 2>/dev/null" | grep "parent=")
+               else
+                       stop ost$ost
+                       mount_fstype ost$ost
+                       ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
+                               $(facet_mntpt ost$ost)/$obj_file)
+                       unmount_fstype ost$ost
+                       start ost$ost $dev $OST_MOUNT_OPTS
+               fi
 
-                [ -z "$ff" ] && error "$obj_file: no filter_fid info"
+               [ -z "$ff" ] && error "$obj_file: no filter_fid info"
 
-                echo "$ff" | sed -e 's#.*objid=#got: objid=#'
+               echo "$ff" | sed -e 's#.*objid=#got: objid=#'
 
-                # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
-                # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
-                local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
-                local ff_pseq=$(echo $ff_parent | cut -d: -f1)
-                local ff_poid=$(echo $ff_parent | cut -d: -f2)
-                local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
+               # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
+               # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
+               local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
+               local ff_pseq=$(echo $ff_parent | cut -d: -f1)
+               local ff_poid=$(echo $ff_parent | cut -d: -f2)
+               local ff_pstripe
+               if echo $ff_parent | grep -q 'stripe='; then
+                       ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
+               else
+                       #
+                       # $LL_DECODE_FILTER_FID does not print "stripe="; look
+                       # into f_ver in this case.  See the comment on
+                       # ff_parent.
+                       #
+                       ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
+                               sed -e 's/\]//')
+               fi
 
                 # compare lmm_seq and filter_fid->ff_parent.f_seq
                 [ $ff_pseq = $lmm_seq ] ||
@@ -1770,7 +1775,7 @@ check_seq_oid()
                 # compare lmm_object_id and filter_fid->ff_parent.f_oid
                 [ $ff_poid = $lmm_oid ] ||
                         error "FF parent OID $ff_poid != $lmm_oid"
-                [ $ff_pstripe = $stripe_nr ] ||
+               (($ff_pstripe == $stripe_nr)) ||
                         error "FF stripe $ff_pstripe != $stripe_nr"
 
                 stripe_nr=$((stripe_nr + 1))
@@ -1808,13 +1813,13 @@ test_27A() { # b=19102
         local restore_count=$($GETSTRIPE -c $MOUNT)
         local restore_offset=$($GETSTRIPE -i $MOUNT)
         $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
+        wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/  *//g'" "1" 20 ||
+                error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
         local default_size=$($GETSTRIPE -S $MOUNT)
-        local default_count=$($GETSTRIPE -c $MOUNT)
         local default_offset=$($GETSTRIPE -i $MOUNT)
         local dsize=$((1024 * 1024))
         [ $default_size -eq $dsize ] ||
                 error "stripe size $default_size != $dsize"
-        [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
         [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
         $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
 }
@@ -2119,14 +2124,17 @@ test_31n() {
        touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
        nlink=$(stat --format=%h $DIR/$tfile)
        [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
-       exec 173<$DIR/$tfile
-       trap "exec 173<&-" EXIT
-       nlink=$(stat --dereference --format=%h /proc/self/fd/173)
+       local fd=$(free_fd)
+       local cmd="exec $fd<$DIR/$tfile"
+       eval $cmd
+       cmd="exec $fd<&-"
+       trap "eval $cmd" EXIT
+       nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
        [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
        rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
-       nlink=$(stat --dereference --format=%h /proc/self/fd/173)
+       nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
        [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
-       exec 173<&-
+       eval $cmd
 }
 run_test 31n "check link count of unlinked file"
 
@@ -2155,7 +2163,7 @@ run_test 31o "duplicate hard links with same filename"
 
 cleanup_test32_mount() {
        trap 0
-       $UMOUNT $DIR/$tdir/ext2-mountpoint
+       $UMOUNT -d $DIR/$tdir/ext2-mountpoint
 }
 
 test_32a() {
@@ -2363,7 +2371,7 @@ run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
 
 cleanup_testdir_mount() {
        trap 0
-       $UMOUNT $DIR/$tdir
+       $UMOUNT -d $DIR/$tdir
 }
 
 test_32q() {
@@ -3133,7 +3141,7 @@ run_test 39n "check that O_NOATIME is honored"
 test_39o() {
        TESTDIR=$DIR/$tdir/$tfile
        [ -e $TESTDIR ] && rm -rf $TESTDIR
-       mkdir -p $TESTDIR
+       test_mkdir -p $TESTDIR
        cd $TESTDIR
        links1=2
        ls
@@ -3150,6 +3158,30 @@ test_39o() {
 }
 run_test 39o "directory cached attributes updated after create ========"
 
+test_39p() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       local MDTIDX=1
+       TESTDIR=$DIR/$tdir/$tfile
+       [ -e $TESTDIR ] && rm -rf $TESTDIR
+       mkdir -p $TESTDIR
+       cd $TESTDIR
+       links1=2
+       ls
+       $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
+       $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
+       ls
+       links2=$(stat -c %h .)
+       [ $(($links1 + 2)) != $links2 ] &&
+               error "wrong links count $(($links1 + 2)) != $links2"
+       rmdir remote_dir2
+       links3=$(stat -c %h .)
+       [ $(($links1 + 1)) != $links3 ] &&
+               error "wrong links count $links1 != $links3"
+       return 0
+}
+run_test 39p "remote directory cached attributes updated after create ========"
+
+
 test_40() {
        dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
        $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
@@ -3955,7 +3987,7 @@ test_54c() {
        dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
        df $tdir
        dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
-       $UMOUNT $tdir
+       $UMOUNT -d $tdir
        losetup -d $loopdev
        rm $loopdev
 }
@@ -4571,6 +4603,9 @@ test_56x() {
 run_test 56x "lfs migration support"
 
 test_56y() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
+               skip "No HSM support on MDS of $(get_lustre_version)," \
+                        "need 2.4.53 at least" && return
        local res=""
 
        local dir0=$DIR/$tdir/$testnum
@@ -4668,7 +4703,7 @@ test_57b() {
        local MDSFREE2=$(do_facet $mymds \
                lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
        local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
-       if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
+       if [ "$MDCFREE2" -lt "$((MDCFREE - 16))" ]; then
                if [ "$MDSFREE" != "$MDSFREE2" ]; then
                        error "MDC before $MDCFREE != after $MDCFREE2"
                else
@@ -5777,6 +5812,7 @@ cleanup_101a() {
 
 test_101a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
        local s
        local discard
        local nreads=10000
@@ -6376,6 +6412,75 @@ run_test 102m "Ensure listxattr fails on small bufffer ========"
 
 cleanup_test102
 
+getxattr() { # getxattr path name
+       # Return the base64 encoding of the value of xattr name on path.
+       local path=$1
+       local name=$2
+
+       # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
+       # file: $path
+       # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
+       #
+       # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
+
+       getfattr --absolute-names --encoding=base64 --name=$name $path |
+               awk -F= -v name=$name '$1 == name {
+                       print substr($0, index($0, "=") + 1);
+       }'
+}
+
+test_102n() { # LU-4101 mdt: protect internal xattrs
+       local file0=$DIR/$tfile.0
+       local file1=$DIR/$tfile.1
+       local xattr0=$TMP/$tfile.0
+       local xattr1=$TMP/$tfile.1
+       local name
+       local value
+
+       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
+       then
+               skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
+               return
+       fi
+
+       rm -rf $file0 $file1 $xattr0 $xattr1
+       touch $file0 $file1
+
+       # Get 'before' xattrs of $file1.
+       getfattr --absolute-names --dump --match=- $file1 > $xattr0
+
+       for name in lov lma lmv link fid version som hsm lfsck_namespace; do
+               # Try to copy xattr from $file0 to $file1.
+               value=$(getxattr $file0 trusted.$name 2> /dev/null)
+
+               setfattr --name=trusted.$name --value="$value" $file1 ||
+                       error "setxattr 'trusted.$name' failed"
+
+               # Try to set a garbage xattr.
+               value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
+
+               setfattr --name=trusted.$name --value="$value" $file1 ||
+                       error "setxattr 'trusted.$name' failed"
+
+               # Try to remove the xattr from $file1. We don't care if this
+               # appears to succeed or fail, we just don't want there to be
+               # any changes or crashes.
+               setfattr --remove=$trusted.$name $file1 2> /dev/null
+       done
+
+       # Get 'after' xattrs of file1.
+       getfattr --absolute-names --dump --match=- $file1 > $xattr1
+
+       if ! diff $xattr0 $xattr1; then
+               error "before and after xattrs of '$file1' differ"
+       fi
+
+       rm -rf $file0 $file1 $xattr0 $xattr1
+
+       return 0
+}
+run_test 102n "silently ignore setxattr on internal trusted xattrs"
+
 run_acl_subtest()
 {
     $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
@@ -6689,7 +6794,7 @@ test_116a() { # was previously test_116()
                echo "ok"
        else
                echo "failed - QOS mode won't be used"
-               error_ignore 0000 "QOS imbalance criteria not met"
+               skip "QOS imbalance criteria not met"
                simple_cleanup_common
                return
        fi
@@ -6743,8 +6848,7 @@ test_116a() { # was previously test_116()
        [ $MINC -gt 0 ] &&
                echo "Wrote ${FILL}% more files to larger OST $MAXI1"
        [ $MAXC -gt $MINC ] ||
-               error_ignore 0000 "stripe QOS didn't balance free space"
-
+               error_ignore LU-9 "stripe QOS didn't balance free space"
        simple_cleanup_common
 }
 run_test 116a "stripe QOS: free space balance ==================="
@@ -9303,12 +9407,11 @@ test_156() {
     BEFORE=`roc_hit`
     cat $file >/dev/null
     AFTER=`roc_hit`
-    if ! let "AFTER - BEFORE == 0"; then
-        error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
-    else
-        log "cache hits:: before: $BEFORE, after: $AFTER"
-    fi
-
+       if ! let "AFTER - BEFORE == 0"; then
+               error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
+       else
+               log "cache hits:: before: $BEFORE, after: $AFTER"
+       fi
 
     log "Turn on the read cache and turn off the write cache"
     set_cache read on
@@ -9322,11 +9425,11 @@ test_156() {
     cancel_lru_locks osc
     cat $file >/dev/null
     AFTER=`roc_hit`
-    if ! let "AFTER - BEFORE == 0"; then
-        error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
-    else
-        log "cache hits:: before: $BEFORE, after: $AFTER"
-    fi
+       if ! let "AFTER - BEFORE == 0"; then
+               error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
+       else
+               log "cache hits:: before: $BEFORE, after: $AFTER"
+       fi
 
     log "Read again; it should be satisfied from the cache."
     BEFORE=`roc_hit`
@@ -9346,7 +9449,7 @@ run_test 156 "Verification of tunables ============================"
 #Changelogs
 err17935 () {
        if [ $MDSCOUNT -gt 1 ]; then
-               error_ignore 17935 $*
+               error_ignore bz17935 $*
        else
                error $*
        fi
@@ -10842,6 +10945,31 @@ test_208() {
 }
 run_test 208 "Exclusive open"
 
+test_209() {
+       [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
+               skip_env "must have disp_stripe" && return
+
+       touch $DIR/$tfile
+       sync; sleep 5; sync;
+
+       echo 3 > /proc/sys/vm/drop_caches
+       req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
+
+       # open/close 500 times
+       for i in $(seq 500); do
+               cat $DIR/$tfile
+       done
+
+       echo 3 > /proc/sys/vm/drop_caches
+       req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
+
+       echo "before: $req_before, after: $req_after"
+       [ $((req_after - req_before)) -ge 300 ] &&
+               error "open/close requests are not freed"
+       return 0
+}
+run_test 209 "read-only open/close requests should be freed promptly"
+
 test_212() {
        size=`date +%s`
        size=$((size % 8192 + 1))
@@ -11513,6 +11641,9 @@ test_228c() {
 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
 
 test_229() { # LU-2482, LU-3448
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
+               skip "No HSM support on MDS of $(get_lustre_version)," \
+                        "need 2.4.53 at least" && return
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
 
@@ -11732,11 +11863,14 @@ test_236() {
        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
+       local fd=$(free_fd)
+       local cmd="exec $fd<>$file2"
+       eval $cmd
        rm $file2
-       $LFS swap_layouts $file1 /proc/self/fd/${FD} ||
-               error "cannot swap layouts of '$file1' and /proc/self/fd/${FD}"
-       exec {FD}>&-
+       $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
+               error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
+       cmd="exec $fd>&-"
+       eval $cmd
        cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
 
        #cleanup