Whamcloud - gitweb
LU-3196 tests: a few fixes for > 10 OSTs.
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 2282370..c70826e 100644 (file)
@@ -677,6 +677,30 @@ test_17n() {
 }
 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
 
+test_17o() {
+       local WDIR=$DIR/${tdir}o
+       local mdt_index
+       local mdtdevname
+       local rc=0
+
+       mkdir -p $WDIR
+       mdt_index=$($LFS getstripe -M $WDIR)
+       mdt_index=$((mdt_index+1))
+       mdtdevname=$(mdsdevname $mdt_index)
+
+       touch $WDIR/$tfile
+       stop mds${mdt_index}
+       start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
+
+       #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
+       do_facet mds${mdt_index} lctl set_param fail_loc=0x194
+       ls -l $WDIR/$tfile && rc=1
+       do_facet mds${mdt_index} lctl set_param fail_loc=0
+       [[ $rc -ne 0 ]] && error "stat file should fail"
+       true
+}
+run_test 17o "stat file with incompat LMA feature"
+
 test_18() {
        touch $DIR/f || error "Failed to touch $DIR/f: $?"
        ls $DIR || error "Failed to ls $DIR: $?"
@@ -1246,7 +1270,7 @@ run_test 27e "setstripe existing file (should return error) ======"
 test_27f() {
        test_mkdir -p $DIR/d27
        $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
-       dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
+       dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
        $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
 }
 run_test 27f "setstripe with bad stripe size (should return error)"
@@ -1708,8 +1732,9 @@ check_seq_oid()
                 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
                 $have_obdidx || continue
 
-                local ost=$((obdidx + 1))
-                local dev=$(ostdevname $ost)
+               local ost=$((obdidx + 1))
+               local dev=$(ostdevname $ost)
+               local oid_hex
 
                if [ $(facet_fstype ost$ost) != ldiskfs ]; then
                        echo "Currently only works with ldiskfs-based OSTs"
@@ -1731,19 +1756,19 @@ check_seq_oid()
                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)
