Whamcloud - gitweb
b=17846
[fs/lustre-release.git] / lustre / tests / sanity.sh
index d661aca..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!
@@ -46,7 +46,6 @@ MCREATE=${MCREATE:-mcreate}
 OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
 READS=${READS:-"reads"}
-TOEXCL=${TOEXCL:-toexcl}
 TRUNCATE=${TRUNCATE:-truncate}
 MUNLINK=${MUNLINK:-munlink}
 SOCKETSERVER=${SOCKETSERVER:-socketserver}
@@ -112,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
@@ -541,9 +542,12 @@ test_22() {
 run_test 22 "unpack tar archive as non-root user ==============="
 
 test_23() {
-       mkdir $DIR/d23
-       $TOEXCL $DIR/d23/f23
-       $TOEXCL -e $DIR/d23/f23 || error
+       mkdir -p $DIR/$tdir
+       local file=$DIR/$tdir/$tfile
+
+       openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
+       openfile -f O_CREAT:O_EXCL $file &&
+               error "$file recreate succeeded" || true
 }
 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
 
@@ -815,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
@@ -930,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() {
@@ -941,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/^.*-//')
 
@@ -959,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() {
@@ -977,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
@@ -1059,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)"
 
@@ -1106,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"
 
@@ -1140,7 +1158,9 @@ test_27w() { # bug 10997
 }
 run_test 27w "check lfs setstripe -c -s -i options ============="
 
-test_28() {
+# createtest also checks that device nodes are created and 
+# then visible correctly (#2091)
+test_28() { # bug 2091
        mkdir $DIR/d28
        $CREATETEST $DIR/d28/ct || error
 }
@@ -1739,9 +1759,15 @@ test_37() {
 run_test 37 "ls a mounted file system to check old content ====="
 
 test_38() {
-       o_directory $DIR/$tfile
+       local file=$DIR/$tfile
+       touch $file
+       openfile -f O_DIRECTORY $file
+       local RC=$?
+       local ENOTDIR=20
+       [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
+       [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
 }
-run_test 38 "open a regular file with O_DIRECTORY =============="
+run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
 
 test_39() {
        touch $DIR/$tfile
@@ -2068,11 +2094,7 @@ test_46() {
 }
 run_test 46 "dirtying a previously written page ================"
 
-# Check that device nodes are created and then visible correctly (#2091)
-test_47() {
-       cmknod $DIR/test_47_node || error
-}
-run_test 47 "Device nodes check ================================"
+# test_47 is removed "Device nodes check" is moved to test_28 
 
 test_48a() { # bug 2399
        check_kernel_version 34 || return 0
@@ -4037,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`
@@ -4053,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() {
@@ -5954,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
@@ -5991,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"
 
@@ -6029,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"
@@ -6090,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
 }
@@ -6112,27 +6151,37 @@ test_170() {
         $LCTL debug_daemon start $TMP/${tfile}_log_good
         touch $DIR/$tfile
         $LCTL debug_daemon stop
-        cat $TMP/${tfile}_log_good | sed -e "s/^...../a/g" > $TMP/${tfile}_log_bad
+        sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
+               error "sed failed to read log_good"
 
         $LCTL debug_daemon start $TMP/${tfile}_log_good
         rm -rf $DIR/$tfile
         $LCTL debug_daemon stop
 
-        $LCTL df $TMP/${tfile}_log_bad 2&> $TMP/${tfile}_log_bad.out
-        bad_line=`tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}'`
-        good_line1=`tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}'`
+        $LCTL df $TMP/${tfile}_log_bad 2&> $TMP/${tfile}_log_bad.out ||
+               error "lctl df log_bad failed"
+
+        local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
+        local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
 
         $LCTL df $TMP/${tfile}_log_good 2&>$TMP/${tfile}_log_good.out 
-        good_line2=`tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}'`
+        local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
 
+       [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] || 
+               error "bad_line good_line1 good_line2 are empty"
         cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
         cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt 
         cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt           
 
         $LCTL df $TMP/${tfile}_logs_corrupt 2&> $TMP/${tfile}_log_bad.out
-        bad_line_new=`tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}'`
-        good_line_new=`tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}'`
-        expected_good=$((good_line1 + good_line2*2))
+        local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
+        local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
+
+       [ "$bad_line_new" ] && [ "$good_line_new" ] || 
+               error "bad_line_new good_line_new are empty"
+        local expected_good=$((good_line1 + good_line2*2))
 
         rm -rf $TMP/${tfile}*
         if [ $bad_line -ne $bad_line_new ]; then
@@ -6146,7 +6195,7 @@ test_170() {
         fi
         true
 }
-run_test 170 "test lctl df to handle corruputed log ====================="
+run_test 170 "test lctl df to handle corrupted log ====================="
 
 # OST pools tests
 POOL=${POOL:-cea1}
@@ -6260,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 =========================="