Whamcloud - gitweb
LU-3131 tests: fix sanity 56u/102k for single OST.
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 7685c77..2282370 100644 (file)
@@ -1119,6 +1119,11 @@ test_24z() {
        mrename $remote_src $remote_tgt &&
                error "rename remote dirs should not work!"
 
+       # If target dir does not exists, it should succeed
+       rm -rf $remote_tgt
+       mrename $remote_src $remote_tgt ||
+               error "rename remote dirs(tgt dir does not exists) failed!"
+
        rm -rf $DIR/$tdir || error "Can not delete directories"
 }
 run_test 24z "rename one remote dir to another remote dir should fail"
@@ -1494,22 +1499,24 @@ test_27t() { # bug 10864
 run_test 27t "check that utils parse path correctly"
 
 test_27u() { # bug 4900
-        [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
-        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       local index
+       local list=$(comma_list $(mdts_nodes))
 
 #define OBD_FAIL_MDS_OSC_PRECREATE      0x139
-        do_facet $SINGLEMDS lctl set_param fail_loc=0x139
-        test_mkdir -p $DIR/$tdir
+       do_nodes $list $LCTL set_param fail_loc=0x139
+       test_mkdir -p $DIR/$tdir
        rm -rf $DIR/$tdir/*
-        createmany -o $DIR/$tdir/t- 1000
-        do_facet $SINGLEMDS lctl set_param fail_loc=0
+       createmany -o $DIR/$tdir/t- 1000
+       do_nodes $list $LCTL set_param fail_loc=0
 
-        TLOG=$DIR/$tfile.getstripe
-        $GETSTRIPE $DIR/$tdir > $TLOG
-        OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
-        unlinkmany $DIR/$tdir/t- 1000
-        [ $OBJS -gt 0 ] && \
-                error "$OBJS objects created on OST-0.  See $TLOG" || pass
+       TLOG=$DIR/$tfile.getstripe
+       $GETSTRIPE $DIR/$tdir > $TLOG
+       OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
+       unlinkmany $DIR/$tdir/t- 1000
+       [ $OBJS -gt 0 ] && \
+               error "$OBJS objects created on OST-0.  See $TLOG" || pass
 }
 run_test 27u "skip object creation on OSC w/o objects =========="
 
@@ -1712,29 +1719,38 @@ check_seq_oid()
                 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
-                #local dir=$(facet_mntpt ost$ost)
-                #stop ost$dev
-                #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
-                #       { error "mounting $dev as $FSTYPE failed"; return 3; }
-                #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
-                #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
-               seq=$(echo $seq | sed -e "s/^0x//g")
-               if [ $seq == 0 ]; then
-                       oid_hex=$(echo $oid)
-               else
-                       oid_hex=$(echo $hex | sed -e "s/^0x//g")
+               # 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
-                local obj_file="O/$seq/d$((oid %32))/$oid_hex"
-                local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
-                           $dev 2>/dev/null" | grep "parent=")
+
+               stop ost$ost
+               do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir ||
+                       { error "mounting $dev as $FSTYPE failed"; return 3; }
+               local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
+               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
+
+               # re-enable when debugfs will understand new filter_fid
+               #seq=$(echo $seq | sed -e "s/^0x//g")
+               #if [ $seq == 0 ]; then
+               #       oid_hex=$(echo $oid)
+               #else
+               #       oid_hex=$(echo $hex | sed -e "s/^0x//g")
+               #fi
+                #local obj_file="O/$seq/d$((oid %32))/$oid_hex"
+               #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
+                #           $dev 2>/dev/null" | grep "parent=")
 
                 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
 
                 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
 
-                #do_facet ost$ost umount -d $dir
-                #start ost$ost $dev $OST_MOUNT_OPTS
-
                 # /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=.//')
@@ -3762,7 +3778,8 @@ test_53() {
                ostnum=$(index_from_ostuuid ${ostname}_UUID)
                node=$(facet_active_host ost$((ostnum+1)))
                param="obdfilter.$ostname.last_id"
-               ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
+               ost_last=$(do_node $node lctl get_param -n $param | head -n 1 |
+                          awk -F':' '{print $2}')
                 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
                 if [ $ost_last != $mds_last ]; then
                     error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
@@ -4285,11 +4302,13 @@ test_56u() { # LU-611
        [ $NUMS -eq $EXPECTED ] ||
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
 
-       EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
-       CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
-       NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
-               error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       if [ $OSTCOUNT -gt 1 ]; then
+               EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
+               CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
+               NUMS=$($CMD | wc -l)
+               [ $NUMS -eq $EXPECTED ] ||
+                       error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       fi
 }
 run_test 56u "check lfs find -stripe-index works"
 
@@ -6192,7 +6211,7 @@ test_102k() {
         local default_size=`$GETSTRIPE -S $test_kdir`
         local default_count=`$GETSTRIPE -c $test_kdir`
         local default_offset=`$GETSTRIPE -i $test_kdir`
-        $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
+       $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
                 error 'dir setstripe failed'
         setfattr -n trusted.lov $test_kdir
         local stripe_size=`$GETSTRIPE -S $test_kdir`
@@ -8272,20 +8291,20 @@ get_rename_size() {
 
 test_133d() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-    remote_ost_nodsh && skip "remote OST with nodsh" && return
-    remote_mds_nodsh && skip "remote MDS with nodsh" && return
-    do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
-        { skip "MDS doesn't support rename stats"; return; }
+       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
+       { skip "MDS doesn't support rename stats"; return; }
 
-    local testdir1=$DIR/${tdir}/stats_testdir1
-    local testdir2=$DIR/${tdir}/stats_testdir2
+       local testdir1=$DIR/${tdir}/stats_testdir1
+       local testdir2=$DIR/${tdir}/stats_testdir2
 
-    do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
 
-    test_mkdir -p ${testdir1} || error "mkdir failed"
-    test_mkdir -p ${testdir2} || error "mkdir failed"
+       mkdir -p ${testdir1} || error "mkdir failed"
+       mkdir -p ${testdir2} || error "mkdir failed"
 
-    createmany -o $testdir1/test 512 || error "createmany failed"
+       createmany -o $testdir1/test 512 || error "createmany failed"
 
        # check samedir rename size
        mv ${testdir1}/test0 ${testdir1}/test_0
@@ -8304,18 +8323,18 @@ test_133d() {
        echo "source rename dir size: ${testdir1_size}"
        echo "target rename dir size: ${testdir2_size}"
 
-    local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
-    eval $cmd || error "$cmd failed"
-    local samedir=$($cmd | grep 'same_dir')
-    local same_sample=$(get_rename_size $testdir1_size)
-    [ -z "$samedir" ] && error "samedir_rename_size count error"
-    [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
-    echo "Check same dir rename stats success"
+       local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
+       eval $cmd || error "$cmd failed"
+       local samedir=$($cmd | grep 'same_dir')
+       local same_sample=$(get_rename_size $testdir1_size)
+       [ -z "$samedir" ] && error "samedir_rename_size count error"
+       [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
+       echo "Check same dir rename stats success"
 
-    do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
 
-    # check crossdir rename size
-    mv ${testdir1}/test_0 ${testdir2}/test_0
+       # check crossdir rename size
+       mv ${testdir1}/test_0 ${testdir2}/test_0
 
        testdir1_size=$(ls -l $DIR/${tdir} |
                awk '/stats_testdir1/ {print $5}')
@@ -8331,15 +8350,15 @@ test_133d() {
        echo "source rename dir size: ${testdir1_size}"
        echo "target rename dir size: ${testdir2_size}"
 
-    eval $cmd || error "$cmd failed"
-    local crossdir=$($cmd | grep 'crossdir')
-    local src_sample=$(get_rename_size $testdir1_size crossdir_src)
-    local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
-    [ -z "$crossdir" ] && error "crossdir_rename_size count error"
-    [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
-    [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
-    echo "Check cross dir rename stats success"
-    rm -rf $DIR/${tdir}
+       eval $cmd || error "$cmd failed"
+       local crossdir=$($cmd | grep 'crossdir')
+       local src_sample=$(get_rename_size $testdir1_size crossdir_src)
+       local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
+       [ -z "$crossdir" ] && error "crossdir_rename_size count error"
+       [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
+       [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
+       echo "Check cross dir rename stats success"
+       rm -rf $DIR/${tdir}
 }
 run_test 133d "Verifying rename_stats ========================================"
 
@@ -8669,16 +8688,13 @@ dot_lustre_fid_permission_check() {
                error "touch $MOUNT/.lustre/fid/$tfile should fail."
 
        echo "setxattr to $MOUNT/.lustre/fid"
-       setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid &&
-               error "setxattr should fail."
+       setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
 
        echo "listxattr for $MOUNT/.lustre/fid"
-       getfattr -d -m "^trusted" $MOUNT/.lustre/fid &&
-               error "listxattr should fail."
+       getfattr -d -m "^trusted" $MOUNT/.lustre/fid
 
        echo "delxattr from $MOUNT/.lustre/fid"
-       setfattr -x trusted.name1 $MOUNT/.lustre/fid &&
-               error "delxattr should fail."
+       setfattr -x trusted.name1 $MOUNT/.lustre/fid
 
        echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
        touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
@@ -8697,6 +8713,21 @@ dot_lustre_fid_permission_check() {
        mrename $MOUNT/.lustre $MOUNT/.lustre/fid/$fid/.lustre &&
                error "rename .lustre to itself should fail."
 
+       local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
+       local new_obf_mode=777
+
+       echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
+       chmod $new_obf_mode $DIR/.lustre/fid ||
+               error "chmod $new_obf_mode $DIR/.lustre/fid failed"
+
+       local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
+       [ $obf_mode -eq $new_obf_mode ] ||
+               error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
+
+       echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
+       chmod $old_obf_mode $DIR/.lustre/fid ||
+               error "chmod $old_obf_mode $DIR/.lustre/fid failed"
+
        $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
        fid=$($LFS path2fid $test_dir/$tfile-2)
        echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
@@ -8728,7 +8759,6 @@ test_154a() {
                error "dot lustre permission check $fid failed"
 
        rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
-       chmod 777 $MOUNT/.lustre && error ".lustre is not allowed to be chmod"
 
        touch $MOUNT/.lustre/file &&
                error "creation is not allowed under .lustre"
@@ -10646,9 +10676,13 @@ run_test 224b "Don't panic on bulk IO failure"
 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
 test_225a () {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       if [ -z ${MDSSURVEY} ]; then
-              skip_env "mds-survey not found" && return
-       fi
+       if [ -z ${MDSSURVEY} ]; then
+             skip_env "mds-survey not found" && return
+       fi
+
+       [ $MDSCOUNT -ge 2 ] &&
+               skip "skipping now for more than one MDT" && return
+
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
             { skip "Need MDS version at least 2.2.51"; return; }
 
@@ -10671,16 +10705,19 @@ run_test 225a "Metadata survey sanity with zero-stripe"
 
 test_225b () {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       if [ -z ${MDSSURVEY} ]; then
-              skip_env "mds-survey not found" && return
-       fi
-       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
-            { skip "Need MDS version at least 2.2.51"; return; }
 
-       if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
-              skip_env "Need to mount OST to test" && return
-       fi
+       if [ -z ${MDSSURVEY} ]; then
+             skip_env "mds-survey not found" && return
+       fi
+       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
+           { skip "Need MDS version at least 2.2.51"; return; }
+
+       if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
+             skip_env "Need to mount OST to test" && return
+       fi
 
+       [ $MDSCOUNT -ge 2 ] &&
+               skip "skipping now for more than one MDT" && return
        local mds=$(facet_host $SINGLEMDS)
        local target=$(do_nodes $mds 'lctl dl' | \
                       awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")