Whamcloud - gitweb
LU-3373 tests: small fixes for sanity tests
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 9280dbd..b012490 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"
@@ -998,6 +998,9 @@ test_24v() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        trap simple_cleanup_common EXIT
 
+       # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
+       [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
+
        mkdir -p $DIR/$tdir
        createmany -m $DIR/$tdir/$tfile $NRFILES
 
@@ -1123,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`
@@ -1280,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 ============="
 
@@ -3127,6 +3131,26 @@ test_39n() { # LU-3832
 }
 run_test 39n "check that O_NOATIME is honored"
 
+test_39o() {
+       TESTDIR=$DIR/$tdir/$tfile
+       [ -e $TESTDIR ] && rm -rf $TESTDIR
+       mkdir -p $TESTDIR
+       cd $TESTDIR
+       links1=2
+       ls
+       mkdir a b
+       ls
+       links2=$(stat -c %h .)
+       [ $(($links1 + 2)) != $links2 ] &&
+               error "wrong links count $(($links1 + 2)) != $links2"
+       rmdir b
+       links3=$(stat -c %h .)
+       [ $(($links1 + 1)) != $links3 ] &&
+               error "wrong links count $links1 != $links3"
+       return 0
+}
+run_test 39o "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 &&
@@ -6614,53 +6638,79 @@ test_116a() { # was previously test_116()
        [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
 
        echo -n "Free space priority "
-       lctl get_param -n lov.*-clilov-*.qos_prio_free
+       do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
+               head -1
        declare -a AVAIL
        free_min_max
-       [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
-               return
 
-       # generate uneven OSTs
+       [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
+       trap simple_cleanup_common EXIT
+
+       # Check if we need to generate uneven OSTs
        test_mkdir -p $DIR/$tdir/OST${MINI}
-       declare -i FILL
-       FILL=$(($MINV / 4))
-       echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
-       $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
-       i=0
-       while [ $FILL -gt 0 ]; do
-           i=$(($i + 1))
-           dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
-           FILL=$(($FILL - 2048))
-           echo -n .
-       done
-       FILL=$(($MINV / 4))
-       sync
-       sleep_maxage
+       local FILL=$(($MINV / 4))
+       local DIFF=$(($MAXV - $MINV))
+       local DIFF2=$(($DIFF * 100 / $MINV))
+
+       local threshold=$(do_facet $SINGLEMDS \
+               lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -1)
+       threshold=${threshold%%%}
+       echo -n "Check for uneven OSTs: "
+       echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
+
+       if [ $DIFF2 -gt $threshold ]; then
+               echo "ok"
+               echo "Don't need to fill OST$MINI"
+       else
+               # generate uneven OSTs. Write 2% over the QOS threshold value
+               echo "no"
+               DIFF=$(($threshold - $DIFF2 + 2))
+               DIFF2=$(( ($MINV * $DIFF)/100 ))
+               echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
+               $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
+                       error "setstripe failed"
+               DIFF=$(($DIFF2 / 2048))
+               i=0
+               while [ $i -lt $DIFF ]; do
+                       i=$(($i + 1))
+                       dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
+                               bs=2M count=1 2>/dev/null
+                       echo -n .
+               done
+               echo .
+               sync
+               sleep_maxage
+               free_min_max
+       fi
 
-       free_min_max
        DIFF=$(($MAXV - $MINV))
        DIFF2=$(($DIFF * 100 / $MINV))
-       echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
-       if [ $DIFF2 -gt 20 ]; then
-           echo "ok"
+       echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
+       if [ $DIFF2 -gt $threshold ]; then
+               echo "ok"
        else
-           echo "failed - QOS mode won't be used"
-           error_ignore "QOS imbalance criteria not met"
-           return
+               echo "failed - QOS mode won't be used"
+               skip "QOS imbalance criteria not met"
+               simple_cleanup_common
+               return
        fi
 
        MINI1=$MINI; MINV1=$MINV
        MAXI1=$MAXI; MAXV1=$MAXV
 
        # now fill using QOS
-       echo writing a bunch of files to QOS-assigned OSTs
        $SETSTRIPE -c 1 $DIR/$tdir
+       FILL=$(($FILL / 200))
+       if [ $FILL -gt 600 ]; then
+               FILL=600
+       fi
+       echo "writing $FILL files to QOS-assigned OSTs"
        i=0
-       while [ $FILL -gt 0 ]; do
-           i=$(($i + 1))
-           dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
-           FILL=$(($FILL - 200))
-           echo -n .
+       while [ $i -lt $FILL ]; do
+               i=$(($i + 1))
+               dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
+                       count=1 2>/dev/null
+               echo -n .
        done
        echo "wrote $i 200k files"
        sync
@@ -6672,26 +6722,30 @@ test_116a() { # was previously test_116()
        echo "free space delta: orig $DIFF final $DIFF2"
        [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
        DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
-       echo "Wrote $DIFF to smaller OST $MINI1"
+       echo "Wrote ${DIFF}KB to smaller OST $MINI1"
        DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
-       echo "Wrote $DIFF2 to larger OST $MAXI1"
-       [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
+       echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
+       FILL=$(($DIFF2 * 100 / $DIFF - 100))
+       [ $DIFF -gt 0 ] &&
+               echo "Wrote ${FILL}% more data to larger OST $MAXI1"
 
        # Figure out which files were written where
        UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
-               awk '/'$MINI1': / {print $2; exit}')
+                 awk '/'$MINI1': / {print $2; exit}')
        echo $UUID
-        MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
+       MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
        echo "$MINC files created on smaller OST $MINI1"
        UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
-               awk '/'$MAXI1': / {print $2; exit}')
+                 awk '/'$MAXI1': / {print $2; exit}')
        echo $UUID
-        MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
+       MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
        echo "$MAXC files created on larger OST $MAXI1"
-       [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
-       [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
-
-       rm -rf $DIR/$tdir
+       FILL=$(($MAXC * 100 / $MINC - 100))
+       [ $MINC -gt 0 ] &&
+               echo "Wrote ${FILL}% more files to larger OST $MAXI1"
+       [ $MAXC -gt $MINC ] ||
+               error_ignore LU-9 "stripe QOS didn't balance free space"
+       simple_cleanup_common
 }
 run_test 116a "stripe QOS: free space balance ==================="
 
@@ -6721,7 +6775,7 @@ test_117() # bug 10891
         echo "Truncate succeeded."
        rm -f $DIR/$tfile
 }
-run_test 117 "verify fsfilt_extend =========="
+run_test 117 "verify osd extend =========="
 
 NO_SLOW_RESENDCOUNT=4
 export OLD_RESENDCOUNT=""
@@ -9249,12 +9303,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
@@ -9268,11 +9321,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`
@@ -9292,7 +9345,7 @@ run_test 156 "Verification of tunables ============================"
 #Changelogs
 err17935 () {
        if [ $MDSCOUNT -gt 1 ]; then
-               error_ignore 17935 $*
+               error_ignore bz17935 $*
        else
                error $*
        fi
@@ -9322,7 +9375,7 @@ changelog_extract_field() {
                tail -1
 }
 
-test_160() {
+test_160a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
@@ -9418,7 +9471,38 @@ test_160() {
                echo "$USERS other changelog users; can't verify off"
        fi
 }
-run_test 160 "changelog sanity"
+run_test 160a "changelog sanity"
+
+test_160b() { # LU-3587
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
+               { skip "Need MDS version at least 2.2.0"; return; }
+
+       local CL_USERS="mdd.$MDT0.changelog_users"
+       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
+       USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
+       echo "Registered as changelog user $USER"
+       $GET_CL_USERS | grep -q $USER ||
+               error "User $USER not found in changelog_users"
+
+       local LONGNAME1=$(str_repeat a 255)
+       local LONGNAME2=$(str_repeat b 255)
+
+       cd $DIR
+       echo "creating very long named file"
+       touch $LONGNAME1 || error "create of $LONGNAME1 failed"
+       echo "moving very long named file"
+       mv $LONGNAME1 $LONGNAME2
+
+       $LFS changelog $MDT0 | grep RENME
+
+       echo "deregistering $USER"
+       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
+
+       rm -f $LONGNAME2
+}
+run_test 160b "Verify that very long rename doesn't crash in changelog"
 
 test_161a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return