Whamcloud - gitweb
b=17846
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 6aadd4f..3220383 100644 (file)
@@ -7,8 +7,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 12653 12653 5188 10764 16260
-ALWAYS_EXCEPT="                27u   42a  42b  42c  42d  45   51d   65a   65e   68b   75    119d  $SANITY_EXCEPT"
+# bug number for skipped test: 16823 13297 2108 9789 3637 9789 3561 12622 12653 12653 5188 10764 16260
+ALWAYS_EXCEPT="                27s   27u   42a  42b  42c  42d  45   51d   65a   65e   68b   75    119d  $SANITY_EXCEPT"
 # bug number for skipped test: 2108 9789 3637 9789 3561 5188/5749 1443
 #ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
@@ -111,11 +111,13 @@ check_and_setup_lustre
 DIR=${DIR:-$MOUNT}
 assert_DIR
 
-LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
-OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
-STRIPECOUNT=`lctl get_param -n lov.$LOVNAME.stripecount`
-STRIPESIZE=`lctl get_param -n lov.$LOVNAME.stripesize`
-ORIGFREE=`lctl get_param -n lov.$LOVNAME.kbytesavail`
+MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
+    awk '{gsub(/_UUID/,""); print $1}' | head -1)
+LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
+OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
+STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
+STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
+ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
 
 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
