test_51ba() depends on test_51b() and skipped if run separately
Patch combines test_51b() and test_51ba() into test_51b().
$tdir is used for test dir name.
Test-Parameters: envdefinitions=ONLY=51b testlist=sanity
Seagate-bug-id: MRP-2290
Signed-off-by: Elena Gryaznova <elena.gryaznova@seagate.com>
Reviewed-by: Vladimir Saveliev <vladimir.saveliev@seagate.com>
Reviewed-by: Vitaly Fertman <vitaly.fertman@seagate.com>
Change-Id: I6ee019a03d398e36c7007973614375c9ca22e349
Reviewed-on: http://review.whamcloud.com/17239
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
}
run_test 51a "special situations: split htree with empty entry =="
}
run_test 51a "special situations: split htree with empty entry =="
test_51b() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
test_51b() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
- local BASE=$DIR/d${base}.${TESTSUITE}
+ local dir=$DIR/$tdir
+
+ local nrdirs=$((65536 + 100))
- test_mkdir -p -c1 $BASE
- local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
+ local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
- [[ $numfree -lt 21000 ]] &&
+ [[ $numfree -lt $nrdirs ]] &&
skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
return
skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
return
- [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
- echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
-
# need to check free space for the directories as well
local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
numfree=$((blkfree / 4))
# need to check free space for the directories as well
local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
numfree=$((blkfree / 4))
- [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
- echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
-
- createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
- {
- $LFS df
- $LFS df -i
- echo "failed" > $BASE/fnum
- error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
- }
-}
-run_test 51b "exceed 64k subdirectory nlink limit"
+ [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
+ return
-test_51ba() { # LU-993
- local BASE=$DIR/d${base}.${TESTSUITE}
- # unlink all but 100 subdirectories, then check it still works
- local LEFT=100
- [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
+ # create files
+ createmany -d $dir/d $nrdirs ||
+ error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
- [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
- local DELETE=$((NUMTEST - LEFT))
+ # really created :
+ nrdirs=$(ls -U $dir | wc -l)
- # continue on to run this test even if 51b didn't finish,
- # just to delete the many subdirectories created.
- [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
+ # unlink all but 100 subdirectories, then check it still works
+ local left=100
+ local delete=$((nrdirs - left))
# for ldiskfs the nlink count should be 1, but this is OSD specific
# and so this is listed for informational purposes only
# for ldiskfs the nlink count should be 1, but this is OSD specific
# and so this is listed for informational purposes only
- echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
- unlinkmany -d $BASE/d $DELETE
- RC=$?
-
- if [ $RC -ne 0 ]; then
- if [ "$NUMPREV" == "failed" ]; then
- skip "previous setup failed"
- return 0
- else
- error "unlink of first $DELETE subdirs failed"
- return $RC
- fi
- fi
+ echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
+ unlinkmany -d $dir/d $delete ||
+ error "unlink of first $delete subdirs failed"
- echo "nlink between: $(stat -c %h $BASE)"
- # trim the first line of ls output
- local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
- [ $FOUND -ne $LEFT ] &&
- error "can't find subdirs: found only $FOUND/$LEFT"
+ echo "nlink between: $(stat -c %h $dir)"
+ local found=$(ls -U $dir | wc -l)
+ [ $found -ne $left ] &&
+ error "can't find subdirs: found only $found, expected $left"
- unlinkmany -d $BASE/d $DELETE $LEFT ||
- error "unlink of second $LEFT subdirs failed"
+ unlinkmany -d $dir/d $delete $left ||
+ error "unlink of second $left subdirs failed"
# regardless of whether the backing filesystem tracks nlink accurately
# or not, the nlink count shouldn't be more than "." and ".." here
# regardless of whether the backing filesystem tracks nlink accurately
# or not, the nlink count shouldn't be more than "." and ".." here
- local AFTER=$(stat -c %h $BASE)
- [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
- echo "nlink after: $AFTER"
+ local after=$(stat -c %h $dir)
+ [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
+ echo "nlink after: $after"
-run_test 51ba "verify nlink for many subdirectory cleanup"
+run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
test_51d() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
test_51d() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return