+
+               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=$(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
 
                # 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=")
 
@@ -1842,6 +1867,7 @@ test_27C() { #LU-2871
 
        declare -a ost_idx
        local index
+       local found
        local i
        local j
 
@@ -1854,10 +1880,21 @@ test_27C() { #LU-2871
                ost_idx=($($GETSTRIPE $tfile$i |
                         tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
                echo ${ost_idx[@]}
+
                # check the layout
-               for j in $(seq 0 $((OSTCOUNT - 1))); do
-                       index=$(((i + j) % OSTCOUNT))
-                       [ ${ost_idx[$j]} -eq $index ] || error
+               [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
+                       error "${#ost_idx[@]} != $OSTCOUNT"
+
+               for index in $(seq 0 $((OSTCOUNT - 1))); do
+                       found=0
+                       for j in $(echo ${ost_idx[@]}); do
+                               if [ $index -eq $j ]; then
+                                       found=1
+                                       break
+                               fi
+                       done
+                       [ $found = 1 ] ||
+                               error "Can not find $index in ${ost_idx[@]}"
                done
        done
 }
@@ -2395,7 +2432,7 @@ test_33c() {
         for ostnum in $(seq $OSTCOUNT); do
                 # test-framework's OST numbering is one-based, while Lustre's
                 # is zero-based
-                ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
+                ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
                 # Parsing llobdstat's output sucks; we could grep the /proc
                 # path, but that's likely to not be as portable as using the
                 # llobdstat utility.  So we parse lctl output instead.
@@ -2419,7 +2456,7 @@ test_33c() {
 
         # Total up write_bytes after writing.  We'd better find non-zeros.
         for ostnum in $(seq $OSTCOUNT); do
-                ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
+                ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
                 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
                         obdfilter/$ostname/stats |
                         awk '/^write_bytes/ {print $7}' )
@@ -2434,7 +2471,7 @@ test_33c() {
         if $all_zeros
         then
                 for ostnum in $(seq $OSTCOUNT); do
-                        ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
+                        ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
                         echo "Check that write_bytes is present in obdfilter/*/stats:"
                         do_facet ost$ostnum lctl get_param -n \
                                 obdfilter/$ostname/stats
@@ -3763,28 +3800,47 @@ test_53() {
        remote_ost_nodsh && skip "remote OST with nodsh" && return
 
        local param
+       local param_seq
        local ostname
        local mds_last
+       local mds_last_seq
        local ost_last
+       local ost_last_seq
+       local ost_last_id
        local ostnum
        local node
+       local found=0
 
        # only test MDT0000
         local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
         for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
-                param=`echo ${value[0]} | cut -d "=" -f1`
-                ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
-                mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
+                param=$(echo ${value[0]} | cut -d "=" -f1)
+                ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
+                param_seq=$(echo ${param} |
+                           sed -e s/prealloc_last_id/prealloc_last_seq/g)
+               mds_last_seq=$(do_facet $SINGLEMDS lctl get_param -n $param_seq)
+               mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
+
                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 |
-                          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"
-                fi
+               for ost_last in $(do_node $node lctl get_param -n $param) ; do
+                       echo "$ostname.last_id=$ost_last ;MDS.last_id=$mds_last"
+                       ost_last_id=$(echo $ost_last | awk -F':' '{print $2}' |
+                                     sed -e "s/^0x//g")
+                       ost_last_seq=$(echo $ost_last | awk -F':' '{print $1}')
+                       if [ $ost_last_seq = $mds_last_seq ]; then
+                               if [ $ost_last_id != $mds_last ]; then
+                                       error "$ost_last != $mds_last_id"
+                               else
+                                       found=1
+                                       break
+                               fi
+                       fi
+               done
         done
+       [ $found = 0 ] && error "can not match last_seq/last_id for $mdtosc"
+       return 0
 }
 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
 
@@ -7081,9 +7137,13 @@ test_120a() {
         test_mkdir -p $DIR/$tdir
         [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
                skip "no early lock cancel on server" && return 0
-        lru_resize_disable mdc
-        lru_resize_disable osc
-        cancel_lru_locks mdc
+
+       lru_resize_disable mdc
+       lru_resize_disable osc
+       cancel_lru_locks mdc
+       # asynchronous object destroy at MDT could cause bl ast to client
+       cancel_lru_locks osc
+
         stat $DIR/$tdir > /dev/null
         can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
         blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
@@ -7774,6 +7834,9 @@ test_130b() {
        [ "$OSTCOUNT" -lt "2" ] &&
                skip_env "skipping FIEMAP on 2-stripe file test" && return
 
+       [ "$OSTCOUNT" -ge "10" ] &&
+               skip_env "skipping FIEMAP with >= 10 OSTs" && return
+
        local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
        [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
                return
@@ -7830,6 +7893,9 @@ test_130c() {
        [ "$OSTCOUNT" -lt "2" ] &&
                skip_env "skipping FIEMAP on 2-stripe file" && return
 
+       [ "$OSTCOUNT" -ge "10" ] &&
+               skip_env "skipping FIEMAP with >= 10 OSTs" && return
+
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
        [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
                return
@@ -7889,6 +7955,9 @@ run_test 130c "FIEMAP (2-stripe file with hole)"
 test_130d() {
        [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
 
+       [ "$OSTCOUNT" -ge "10" ] &&
+               skip_env "skipping FIEMAP with >= 10 OSTs" && return
+
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
        [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
 
@@ -7940,6 +8009,9 @@ run_test 130d "FIEMAP (N-stripe file)"
 test_130e() {
        [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
 
+       [ "$OSTCOUNT" -ge "10" ] &&
+               skip_env "skipping FIEMAP with >= 10 OSTs" && return
+
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
        [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
 
@@ -9694,6 +9766,37 @@ test_184c() {
 }
 run_test 184c "Concurrent write and layout swap"
 
+test_184d() {
+       check_swap_layouts_support && return 0
+
+       local file1=$DIR/$tdir/$tfile-1
+       local file2=$DIR/$tdir/$tfile-2
+       local file3=$DIR/$tdir/$tfile-3
+       local lovea1
+       local lovea2
+
+       mkdir -p $DIR/$tdir
+       touch $file1 || error "create $file1 failed"
+       $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
+               error "create $file2 failed"
+       $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
+               error "create $file3 failed"
+       lovea1=$($LFS getstripe $file1 | sed 1d)
+
+       $LFS swap_layouts $file2 $file3 ||
+               error "swap $file2 $file3 layouts failed"
+       $LFS swap_layouts $file1 $file2 ||
+               error "swap $file1 $file2 layouts failed"
+
+       lovea2=$($LFS getstripe $file2 | sed 1d)
+       [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
+
+       lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
+       [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
+}
+run_test 184d "allow stripeless layouts swap"
+
+
 test_185() { # LU-2441
        mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
        touch $DIR/$tdir/spoo
@@ -10450,16 +10553,20 @@ run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079,
 
 test_216() { # bug 20317
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        remote_ost_nodsh && skip "remote OST with nodsh" && return
-        local node
-        local p="$TMP/sanityN-$TESTNAME.parameters"
-        save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
-        for node in $(osts_nodes); do
-                save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
-                save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
-                save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
-        done
-        clear_osc_stats
+       remote_ost_nodsh && skip "remote OST with nodsh" && return
+
+       local node
+       local facets=$(get_facets OST)
+       local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+       save_lustre_params client "osc.*.contention_seconds" > $p
+       save_lustre_params $facets \
+               "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
+       save_lustre_params $facets \
+               "ldlm.namespaces.filter-*.contended_locks" >> $p
+       save_lustre_params $facets \
+               "ldlm.namespaces.filter-*.contention_seconds" >> $p
+       clear_osc_stats
 
         # agressive lockless i/o settings
         for node in $(osts_nodes); do