Whamcloud - gitweb
LU-6824 ldiskfs: give warning with dir htree growing
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 1bb2891..3b77e07 100755 (executable)
@@ -556,11 +556,7 @@ run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
 test_17m() {
        local short_sym="0123456789"
        local WDIR=$DIR/${tdir}m
-       local mds_index
-       local devname
-       local cmd
        local i
-       local rc=0
 
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
@@ -593,49 +589,42 @@ test_17m() {
        echo "recreate the 512 symlink files with a shorter string"
        for ((i = 0; i < 512; ++i)); do
                # rewrite the symlink file with a shorter string
-               ln -sf ${long_sym} $WDIR/long-$i
-               ln -sf ${short_sym} $WDIR/short-$i
+               ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
+               ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
        done
 
-       mds_index=$($LFS getstripe -M $WDIR)
-       mds_index=$((mds_index+1))
-       devname=$(mdsdevname $mds_index)
-       cmd="$E2FSCK -fnvd $devname"
+       local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
+       local devname=$(mdsdevname $mds_index)
 
-       echo "stop and checking mds${mds_index}: $cmd"
+       echo "stop and checking mds${mds_index}:"
        # e2fsck should not return error
        stop mds${mds_index}
-       do_facet mds${mds_index} $cmd || rc=$?
+       run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
+       rc=$?
 
        start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
        df $MOUNT > /dev/null 2>&1
-       [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
-               "short/long symlink MDT: rc=$rc"
-       return $rc
+       [ $rc -eq 0 ] ||
+               error "e2fsck detected error for short/long symlink: rc=$rc"
 }
 run_test 17m "run e2fsck against MDT which contains short/long symlink"
 
 check_fs_consistency_17n() {
        local mdt_index
-       local devname
-       local cmd
        local rc=0
 
        # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
        # so it only check MDT1/MDT2 instead of all of MDTs.
-       for mdt_index in $(seq 1 2); do
-               devname=$(mdsdevname $mdt_index)
-               cmd="$E2FSCK -fnvd $devname"
-
-               echo "stop and checking mds${mdt_index}: $cmd"
+       for mdt_index in 1 2; do
+               local devname=$(mdsdevname $mdt_index)
                # e2fsck should not return error
                stop mds${mdt_index}
-               do_facet mds${mdt_index} $cmd || rc=$?
+               run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
+                       rc=$((rc + $?))
 
                start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
-                       error "mount mds${mdt_index} failed"
+                       error "mount mds$mdt_index failed"
                df $MOUNT > /dev/null 2>&1
-               [ $rc -ne 0 ] && break
        done
        return $rc
 }
@@ -1885,6 +1874,7 @@ check_seq_oid()
                                $(facet_mntpt ost$ost)/$obj_file)
                        unmount_fstype ost$ost
                        start ost$ost $dev $OST_MOUNT_OPTS
+                       clients_up
                fi
 
                [ -z "$ff" ] && error "$obj_file: no filter_fid info"
@@ -5649,7 +5639,7 @@ test_68b() {  # was test_68
 run_test 68b "support swapping to Lustre ========================"
 
 # bug5265, obdfilter oa2dentry return -ENOENT
-# #define OBD_FAIL_OST_ENOENT 0x217
+# #define OBD_FAIL_SRV_ENOENT 0x217
 test_69() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        remote_ost_nodsh && skip "remote OST with nodsh" && return
@@ -7597,7 +7587,7 @@ test_118b()
 
        reset_async
 
-       #define OBD_FAIL_OST_ENOENT 0x217
+       #define OBD_FAIL_SRV_ENOENT 0x217
        set_nodes_failloc "$(osts_nodes)" 0x217
        $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
        RC=$?
@@ -8698,9 +8688,20 @@ set_dir_limits () {
                do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
                                                LDPROC=/sys/fs/ldiskfs
                do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
+               do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
+                                               LDPROC=/sys/fs/ldiskfs
+               do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
        done
 }
 
+check_mds_dmesg() {
+       local facets=$(get_facets MDS)
+       for facet in ${facets//,/ }; do
+               do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
+       done
+       return 1
+}
+
 test_129() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
@@ -8710,6 +8711,7 @@ test_129() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
        ENOSPC=28
        EFBIG=27
+       has_warning=0
 
        rm -rf $DIR/$tdir
        test_mkdir -p $DIR/$tdir
@@ -8717,8 +8719,8 @@ test_129() {
        # block size of mds1
        local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
        local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
-       local MAX=$((MDSBLOCKSIZE * 3))
-       set_dir_limits $MAX
+       local MAX=$((MDSBLOCKSIZE * 5))
+       set_dir_limits $MAX $MAX
        local I=$(stat -c%s "$DIR/$tdir")
        local J=0
        local STRIPE_COUNT=1
@@ -8727,15 +8729,25 @@ test_129() {
        while [[ $I -le $MAX ]]; do
                $MULTIOP $DIR/$tdir/$J Oc
                rc=$?
+               if [ $has_warning -eq 0 ]; then
+                       check_mds_dmesg '"is approaching"' &&
+                               has_warning=1
+               fi
                #check two errors ENOSPC for new version of ext4 max_dir_size patch
                #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
                #and EFBIG for previous versions
                if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
-                       set_dir_limits 0
+                       set_dir_limits 0 0
                        echo "return code $rc received as expected"
                        multiop $DIR/$tdir/$J Oc ||
                                error_exit "multiop failed w/o dir size limit"
 
+                       check_mds_dmesg '"has reached"' ||
+                               error_exit "has reached message should be output"
+
+                       [ $has_warning ] ||
+                               error_exit "warning message should be output"
+
                        I=$(stat -c%s "$DIR/$tdir")
 
                        if [ $(lustre_version_code $SINGLEMDS) -lt \
@@ -8747,7 +8759,7 @@ test_129() {
                        fi
                        error_exit "current dir size $I, previous limit $MAX"
                elif [ $rc -ne 0 ]; then
-                       set_dir_limits 0
+                       set_dir_limits 0 0
                        error_exit "return code $rc received instead of expected " \
                                   "$EFBIG or $ENOSPC, files in dir $I"
                fi
@@ -8755,7 +8767,7 @@ test_129() {
                I=$(stat -c%s "$DIR/$tdir")
        done
 
-       set_dir_limits 0
+       set_dir_limits 0 0
        error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
 }
 run_test 129 "test directory size limit ========================"
@@ -13507,120 +13519,6 @@ test_252() {
 }
 run_test 252 "check lr_reader tool"
 
-test_253_fill_ost() {
-       local size_1
-       local hwm=$3
-       local free_10
-
-       blocks=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
-       size_1=$((blocks/1024-hwm))
-       free_10=$((blocks/10240))
-       if (( free_10 > size_1 )); then
-               size_1=$free_10
-       else
-               size_1=$((size_1+size_1/10))
-       fi
-       if [[ $hwm < $((blocks/1024)) ]]; then
-               dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_1 \
-                        oflag=append conv=notrunc
-
-               sleep_maxage
-
-               blocks=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
-               echo "OST still has $((blocks/1024)) mbytes free"
-       fi
-}
-
-test_253() {
-       local ostidx=0
-       local rc=0
-
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
-
-       rm -rf $DIR/$tdir
-       wait_mds_ost_sync
-       wait_delete_completed
-       mkdir $DIR/$tdir
-       local ost_name=$($LFS osts | grep ${ostidx}": " | \
-               awk '{print $2}' | sed -e 's/_UUID$//')
-
-       # on the mdt's osc
-       local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
-       local last_wm_h=$(do_facet $SINGLEMDS lctl get_param -n \
-                       osp.$mdtosc_proc1.reserved_mb_high)
-       local last_wm_l=$(do_facet $SINGLEMDS lctl get_param -n \
-                       osp.$mdtosc_proc1.reserved_mb_low)
-       echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
-
-       do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
-               error "Pool creation failed"
-       do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
-               errot "Adding $ost_name to pool fialed"
-
-       # Wait for client to see a OST at pool
-       wait_update $HOSTNAME "lctl get_param -n
-                       lov.$FSNAME-*.pools.$TESTNAME | sort -u |
-                       grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
-                       return 2
-       $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
-               error "Setstripe failed"
-
-       dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
-       local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
-       echo "OST still has $((blocks/1024)) mbytes free"
-
-       local new_hwm=$((blocks/1024-10))
-       do_facet $SINGLEMDS lctl set_param \
-                       osp.$mdtosc_proc1.reserved_mb_high=$((new_hwm+5))
-       do_facet $SINGLEMDS lctl set_param \
-                       osp.$mdtosc_proc1.reserved_mb_low=$new_hwm
-
-       test_253_fill_ost $ost_name $mdtosc_proc1 $new_hwm
-
-       #First enospc could execute orphan deletion so repeat.
-       test_253_fill_ost $ost_name $mdtosc_proc1 $new_hwm
-
-       local oa_status=$(do_facet $SINGLEMDS lctl get_param -n \
-                       osp.$mdtosc_proc1.prealloc_status)
-       echo "prealloc_status $oa_status"
-
-       dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
-               error "File creation should fail"
-       #object allocation was stopped, but we still able to append files
-       dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
-               error "Append failed"
-       rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
-
-       wait_delete_completed
-
-       sleep_maxage
-
-       for i in $(seq 10 12); do
-               dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
-                       error "File creation failed after rm";
-       done
-
-       oa_status=$(do_facet $SINGLEMDS lctl get_param -n \
-                       osp.$mdtosc_proc1.prealloc_status)
-       echo "prealloc_status $oa_status"
-
-       if (( oa_status != 0 )); then
-               error "Object allocation still disable after rm"
-       fi
-       do_facet $SINGLEMDS lctl set_param \
-                       osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
-       do_facet $SINGLEMDS lctl set_param \
-                       osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
-
-
-       do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
-               error "Remove $ost_name from pool failed"
-       do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
-               error "Pool destroy fialed"
-}
-run_test 253 "Check object allocation limit"
 
 cleanup_test_300() {
        trap 0