Whamcloud - gitweb
LU-819 utils: Fix lfs getstripe -M
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 1988caf..02f0d6f 100644 (file)
@@ -2982,17 +2982,13 @@ test_51a() {    # was test_51
 }
 run_test 51a "special situations: split htree with empty entry =="
 
-#export NUMTEST=70000
-# FIXME: I select a relatively small number to do basic test.
-# large number may give panic(). debugging on this is going on.
-export NUMTEST=70
+export NUMTEST=70000
 test_51b() {
        NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
        [ $NUMFREE -lt 21000 ] && \
                skip "not enough free inodes ($NUMFREE)" && \
                return
 
-       check_kernel_version 40 || NUMTEST=31000
        [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
 
        mkdir -p $DIR/d51b
@@ -3000,6 +2996,32 @@ test_51b() {
 }
 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
 
+test_51ba() { # LU-993
+        local BASE=$DIR/d51b
+        # unlink all but 100 subdirectories, then check it still works
+        local LEFT=100
+        local DELETE=$((NUMTEST - LEFT))
+
+        ! [ -d "${BASE}/t-$DELETE" ] && skip "test_51b() not run" && return 0
+
+        # for ldiskfs the nlink count should be 1, but this is OSD specific
+        # and so this is listed for informational purposes only
+        log "nlink before: $(stat -c %h $BASE)"
+        unlinkmany -d $BASE/t- $DELETE ||
+                error "unlink of first $DELETE subdirs failed"
+
+        log "nlink between: $(stat -c %h $BASE)"
+        local FOUND=$(ls -l ${BASE} | wc -l)
+        FOUND=$((FOUND - 1))  # trim the first line of ls output
+        [ $FOUND -ne $LEFT ] &&
+                error "can't find subdirs: found only $FOUND/$LEFT"
+
+        unlinkmany -d $BASE/t- $DELETE $LEFT ||
+                error "unlink of second $LEFT subdirs failed"
+        log "nlink after: $(stat -c %h $BASE)"
+}
+run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
+
 test_51bb() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
@@ -3353,9 +3375,9 @@ test_56i() {
        mkdir -p $DIR/$tdir
        UUID=$(ostuuid_from_index 0 $DIR/$tdir)
        OUT=$($LFIND -obd $UUID $DIR/$tdir)
-       [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
+       [ "$OUT" ] && error "$LFIND -obd returned directory '$OUT'" || true
 }
-run_test 56i "check 'lfs find -ost UUID' skips directories ======="
+run_test 56i "check 'lfs find -obd UUID' skips directories ======="
 
 test_56j() {
        setup_56_special $NUMFILES $NUMDIRS
@@ -3516,6 +3538,22 @@ test_56r() {
 
 run_test 56r "check lfs find -size works =========================="
 
+test_56v() {
+    local FIND_MDT_IDX=0
+
+    TDIR=${tdir}g
+    rm -rf $TDIR
+    setup_56 $NUMFILES $NUMDIRS
+
+    UUID=$(mdtuuid_from_index $FIND_MDT_IDX $DIR/$TDIR)
+    for file in $($LFIND -mdt $UUID $DIR/$TDIR); do
+        file_mdt_idx=$($GETSTRIPE -M $file)
+        [ $file_mdt_idx -eq $FIND_MDT_IDX ] ||
+            error "wrong lfind -m not match getstripe -M"
+    done
+}
+run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
+
 test_57a() {
        # note test will not do anything if MDS is not local
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
@@ -6862,6 +6900,16 @@ test_133a() {
        rmdir ${testdir} || error "rmdir failed"
        check_stats $SINGLEMDS "rmdir" 1
 
+       local testdir1=$DIR/${tdir}/stats_testdir1
+       mkdir -p ${testdir}
+       mkdir -p ${testdir1}
+       touch ${testdir1}/test1
+       mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
+       check_stats $SINGLEMDS "crossdir_rename" 1
+
+       mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
+       check_stats $SINGLEMDS "samedir_rename" 1
+
        rm -rf $DIR/${tdir}
 }
 run_test 133a "Verifying MDT stats ========================================"
@@ -6921,6 +6969,101 @@ test_133c() {
 }
 run_test 133c "Verifying OST stats ========================================"
 
+order_2() {
+    local value=$1
+    local orig=$value
+    local order=1
+
+    while [ $value -ge 2 ]; do
+        order=$((order*2))
+        value=$((value/2))
+    done
+
+    if [ $orig -gt $order ]; then
+        order=$((order*2))
+    fi
+    echo $order
+}
+
+size_in_KMGT() {
+    local value=$1
+    local size=('K' 'M' 'G' 'T');
+    local i=0
+    local size_string=$value
+
+    while [ $value -ge 1024 ]; do
+        if [ $i -gt 3 ]; then
+            #T is the biggest unit we get here, if that is bigger,
+            #just return XXXT
+            size_string=${value}T
+            break
+        fi
+        value=$((value >> 10))
+        if [ $value -lt 1024 ]; then
+            size_string=${value}${size[$i]}
+            break
+        fi
+        i=$((i + 1))
+    done
+
+    echo $size_string
+}
+
+get_rename_size() {
+    local size=$1
+    local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+                   awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
+    echo $sample
+}
+
+test_133d() {
+    remote_ost_nodsh && skip "remote OST with nodsh" && return
+    remote_mds_nodsh && skip "remote MDS with nodsh" && return
+    local testdir1=$DIR/${tdir}/stats_testdir1
+    local testdir2=$DIR/${tdir}/stats_testdir2
+
+    do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+
+    mkdir -p ${testdir1} || error "mkdir failed"
+    mkdir -p ${testdir2} || error "mkdir failed"
+
+    createmany -o $testdir1/test 512 || error "createmany failed"
+    local testdir1_size=$(ls -l $DIR/${tdir} | \
+                          awk '/stats_testdir1/ {print $5}')
+    local testdir2_size=$(ls -l $DIR/${tdir} | \
+                          awk '/stats_testdir2/ {print $5}')
+
+    testdir1_size=$(order_2 $testdir1_size)
+    testdir2_size=$(order_2 $testdir2_size)
+
+    testdir1_size=$(size_in_KMGT $testdir1_size)
+    testdir2_size=$(size_in_KMGT $testdir2_size)
+
+    # check samedir rename size
+    mv ${testdir1}/test0 ${testdir1}/test_0
+    local samedir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+                    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 count error"
+    echo "Check same dir rename stats success"
+
+    # check crossdir rename size
+    do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+    mv ${testdir1}/test_0 ${testdir2}/test_0
+    local crossdir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+                     grep 'crossdir')
+    local src_sample=$(get_rename_size $testdir1_size)
+    local tgt_sample=$(get_rename_size $testdir2_size)
+    [ -z "$crossdir" ] && error "crossdir_rename_size count error"
+    [ $src_sample -eq 1 ] || error "crossdir_rename_size count error"
+    [ $tgt_sample -eq 1 ] || error "crossdir_rename_size count error"
+    echo "Check cross dir rename stats success"
+
+    rm -rf $DIR/${tdir}
+}
+run_test 133d "Verifying rename_stats ========================================"
+
 test_140() { #bug-17379
         mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
         cd $DIR/$tdir || error "Changing to $DIR/$tdir"