@@ -817,6 +819,7 @@ run_test 26f "rm -r of a directory which has recursive symlink ="
 test_27a() {
        echo '== stripe sanity =============================================='
        mkdir -p $DIR/d27 || error "mkdir failed"
+       $GETSTRIPE $DIR/d27
        $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
        $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
        pass
@@ -932,10 +935,15 @@ run_test 27m "create file while OST0 was full =================="
 
 # osc's keep a NOSPC stick flag that gets unset with rmdir
 reset_enospc() {
-       [ "$1" ] && FAIL_LOC=$1 || FAIL_LOC=0
+       local FAIL_LOC=${1:-0}
+       local OSTIDX=${2:-""}
+
        mkdir -p $DIR/d27/nospc
        rmdir $DIR/d27/nospc
-       do_nodes $(comma_list $(osts_nodes)) lctl set_param fail_loc=$FAIL_LOC
+       local list=$(comma_list $(osts_nodes))
+       [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
+
+       do_nodes $list lctl set_param fail_loc=$FAIL_LOC
 }
 
 exhaust_precreations() {
@@ -943,7 +951,8 @@ exhaust_precreations() {
        local MDSIDX=$(get_mds_dir "$DIR/d27")
        echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
 
-       local OST=$(lfs osts | grep ${OSTIDX}": " | awk '{print $2}' | sed -e 's/_UUID$//')
+       local OST=$(lfs osts | grep ${OSTIDX}": " | \
+               awk '{print $2}' | sed -e 's/_UUID$//')
        local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
                          sed -e 's/_UUID$//;s/^.*-//')
 
@@ -961,7 +970,7 @@ exhaust_precreations() {
        echo "Creating to objid $last_id on ost $OST..."
        createmany -o $DIR/d27/${OST}-f $next_id $((last_id - next_id + 2))
        do_facet mds${MDSIDX} lctl get_param osc.*${OST}-osc-${MDT_INDEX}.prealloc* | grep '[0-9]'
-       reset_enospc $2
+       reset_enospc $2 $OSTIDX
 }
 
 exhaust_all_precreations() {
@@ -979,6 +988,7 @@ test_27n() {
 
        reset_enospc
        rm -f $DIR/d27/f27n
+       $SETSTRIPE $DIR/d27 -c 1 -i -1
        exhaust_precreations 0 0x80000215
 
        touch $DIR/d27/f27n || error
@@ -1061,9 +1071,13 @@ test_27r() {
 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
 
 test_27s() { # bug 10725
-       mkdir -p $DIR/$tdir
-       $LSTRIPE $DIR/$tdir $((2048 * 1024 * 1024)) -1 2 && \
-               error "stripe width >= 2^32 succeeded" || true
+       mkdir -p $DIR/$tdir
+       local stripe_size=$((4096 * 1024 * 1024))       # 2^32
+       local stripe_count=0
+       [ $OSTCOUNT -eq 1 ] || stripe_count=2 
+       $SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
+               error "stripe width >= 2^32 succeeded" || true
+
 }
 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
 
@@ -1108,15 +1122,17 @@ test_27v() { # bug 4900
 
         touch $DIR/$tdir/$tfile
         #define OBD_FAIL_TGT_DELAY_PRECREATE     0x705
-        lctl set_param fail_loc=0x705
-        START=`date +%s`
-        for F in `seq 1 32`; do
-                touch $DIR/$tdir/$tfile.$F
+        # all except ost1
+        for (( i=0; i < OSTCOUNT; i++ )) ; do
+                do_facet ost$i lctl set_param fail_loc=0x705
         done
-        lctl set_param fail_loc=0
+        local START=`date +%s`
+        createmany -o $DIR/$tdir/$tfile 32
 
-        FINISH=`date +%s`
-        TIMEOUT=`lctl get_param -n timeout`
+        reset_enospc
+
+        local FINISH=`date +%s`
+        local TIMEOUT=`lctl get_param -n timeout`
         [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
                error "$FINISH - $START >= $TIMEOUT / 2"
 
@@ -4043,6 +4059,8 @@ test_102c() {
 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
 
 compare_stripe_info1() {
+       local stripe_index_all_zero=1
+
        for num in 1 2 3 4
        do
                for count in `seq 1 $STRIPE_COUNT`
@@ -4059,11 +4077,13 @@ compare_stripe_info1() {
                                        error "$file: different stripe count $stripe_count, expected $count" && return
                                fi
                                if [ $stripe_index -ne 0 ]; then
-                                       error "$file: different stripe offset $stripe_index, expected 0" && return
+                                      stripe_index_all_zero=0
                                fi
                        done
                done
        done
+       [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
+       return 0
 }
 
 compare_stripe_info2() {
@@ -5960,32 +5980,34 @@ test_153() {
 }
 run_test 153 "test if fdatasync does not crash ======================="
 
-err17935 () {
-    if [ $MDSCOUNT -gt 1 ]; then
-       error_ignore 17935 $*
-    else
-       error $*
-    fi
-}
-
 test_154() {
        cp /etc/hosts $DIR/$tfile
 
-       fid=`$LFS path2fid $DIR/$tfile`
+       fid=$($LFS path2fid $DIR/$tfile)
        rc=$?
        [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
 
-       diff $DIR/$tfile $DIR/.lustre/fid/$fid || error "open by fid failed: did not find expected data in file."
+       echo "open fid $fid"
+       diff /etc/hosts $DIR/.lustre/fid/$fid || error "open by fid failed: did not find expected data in file."
 
        echo "Opening a file by FID succeeded"
 }
 run_test 154 "Opening a file by FID"
 
 #Changelogs
+err17935 () {
+    if [ $MDSCOUNT -gt 1 ]; then
+       error_ignore 17935 $*
+    else
+       error $*
+    fi
+}
 test_160() {
-    remote_mds && skip "remote MDS" && return
-    lctl set_param -n mdd.*.changelog on
-    $LFS changelog_clear $FSNAME 0
+    do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog on
+    USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
+    echo "Registered as changelog user $USER"
+    do_facet $SINGLEMDS lctl get_param -n mdd.$MDT0.changelog_users | \
+       grep -q $USER || error "User $USER not found in changelog_users"
 
     # change something
     mkdir -p $DIR/$tdir/pics/2008/zachy
@@ -5997,29 +6019,40 @@ test_160() {
     rm $DIR/$tdir/pics/desktop.jpg
 
     # verify contents
-    $LFS changelog $FSNAME
-    # check target fid
-    fidc=$($LFS changelog $FSNAME | grep timestamp | grep "CREAT" | tail -1 | \
-       awk '{print $5}')
+    $LFS changelog $MDT0 | tail -5
+    echo "verifying target fid"
+    fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
+       tail -1 | awk '{print $5}')
     fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
     [ "$fidc" == "t=$fidf" ] || \
        err17935 "fid in changelog $fidc != file fid $fidf"
-    # check parent fid
-    fidc=$($LFS changelog $FSNAME | grep timestamp | grep "CREAT" | tail -1 | \
-       awk '{print $6}')
+    echo "verifying parent fid"
+    fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
+       tail -1 | awk '{print $6}')
     fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
     [ "$fidc" == "p=$fidf" ] || \
        err17935 "pfid in changelog $fidc != dir fid $fidf" 
 
-    # verify purge
-    FIRST_REC=$($LFS changelog $FSNAME | head -1 | awk '{print $1}')
-    $LFS changelog_clear $FSNAME $(($FIRST_REC + 5)) 
-    PURGE_REC=$($LFS changelog $FSNAME | head -1 | awk '{print $1}')
-    [ $PURGE_REC == $(($FIRST_REC + 6)) ] || \
-     err17935 "first rec after purge should be $(($FIRST_REC + 6)); is $PURGE_REC"
-    # purge all
-    $LFS changelog_clear $FSNAME 0
-    lctl set_param -n mdd.*.changelog off
+    echo "verifying user clear"
+    USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
+       mdd.$MDT0.changelog_users | wc -l) - 2 ))
+    FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
+    $LFS changelog_clear $MDT0 $USER $(($FIRST_REC + 5))  
+    USER_REC=$(do_facet $SINGLEMDS lctl get_param -n \
+       mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
+    [ $USER_REC == $(($FIRST_REC + 5)) ] || \
+       err17935 "user index should be $(($FIRST_REC + 5)); is $USER_REC"
+    CLEAR_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
+    [ $CLEAR_REC == $(($FIRST_REC + 6)) -o $USERS -gt 1 ] || \
+       err17935 "first index should be $(($FIRST_REC + 6)); is $PURGE_REC"
+
+    echo "verifying user deregister"
+    do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
+    do_facet $SINGLEMDS lctl get_param -n mdd.$MDT0.changelog_users | \
+       grep -q $USER && error "User $USER still found in changelog_users"
+
+    [ $USERS -eq 1 ] && \
+       do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog off || true
 }
 run_test 160 "changelog sanity"
 
@@ -6035,7 +6068,7 @@ test_161() {
     ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
     ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
     ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
-    local FID=$($LFS path2fid $DIR/$tdir/$tfile)
+    local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
     if [ "$($LFS fid2path ${mds1_svc} $FID | wc -l)" != "5" ]; then
        $LFS fid2path ${mds1_svc} $FID
        err17935 "bad link ea"
@@ -6096,19 +6129,19 @@ test_162() {
     touch $DIR/$tdir/d2/x2
     mkdir -p $DIR/$tdir/d2/a/b/c
     mkdir -p $DIR/$tdir/d2/p/q/r
-    fid=$($LFS path2fid $DIR/$tdir/d2/$tfile)
-    check_path "/$tdir/d2/$tfile" ${mds1_svc} $fid --link 0
+    FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[')
+    check_path "/$tdir/d2/$tfile" ${mds1_svc} $FID --link 0
     ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
     mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
-    fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file)
-    check_path "/$tdir/d2/a/b/c/new_file" ${mds1_svc} $fid --link 1
-    check_path "/$tdir/d2/p/q/r/hlink" ${mds1_svc} $fid --link 0
-    # check that there are 2 links, and that --rec doesnt break anything
-    ${LFS} fid2path ${mds1_svc} $fid --rec 20 | wc -l | grep -q 2 || \
+    FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[')
+    check_path "/$tdir/d2/a/b/c/new_file" ${mds1_svc} $FID --link 1
+    check_path "/$tdir/d2/p/q/r/hlink" ${mds1_svc} $FID --link 0
+    # check that there are 2 links
+    ${LFS} fid2path ${mds1_svc} $FID | wc -l | grep -q 2 || \
        err17935 "expected 2 links" 
 
     rm $DIR/$tdir/d2/p/q/r/hlink
-    check_path "/$tdir/d2/a/b/c/new_file" ${mds1_svc} $fid --link 0
+    check_path "/$tdir/d2/a/b/c/new_file" ${mds1_svc} $FID --link 0
     # Doesnt work with CMD yet: 17935 
     return 0
 }
@@ -6276,6 +6309,8 @@ test_200h() {
        done
        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" ""\
            || error "Pool $FSNAME.$POOL cannot be drained"
+       # striping on an empty pool should fall back to "pool of everything"
+       $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile || error "failed to create file with empty pool"
 }
 run_test 200h "Remove all targets from a pool =========================="