set -e
ONLY=${ONLY:-"$*"}
-# bug number for skipped test: LU-9693 LU-6493 LU-9693 3561 5188
-ALWAYS_EXCEPT=" 42a 42b 42c 45 68b $SANITY_EXCEPT"
+# bug number for skipped test: LU-9693 LU-6493 LU-9693
+ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-# skipped tests: LU-8411 LU-9096 LU-9054 LU-10199
-ALWAYS_EXCEPT=" 407 253 312 56xb $ALWAYS_EXCEPT"
+# skipped tests: LU-8411 LU-9096 LU-9054
+ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
# Check Grants after these tests
GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
-is_sles11() # LU-4341
-{
- if [ -r /etc/SuSE-release ]
- then
- local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
- local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
- awk '{ print $3 }')
- if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
- return 0
- fi
- fi
- return 1
-}
-
-if is_sles11; then # LU-4341
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
-fi
-
SRCDIR=$(cd $(dirname $0); echo $PWD)
export PATH=$PATH:/sbin
CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
CREATETEST=${CREATETEST:-createtest}
LFS=${LFS:-lfs}
-LFIND=${LFIND:-"$LFS find"}
LVERIFY=${LVERIFY:-ll_dirstripe_verify}
LCTL=${LCTL:-lctl}
OPENFILE=${OPENFILE:-openfile}
[ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
fi
+# Get the SLES version so we can make decisions on if a test should be run
+#
+# Returns a version string that should only be used in comparing
+# strings returned by version_code()
+
+sles_version_code()
+{
+ local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
+
+ # All SuSE Linux versions have one decimal. version_code expects two
+ local sles_version=$version.0
+ version_code $sles_version
+}
+
+if [ -r /etc/SuSE-release ]; then
+ sles_version=$(sles_version_code)
+ [ $sles_version -lt $(version_code 11.4.0) ] &&
+ # bug number for skipped test: LU-4341
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
+ [ $sles_version -lt $(version_code 12.0.0) ] &&
+ # bug number for skipped test: LU-3703
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
+fi
+
FAIL_ON_ERROR=false
cleanup() {
unlinkmany $DIR/$tdir/t- 1000
trap 0
[[ $OBJS -gt 0 ]] &&
- error "$OBJS objects created on OST-0. See $TLOG" || pass
+ error "$OBJS objects created on OST-0. See $TLOG" ||
+ rm -f $TLOG
}
run_test 27u "skip object creation on OSC w/o objects"
cp -p multiop $DIR/$tdir/multiop
MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
error "multiop open $TMP/$tfile.junk failed"
+ rm $TMP/$tfile.junk # delete junk file on close (not part of test)
MULTIOP_PID=$!
$MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
cp -p multiop $DIR/$tdir/multiop
MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
error "multiop open $TMP/$tfile.junk failed"
+ rm $TMP/$tfile.junk # delete junk file on close (not part of test)
MULTIOP_PID=$!
$TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
}
run_test 54e "console/tty device works in lustre ======================"
-#The test_55 used to be iopen test and it was removed by bz#24037.
-#run_test 55 "check iopen_connect_dentry() ======================"
-
-test_56a() { # was test_56
- rm -rf $DIR/$tdir
- $SETSTRIPE -d $DIR
- test_mkdir -p $DIR/$tdir/dir
- NUMFILES=3
- NUMFILESx2=$(($NUMFILES * 2))
- for i in $(seq 1 $NUMFILES); do
- touch $DIR/$tdir/file$i
- touch $DIR/$tdir/dir/file$i
- done
+test_56a() {
+ local numfiles=3
+ local dir=$DIR/$tdir
+
+ rm -rf $dir
+ test_mkdir -p $dir/dir
+ for i in $(seq $numfiles); do
+ touch $dir/file$i
+ touch $dir/dir/file$i
+ done
+
+ local numcomp=$($LFS getstripe --component-count $dir)
+
+ [[ $numcomp == 0 ]] && numcomp=1
+
+ # test lfs getstripe with --recursive
+ local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
- # test lfs getstripe with --recursive
- FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
- [[ $FILENUM -eq $NUMFILESx2 ]] ||
- error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
- FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
- [[ $FILENUM -eq $NUMFILES ]] ||
- error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
- echo "$GETSTRIPE --recursive passed."
+ [[ $filenum -eq $((numfiles * 2)) ]] ||
+ error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
+ filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
+ [[ $filenum -eq $numfiles ]] ||
+ error "$LFS getstripe $dir: found $filenum, not $numfiles"
+ echo "$LFS getstripe showed obdidx or l_ost_idx"
# test lfs getstripe with file instead of dir
- FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
- [[ $FILENUM -eq 1 ]] ||
- error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
- echo "$GETSTRIPE file1 passed."
+ filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
+ [[ $filenum -eq 1 ]] ||
+ error "$LFS getstripe $dir/file1: found $filenum, not 1"
+ echo "$LFS getstripe file1 passed"
#test lfs getstripe with --verbose
- [[ $($GETSTRIPE --verbose $DIR/$tdir |
- grep -c lmm_magic) -eq $NUMFILES ]] ||
- error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
- [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
- error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
+ filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
+ [[ $filenum -eq $((numfiles * numcomp)) ]] ||
+ error "$LFS getstripe --verbose $dir: "\
+ "got $filenum want $((numfiles * numcomp)) lmm_magic"
+ [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
+ error "$LFS getstripe $dir: showed lmm_magic"
#test lfs getstripe with -v prints lmm_fid
- [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
- error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
- [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
- error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
- echo "$GETSTRIPE --verbose passed."
+ filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
+ [[ $filenum -eq $((numfiles * numcomp)) ]] ||
+ error "$LFS getstripe -v $dir: "\
+ "got $filenum want $((numfiles * numcomp)) lmm_fid"
+ [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
+ error "$LFS getstripe $dir: showed lmm_fid by default"
+ echo "$LFS getstripe --verbose passed"
#check for FID information
- local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
- local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
- awk '/lmm_fid: / { print $2 }')
- local fid3=$($LFS path2fid $DIR/$tdir/file1)
+ local fid1=$($LFS getstripe --fid $dir/file1)
+ local fid2=$($LFS getstripe --verbose $dir/file1 |
+ awk '/lmm_fid: / { print $2; exit; }')
+ local fid3=$($LFS path2fid $dir/file1)
+
[ "$fid1" != "$fid2" ] &&
- error "getstripe --fid $fid1 != getstripe --verbose $fid2"
+ error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
[ "$fid1" != "$fid3" ] &&
- error "getstripe --fid $fid1 != lfs path2fid $fid3"
- echo "$GETSTRIPE --fid passed."
+ error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
+ echo "$LFS getstripe --fid passed"
#test lfs getstripe with --obd
- $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
- grep -q "unknown obduuid" ||
- error "$GETSTRIPE --obd wrong_uuid should return error message"
+ $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
+ error "$LFS getstripe --obd wrong_uuid: should return error"
[[ $OSTCOUNT -lt 2 ]] &&
- skip_env "skipping other $GETSTRIPE --obd test" && return
-
- OSTIDX=1
- OBDUUID=$(ostuuid_from_index $OSTIDX)
- FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
- FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
- [[ $FOUND -eq $FILENUM ]] ||
- error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
- [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
- sed '/^[ ]*'${OSTIDX}'[ ]/d' |
+ skip_env "skip '$LFS getstripe --obd' tests: $OSTCOUNT < 2" &&
+ return
+
+ local ostidx=1
+ local obduuid=$(ostuuid_from_index $ostidx)
+ local found=$($LFS getstripe -r --obd $obduuid $dir |
+ egrep -c "obdidx|l_ost_idx")
+
+ filenum=$($LFS getstripe -ir $dir | grep "^$ostidx\$" | wc -l)
+ [[ $found -eq $filenum ]] ||
+ error "$LFS getstripe --obd: found $found expect $filenum"
+ [[ $($LFS getstripe -r -v --obd $obduuid $dir |
+ sed '/^[ ]*'${ostidx}'[ ]/d' |
sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
- error "$GETSTRIPE --obd: should not show file on other obd"
- echo "$GETSTRIPE --obd passed"
+ error "$LFS getstripe --obd: should not show file on other obd"
+ echo "$LFS getstripe --obd passed"
}
-run_test 56a "check $GETSTRIPE"
+run_test 56a "check $LFS getstripe"
test_56b() {
- test_mkdir $DIR/$tdir
- NUMDIRS=3
- for i in $(seq 1 $NUMDIRS); do
- test_mkdir $DIR/$tdir/dir$i
+ local dir=$DIR/$tdir
+ local numdirs=3
+
+ test_mkdir $dir
+ for i in $(seq $numdirs); do
+ test_mkdir $dir/dir$i
done
# test lfs getdirstripe default mode is non-recursion, which is
# different from lfs getstripe
- dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
+ local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
+
[[ $dircnt -eq 1 ]] ||
error "$LFS getdirstripe: found $dircnt, not 1"
- dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
+ dircnt=$($LFS getdirstripe --recursive $dir |
grep -c lmv_stripe_count)
- [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
- error "$LFS getdirstripe --recursive: found $dircnt, \
- not $((NUMDIRS + 1))"
+ [[ $dircnt -eq $((numdirs + 1)) ]] ||
+ error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
}
run_test 56b "check $LFS getdirstripe"
test_56c() {
local ost_idx=0
local ost_name=$(ostname_from_index $ost_idx)
-
local old_status=$(ost_dev_status $ost_idx)
+
[[ -z "$old_status" ]] ||
{ skip_env "OST $ost_name is in $old_status status"; return 0; }
sleep_maxage
local new_status=$(ost_dev_status $ost_idx)
+
[[ "$new_status" = "D" ]] ||
error "OST $ost_name is in status of '$new_status', not 'D'"
NUMFILES=3
NUMDIRS=3
setup_56() {
- local LOCAL_NUMFILES="$1"
- local LOCAL_NUMDIRS="$2"
- local MKDIR_PARAMS="$3"
- local DIR_STRIPE_PARAMS="$4"
-
- if [ ! -d "$TDIR" ] ; then
- test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
- [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
- for i in `seq 1 $LOCAL_NUMFILES` ; do
- touch $TDIR/file$i
+ local local_tdir="$1"
+ local local_numfiles="$2"
+ local local_numdirs="$3"
+ local dir_params="$4"
+ local dir_stripe_params="$5"
+
+ if [ ! -d "$local_tdir" ] ; then
+ test_mkdir -p $dir_stripe_params $local_tdir
+ [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
+ for i in $(seq $local_numfiles) ; do
+ touch $local_tdir/file$i
done
- for i in `seq 1 $LOCAL_NUMDIRS` ; do
- test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
- for j in `seq 1 $LOCAL_NUMFILES` ; do
- touch $TDIR/dir$i/file$j
+ for i in $(seq $local_numdirs) ; do
+ test_mkdir $dir_stripe_params $local_tdir/dir$i
+ for j in $(seq $local_numfiles) ; do
+ touch $local_tdir/dir$i/file$j
done
done
fi
}
setup_56_special() {
- LOCAL_NUMFILES=$1
- LOCAL_NUMDIRS=$2
- setup_56 $1 $2
- if [ ! -e "$TDIR/loop1b" ] ; then
- for i in `seq 1 $LOCAL_NUMFILES` ; do
- mknod $TDIR/loop${i}b b 7 $i
- mknod $TDIR/null${i}c c 1 3
- ln -s $TDIR/file1 $TDIR/link${i}l
+ local local_tdir=$1
+ local local_numfiles=$2
+ local local_numdirs=$3
+
+ setup_56 $local_tdir $local_numfiles $local_numdirs
+
+ if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
+ for i in $(seq $local_numfiles) ; do
+ mknod $local_tdir/loop${i}b b 7 $i
+ mknod $local_tdir/null${i}c c 1 3
+ ln -s $local_tdir/file1 $local_tdir/link${i}
done
- for i in `seq 1 $LOCAL_NUMDIRS` ; do
- mknod $TDIR/dir$i/loop${i}b b 7 $i
- mknod $TDIR/dir$i/null${i}c c 1 3
- ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
+ for i in $(seq $local_numdirs) ; do
+ mknod $local_tdir/dir$i/loop${i}b b 7 $i
+ mknod $local_tdir/dir$i/null${i}c c 1 3
+ ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
done
fi
}
test_56g() {
- $SETSTRIPE -d $DIR
-
- TDIR=$DIR/${tdir}g
- setup_56 $NUMFILES $NUMDIRS
-
- EXPECTED=$(($NUMDIRS + 2))
- # test lfs find with -name
- for i in $(seq 1 $NUMFILES) ; do
- NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "lfs find -name \"*$i\" $TDIR wrong: "\
- "found $NUMS, expected $EXPECTED"
- done
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
+ local expected=$(($NUMDIRS + 2))
+
+ setup_56 $dir $NUMFILES $NUMDIRS
+
+ # test lfs find with -name
+ for i in $(seq $NUMFILES) ; do
+ local nums=$($LFS find -name "*$i" $dir | wc -l)
+
+ [ $nums -eq $expected ] ||
+ error "lfs find -name '*$i' $dir wrong: "\
+ "found $nums, expected $expected"
+ done
}
-run_test 56g "check lfs find -name ============================="
+run_test 56g "check lfs find -name"
test_56h() {
- $SETSTRIPE -d $DIR
-
- TDIR=$DIR/${tdir}g
- setup_56 $NUMFILES $NUMDIRS
-
- EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
- # test lfs find with ! -name
- for i in $(seq 1 $NUMFILES) ; do
- NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "lfs find ! -name \"*$i\" $TDIR wrong: "\
- "found $NUMS, expected $EXPECTED"
- done
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
+ local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
+
+ setup_56 $dir $NUMFILES $NUMDIRS
+
+ # test lfs find with ! -name
+ for i in $(seq $NUMFILES) ; do
+ local nums=$($LFS find ! -name "*$i" $dir | wc -l)
+
+ [ $nums -eq $expected ] ||
+ error "lfs find ! -name '*$i' $dir wrong: "\
+ "found $nums, expected $expected"
+ done
}
run_test 56h "check lfs find ! -name"
test_56i() {
- tdir=${tdir}i
- test_mkdir $DIR/$tdir
- UUID=$(ostuuid_from_index 0 $DIR/$tdir)
- CMD="$LFIND -ost $UUID $DIR/$tdir"
- OUT=$($CMD)
- [ -z "$OUT" ] || error "'$CMD' returned directory '$OUT'"
+ local dir=$DIR/$tdir
+
+ test_mkdir $dir
+
+ local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
+ local out=$($cmd)
+
+ [ -z "$out" ] || error "'$cmd' returned directory '$out'"
}
run_test 56i "check 'lfs find -ost UUID' skips directories"
test_56j() {
- TDIR=$DIR/${tdir}g
- setup_56_special $NUMFILES $NUMDIRS
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
- EXPECTED=$((NUMDIRS + 1))
- CMD="$LFIND -type d $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ setup_56_special $dir $NUMFILES $NUMDIRS
+
+ local expected=$((NUMDIRS + 1))
+ local cmd="$LFS find -type d $dir"
+ local nums=$($cmd | wc -l)
+
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56j "check lfs find -type d ============================="
+run_test 56j "check lfs find -type d"
test_56k() {
- TDIR=$DIR/${tdir}g
- setup_56_special $NUMFILES $NUMDIRS
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
+
+ setup_56_special $dir $NUMFILES $NUMDIRS
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
- CMD="$LFIND -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ local expected=$(((NUMDIRS + 1) * NUMFILES))
+ local cmd="$LFS find -type f $dir"
+ local nums=$($cmd | wc -l)
+
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56k "check lfs find -type f ============================="
+run_test 56k "check lfs find -type f"
test_56l() {
- TDIR=$DIR/${tdir}g
- setup_56_special $NUMFILES $NUMDIRS
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
+
+ setup_56_special $dir $NUMFILES $NUMDIRS
+
+ local expected=$((NUMDIRS + NUMFILES))
+ local cmd="$LFS find -type b $dir"
+ local nums=$($cmd | wc -l)
- EXPECTED=$((NUMDIRS + NUMFILES))
- CMD="$LFIND -type b $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56l "check lfs find -type b ============================="
+run_test 56l "check lfs find -type b"
test_56m() {
- TDIR=$DIR/${tdir}g
- setup_56_special $NUMFILES $NUMDIRS
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
- EXPECTED=$((NUMDIRS + NUMFILES))
- CMD="$LFIND -type c $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ setup_56_special $dir $NUMFILES $NUMDIRS
+
+ local expected=$((NUMDIRS + NUMFILES))
+ local cmd="$LFS find -type c $dir"
+ local nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56m "check lfs find -type c ============================="
+run_test 56m "check lfs find -type c"
test_56n() {
- TDIR=$DIR/${tdir}g
- setup_56_special $NUMFILES $NUMDIRS
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
+ setup_56_special $dir $NUMFILES $NUMDIRS
+
+ local expected=$((NUMDIRS + NUMFILES))
+ local cmd="$LFS find -type l $dir"
+ local nums=$($cmd | wc -l)
- EXPECTED=$((NUMDIRS + NUMFILES))
- CMD="$LFIND -type l $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56n "check lfs find -type l ============================="
+run_test 56n "check lfs find -type l"
test_56o() {
- TDIR=$DIR/${tdir}o
- setup_56 $NUMFILES $NUMDIRS
- utime $TDIR/file1 > /dev/null || error "utime (1)"
- utime $TDIR/file2 > /dev/null || error "utime (2)"
- utime $TDIR/dir1 > /dev/null || error "utime (3)"
- utime $TDIR/dir2 > /dev/null || error "utime (4)"
- utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
- dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
-
- EXPECTED=4
- NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
- [ $NUMS -eq $EXPECTED ] || \
- error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
-
- EXPECTED=12
- CMD="$LFIND -mtime 0 $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-}
-run_test 56o "check lfs find -mtime for old files =========================="
+ local dir=$DIR/$tdir
+
+ setup_56 $dir $NUMFILES $NUMDIRS
+ utime $dir/file1 > /dev/null || error "utime (1)"
+ utime $dir/file2 > /dev/null || error "utime (2)"
+ utime $dir/dir1 > /dev/null || error "utime (3)"
+ utime $dir/dir2 > /dev/null || error "utime (4)"
+ utime $dir/dir1/file1 > /dev/null || error "utime (5)"
+ dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
+
+ local expected=4
+ local nums=$($LFS find -mtime +0 $dir | wc -l)
+
+ [ $nums -eq $expected ] ||
+ error "lfs find -mtime +0 $dir: found $nums expect $expected"
+
+ expected=12
+ cmd="$LFS find -mtime 0 $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+}
+run_test 56o "check lfs find -mtime for old files"
test_56p() {
[ $RUNAS_ID -eq $UID ] &&
skip_env "RUNAS_ID = UID = $UID -- skipping" && return
- TDIR=$DIR/${tdir}p
- setup_56 $NUMFILES $NUMDIRS
+ local dir=$DIR/$tdir
+
+ setup_56 $dir $NUMFILES $NUMDIRS
+ chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
- chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
- EXPECTED=$NUMFILES
- CMD="$LFIND -uid $RUNAS_ID $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || \
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ local expected=$NUMFILES
+ local cmd="$LFS find -uid $RUNAS_ID $dir"
+ local nums=$($cmd | wc -l)
- EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
- CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || \
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ expected=$(((NUMFILES + 1) * NUMDIRS + 1))
+ cmd="$LFS find ! -uid $RUNAS_ID $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56p "check lfs find -uid and ! -uid ==============================="
+run_test 56p "check lfs find -uid and ! -uid"
test_56q() {
[ $RUNAS_ID -eq $UID ] &&
skip_env "RUNAS_ID = UID = $UID -- skipping" && return
- TDIR=$DIR/${tdir}q
- setup_56 $NUMFILES $NUMDIRS
+ local dir=$DIR/$tdir
+
+ setup_56 $dir $NUMFILES $NUMDIRS
+ chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
- chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
+ local expected=$NUMFILES
+ local cmd="$LFS find -gid $RUNAS_GID $dir"
+ local nums=$($cmd | wc -l)
- EXPECTED=$NUMFILES
- CMD="$LFIND -gid $RUNAS_GID $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
- EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
- CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
+ cmd="$LFS find ! -gid $RUNAS_GID $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
-run_test 56q "check lfs find -gid and ! -gid ==============================="
+run_test 56q "check lfs find -gid and ! -gid"
test_56r() {
- TDIR=$DIR/${tdir}r
- setup_56 $NUMFILES $NUMDIRS
-
- EXPECTED=12
- CMD="$LFIND -size 0 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- EXPECTED=0
- CMD="$LFIND ! -size 0 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- echo "test" > $TDIR/$tfile
- echo "test2" > $TDIR/$tfile.2 && sync
- EXPECTED=1
- CMD="$LFIND -size 5 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- EXPECTED=1
- CMD="$LFIND -size +5 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- EXPECTED=2
- CMD="$LFIND -size +0 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- EXPECTED=2
- CMD="$LFIND ! -size -5 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- EXPECTED=12
- CMD="$LFIND -size -5 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-}
-run_test 56r "check lfs find -size works =========================="
-
-test_56s() { # LU-611
- TDIR=$DIR/${tdir}s
-
- #LU-9369
- setup_56 0 $NUMDIRS
- for i in $(seq 1 $NUMDIRS); do
- $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
+ local dir=$DIR/$tdir
+
+ setup_56 $dir $NUMFILES $NUMDIRS
+
+ local expected=12
+ local cmd="$LFS find -size 0 -type f $dir"
+ local nums=$($cmd | wc -l)
+
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+ expected=0
+ cmd="$LFS find ! -size 0 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+ echo "test" > $dir/$tfile
+ echo "test2" > $dir/$tfile.2 && sync
+ expected=1
+ cmd="$LFS find -size 5 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+ expected=1
+ cmd="$LFS find -size +5 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+ expected=2
+ cmd="$LFS find -size +0 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+ expected=2
+ cmd="$LFS find ! -size -5 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+ expected=12
+ cmd="$LFS find -size -5 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+}
+run_test 56r "check lfs find -size works"
+
+test_56s() { # LU-611 #LU-9369
+ [[ $OSTCOUNT -lt 2 ]] && skip "need at least 2 OSTs" && return 0
+
+ local dir=$DIR/$tdir
+ local onestripe=$(((NUMDIRS + 1) * NUMFILES))
+
+ setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
+ for i in $(seq $NUMDIRS); do
+ $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
done
- EXPECTED=$NUMDIRS
- CMD="$LFIND -c $OSTCOUNT $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
- }
- rm -rf $TDIR
- setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
- if [[ $OSTCOUNT -gt 1 ]]; then
- $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
- ONESTRIPE=4
- EXTRA=4
- else
- ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
- EXTRA=0
- fi
+ local expected=$NUMDIRS
+ local cmd="$LFS find -c $OSTCOUNT $dir"
+ local nums=$($cmd | wc -l)
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
- CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ [ $nums -eq $expected ] || {
+ $LFS getstripe -R $dir
+ error "'$cmd' wrong: found $nums, expected $expected"
}
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
- CMD="$LFIND -stripe-count +0 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ expected=$((NUMDIRS + onestripe))
+ cmd="$LFS find -stripe-count +0 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] || {
+ $LFS getstripe -R $dir
+ error "'$cmd' wrong: found $nums, expected $expected"
}
- EXPECTED=$ONESTRIPE
- CMD="$LFIND -stripe-count 1 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ expected=$onestripe
+ cmd="$LFS find -stripe-count 1 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] || {
+ $LFS getstripe -R $dir
+ error "'$cmd' wrong: found $nums, expected $expected"
}
- CMD="$LFIND -stripe-count -2 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ cmd="$LFS find -stripe-count -2 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] || {
+ $LFS getstripe -R $dir
+ error "'$cmd' wrong: found $nums, expected $expected"
}
- EXPECTED=0
- CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ expected=0
+ cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] || {
+ $LFS getstripe -R $dir
+ error "'$cmd' wrong: found $nums, expected $expected"
}
}
run_test 56s "check lfs find -stripe-count works"
-test_56t() { # LU-611
- TDIR=$DIR/${tdir}t
+test_56t() { # LU-611 #LU-9369
+ local dir=$DIR/$tdir
- #LU-9369
- setup_56 0 $NUMDIRS
- for i in $(seq 1 $NUMDIRS); do
- $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
+ setup_56 $dir 0 $NUMDIRS
+ for i in $(seq $NUMDIRS); do
+ $LFS setstripe -S 4M $dir/dir$i/$tfile
done
- EXPECTED=$NUMDIRS
- CMD="$LFIND -S 4M $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] || {
- $GETSTRIPE -R $TDIR
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+
+ local expected=$NUMDIRS
+ local cmd="$LFS find -S 4M $dir"
+ local nums=$($cmd | wc -l)
+
+ [ $nums -eq $expected ] || {
+ $LFS getstripe -R $dir
+ error "'$cmd' wrong: found $nums, expected $expected"
}
- rm -rf $TDIR
-
- setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
-
- $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
-
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
- CMD="$LFIND -stripe-size 512k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-
- CMD="$LFIND -stripe-size +320k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
- CMD="$LFIND -stripe-size +200k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-
- CMD="$LFIND -stripe-size -640k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-
- EXPECTED=4
- CMD="$LFIND -stripe-size 256k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-
- CMD="$LFIND -stripe-size -320k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
-
- EXPECTED=0
- CMD="$LFIND -stripe-size 1024k -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ rm -rf $dir
+
+ setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
+
+ $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
+
+ expected=$(((NUMDIRS + 1) * NUMFILES))
+ cmd="$LFS find -stripe-size 512k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ cmd="$LFS find -stripe-size +320k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ expected=$(((NUMDIRS + 1) * NUMFILES + 4))
+ cmd="$LFS find -stripe-size +200k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ cmd="$LFS find -stripe-size -640k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ expected=4
+ cmd="$LFS find -stripe-size 256k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ cmd="$LFS find -stripe-size -320k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ expected=0
+ cmd="$LFS find -stripe-size 1024k -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
}
run_test 56t "check lfs find -stripe-size works"
test_56u() { # LU-611
- TDIR=$DIR/${tdir}u
- setup_56 $NUMFILES $NUMDIRS "-i 0"
+ local dir=$DIR/$tdir
+
+ setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
if [[ $OSTCOUNT -gt 1 ]]; then
- $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
- ONESTRIPE=4
+ $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
+ onestripe=4
else
- ONESTRIPE=0
+ onestripe=0
fi
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
- CMD="$LFIND -stripe-index 0 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ local expected=$(((NUMDIRS + 1) * NUMFILES))
+ local cmd="$LFS find -stripe-index 0 -type f $dir"
+ local nums=$($cmd | wc -l)
- EXPECTED=$ONESTRIPE
- CMD="$LFIND -stripe-index 1 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
- CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ expected=$onestripe
+ cmd="$LFS find -stripe-index 1 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
- EXPECTED=0
+ cmd="$LFS find ! -stripe-index 0 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
+
+ expected=0
# This should produce an error and not return any files
- CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
- NUMS=$($CMD 2>/dev/null | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
+ nums=$($cmd 2>/dev/null | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
if [[ $OSTCOUNT -gt 1 ]]; then
- EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
- CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
- NUMS=$($CMD | wc -l)
- [ $NUMS -eq $EXPECTED ] ||
- error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+ expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
+ cmd="$LFS find -stripe-index 0,1 -type f $dir"
+ nums=$($cmd | wc -l)
+ [ $nums -eq $expected ] ||
+ error "'$cmd' wrong: found $nums, expected $expected"
fi
}
run_test 56u "check lfs find -stripe-index works"
test_56v() {
- local MDT_IDX=0
+ local MDT_IDX=0
+ local dir=$DIR/$tdir
- TDIR=$DIR/${tdir}v
- rm -rf $TDIR
- setup_56 $NUMFILES $NUMDIRS
+ setup_56 $dir $NUMFILES $NUMDIRS
- UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
- [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
+ UUID=$(mdtuuid_from_index $MDT_IDX $dir)
+ [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $MDT_IDX"
- for file in $($LFIND -mdt $UUID $TDIR); do
- file_mdt_idx=$($GETSTRIPE -M $file)
- [ $file_mdt_idx -eq $MDT_IDX ] ||
- error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
- done
+ for file in $($LFS find -mdt $UUID $dir); do
+ file_mdt_idx=$($LFS getstripe -M $file)
+ [ $file_mdt_idx -eq $MDT_IDX ] ||
+ error "lfind -mdt $UUID != getstripe -M $file_mdt_idx"
+ done
}
run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
test_56w() {
[[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
- TDIR=$DIR/${tdir}w
+ local dir=$DIR/$tdir
- rm -rf $TDIR || error "remove $TDIR failed"
- setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
+ setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
- local stripe_size
- stripe_size=$($GETSTRIPE -S -d $TDIR) ||
- error "$GETSTRIPE -S -d $TDIR failed"
+ local stripe_size=$($LFS getstripe -S -d $dir) ||
+ error "$LFS getstripe -S -d $dir failed"
stripe_size=${stripe_size%% *}
local file_size=$((stripe_size * OSTCOUNT))
local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
local required_space=$((file_num * file_size))
-
local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
head -n1)
[[ $free_space -le $((required_space / 1024)) ]] &&
- skip_env "need $required_space bytes, have $free_space KB" &&
+ skip_env "need $required_space, have $free_space kbytes" &&
return
local dd_bs=65536
local i
local j
local file
- for i in $(seq 1 $NUMFILES); do
- file=$TDIR/file$i
+
+ for i in $(seq $NUMFILES); do
+ file=$dir/file$i
yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
error "write data into $file failed"
done
- for i in $(seq 1 $NUMDIRS); do
- for j in $(seq 1 $NUMFILES); do
- file=$TDIR/dir$i/file$j
+ for i in $(seq $NUMDIRS); do
+ for j in $(seq $NUMFILES); do
+ file=$dir/dir$i/file$j
yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
error "write data into $file failed"
done
# $LFS_MIGRATE will fail if hard link migration is unsupported
if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
- createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
- error "creating links to $TDIR/dir1/file1 failed"
+ createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
+ error "creating links to $dir/dir1/file1 failed"
fi
local expected=-1
+
[[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
# lfs_migrate file
- local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
+ local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
+
echo "$cmd"
eval $cmd || error "$cmd failed"
- check_stripe_count $TDIR/file1 $expected
+ check_stripe_count $dir/file1 $expected
if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
then
# lfs_migrate file onto OST 0 if it is on OST 1, or onto
# OST 1 if it is on OST 0. This file is small enough to
# be on only one stripe.
- file=$TDIR/migr_1_ost
+ file=$dir/migr_1_ost
dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
error "write data into $file failed"
local obdidx=$($LFS getstripe -i $file)
local oldmd5=$(md5sum $file)
local newobdidx=0
+
[[ $obdidx -eq 0 ]] && newobdidx=1
cmd="$LFS migrate -i $newobdidx $file"
echo $cmd
eval $cmd || error "$cmd failed"
+
local realobdix=$($LFS getstripe -i $file)
local newmd5=$(md5sum $file)
+
[[ $newobdidx -ne $realobdix ]] &&
- error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
+ error "new OST is different (was=$obdidx, "\
+ "wanted=$newobdidx, got=$realobdix)"
[[ "$oldmd5" != "$newmd5" ]] &&
error "md5sum differ: $oldmd5, $newmd5"
fi
- # lfs_migrate dir
- cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
- echo "$cmd"
- eval $cmd || error "$cmd failed"
+ # lfs_migrate dir
+ cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
+ echo "$cmd"
+ eval $cmd || error "$cmd failed"
- for j in $(seq 1 $NUMFILES); do
- check_stripe_count $TDIR/dir1/file$j $expected
- done
+ for j in $(seq $NUMFILES); do
+ check_stripe_count $dir/dir1/file$j $expected
+ done
- # lfs_migrate works with lfs find
- cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
- $LFS_MIGRATE -y -c $expected"
- echo "$cmd"
- eval $cmd || error "$cmd failed"
+ # lfs_migrate works with lfs find
+ cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
+ $LFS_MIGRATE -y -c $expected"
+ echo "$cmd"
+ eval $cmd || error "$cmd failed"
- for i in $(seq 2 $NUMFILES); do
- check_stripe_count $TDIR/file$i $expected
- done
- for i in $(seq 2 $NUMDIRS); do
- for j in $(seq 1 $NUMFILES); do
- check_stripe_count $TDIR/dir$i/file$j $expected
- done
- done
+ for i in $(seq 2 $NUMFILES); do
+ check_stripe_count $dir/file$i $expected
+ done
+ for i in $(seq 2 $NUMDIRS); do
+ for j in $(seq $NUMFILES); do
+ check_stripe_count $dir/dir$i/file$j $expected
+ done
+ done
}
run_test 56w "check lfs_migrate -c stripe_count works"
+test_56wb() {
+ local file1=$DIR/$tdir/file1
+ local create_pool=false
+ local initial_pool=$($LFS getstripe -p $DIR)
+ local pool_list=()
+ local pool=""
+
+ echo -n "Creating test dir..."
+ test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
+ echo "done."
+
+ echo -n "Creating test file..."
+ touch $file1 || error "cannot create file"
+ echo "done."
+
+ echo -n "Detecting existing pools..."
+ while IFS='' read thispool; do
+ pool_list+=("$thispool")
+ done < <($LFS pool_list $MOUNT | awk -F '.' 'NR>=2 { print $2 }')
+
+ if [ ${#pool_list[@]} -gt 0 ]; then
+ echo "${pool_list[@]}"
+ for thispool in "${pool_list[@]}"; do
+ if [[ -z "$initial_pool" ||
+ "$initial_pool" != "$thispool" ]]; then
+ pool="$thispool"
+ echo "Using existing pool '$pool'"
+ break
+ fi
+ done
+ else
+ echo "none detected."
+ fi
+ if [ -z "$pool" ]; then
+ pool=${POOL:-testpool}
+ [ "$initial_pool" = "$pool" ] && pool="testpool2"
+ echo -n "Creating pool '$pool'..."
+ create_pool=true
+ pool_add $pool &> /dev/null ||
+ error "pool_add failed"
+ echo "done."
+
+ echo -n "Adding target to pool..."
+ pool_add_targets $pool 0 0 1 &> /dev/null ||
+ error "pool_add_targets failed"
+ echo "done."
+ fi
+
+ echo -n "Setting pool using -p option..."
+ $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
+ error "migrate failed rc = $?"
+ echo "done."
+
+ echo -n "Verifying test file is in pool after migrating..."
+ [ "$($LFS getstripe -p $file1)" = $pool ] ||
+ error "file was not migrated to pool $pool"
+ echo "done."
+
+ echo -n "Removing test file from pool '$pool'..."
+ $LFS migrate $file1 &> /dev/null ||
+ error "cannot remove from pool"
+ [ "$($LFS getstripe -p $file1)" ] &&
+ error "pool still set"
+ echo "done."
+
+ echo -n "Setting pool using --pool option..."
+ $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
+ error "migrate failed rc = $?"
+ echo "done."
+
+ # Clean up
+ rm -f $file1
+ if $create_pool; then
+ destroy_test_pools 2> /dev/null ||
+ error "destroy test pools failed"
+ fi
+}
+run_test 56wb "check lfs_migrate pool support"
+
+test_56wc() {
+ local file1="$DIR/$tdir/file 1"
+
+ echo -n "Creating test dir..."
+ test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
+ $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
+ error "cannot set stripe"
+ echo "done"
+
+ echo -n "Setting initial stripe for test file..."
+ $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
+ error "cannot set stripe"
+ [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
+ error "stripe size not set"
+ echo "done."
+
+ # File currently set to -S 512K -c 1
+
+ # Ensure -c and -S options are rejected when -R is set
+ echo -n "Verifying incompatible options are detected..."
+ $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
+ error "incompatible -c and -R options not detected"
+ $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
+ error "incompatible -S and -R options not detected"
+ echo "done."
+
+ # Ensure unrecognized options are passed through to 'lfs migrate'
+ echo -n "Verifying -S option is passed through to lfs migrate..."
+ $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
+ error "migration failed"
+ [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
+ error "file was not restriped"
+ echo "done."
+
+ # File currently set to -S 1M -c 1
+
+ # Ensure long options are supported
+ echo -n "Verifying long options supported..."
+ $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
+ error "long option without argument not supported"
+ $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
+ error "long option with argument not supported"
+ [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
+ error "file not restriped with --stripe-size option"
+ echo "done."
+
+ # File currently set to -S 512K -c 1
+
+ if [ "$OSTCOUNT" -gt 1 ]; then
+ echo -n "Verifying explicit stripe count can be set..."
+ $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
+ error "migrate failed"
+ [ $($LFS getstripe -c "$file1") -eq 2 ] ||
+ error "file not restriped to explicit count"
+ echo "done."
+ fi
+
+ # File currently set to -S 512K -c 1 or -S 512K -c 2
+
+ # Ensure parent striping is used if -R is set, and no stripe
+ # count or size is specified
+ echo -n "Setting stripe for parent directory..."
+ $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
+ error "cannot set stripe"
+ echo "done."
+
+ echo -n "Verifying restripe option uses parent stripe settings..."
+ $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
+ error "migrate failed"
+ [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
+ error "file not restriped to parent settings"
+ [ $($LFS getstripe -c "$file1") -eq 1 ] ||
+ error "file not restriped to parent settings"
+ echo "done."
+
+ # File currently set to -S 1M -c 1
+
+ # Ensure striping is preserved if -R is not set, and no stripe
+ # count or size is specified
+ echo -n "Verifying striping size preserved when not specified..."
+ $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
+ error "cannot set stripe on parent directory"
+ $LFS_MIGRATE -y "$file1" &> /dev/null ||
+ error "migrate failed"
+ [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
+ error "file was restriped"
+ echo "done."
+
+ # Ensure file name properly detected when final option has no argument
+ echo -n "Verifying file name properly detected..."
+ $LFS_MIGRATE -y "$file1" &> /dev/null ||
+ error "file name interpreted as option argument"
+ echo "done."
+
+ # Clean up
+ rm -f "$file1"
+}
+run_test 56wc "check unrecognized options for lfs_migrate are passed through"
+
+test_56wd() {
+ [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+ local file1=$DIR/$tdir/file1
+
+ echo -n "Creating test dir..."
+ test_mkdir $DIR/$tdir || error "cannot create dir"
+ echo "done."
+
+ echo -n "Creating test file..."
+ touch $file1
+ echo "done."
+
+ # Ensure 'lfs migrate' will fail by using a non-existent option,
+ # and make sure rsync is not called to recover
+ echo -n "Make sure --no-rsync option works..."
+ $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
+ grep -q 'refusing to fall back to rsync' ||
+ error "rsync was called with --no-rsync set"
+ echo "done."
+
+ # Ensure rsync is called without trying 'lfs migrate' first
+ echo -n "Make sure --rsync option works..."
+ $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
+ grep -q 'falling back to rsync' &&
+ error "lfs migrate was called with --rsync set"
+ echo "done."
+
+ echo -n "Make sure --rsync and --no-rsync options are exclusive..."
+ $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
+ grep -q 'at the same time' ||
+ error "--rsync and --no-rsync accepted concurrently"
+ echo "done."
+
+ # Clean up
+ rm -f $file1
+}
+run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
+
test_56x() {
check_swap_layouts_support && return 0
[[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
- local dir0=$DIR/$tdir
+ local dir=$DIR/$tdir
local ref1=/etc/passwd
- local file1=$dir0/file1
+ local file1=$dir/file1
- test_mkdir $dir0 || error "creating dir $dir0"
+ test_mkdir $dir || error "creating dir $dir"
$LFS setstripe -c 2 $file1
cp $ref1 $file1
$LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
check_swap_layouts_support && return 0
[[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
- local dir0=$DIR/$tdir/$testnum
- test_mkdir -p $dir0
+ local dir=$DIR/$tdir/$testnum
+
+ test_mkdir -p $dir
local ref1=/etc/passwd
- local file1=$dir0/file1
+ local file1=$dir/file1
$LFS setstripe -c 2 $file1
cp $ref1 $file1
$LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
+
local stripe=$($LFS getstripe -c $file1)
+
[[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
error "cannot get fid for file $file1"
for i in $(seq 2 $total_count); do
local fid2=$($LFS getstripe -F $dir/file$i)
+
[ "$fid2" == "$fid" ] ||
error "migrated hard link has mismatched FID"
done
# also be migrated
local actual=$(grep -c 'done migrate' <<< "$migrate_out")
local expected=$(($uniq_count + 1))
+
[ "$actual" -eq "$expected" ] ||
error "hard links individually migrated ($actual != $expected)"
# make sure the correct number of hard links are present
local hardlinks=$(stat -c '%h' "$file1")
+
[ $hardlinks -eq $total_count ] ||
error "num hard links $hardlinks != $total_count"
echo "done"
}
test_56xb() {
- local dir0="$DIR/$tdir"
+ local dir="$DIR/$tdir"
- test_mkdir "$dir0" || error "cannot create dir $dir0"
+ test_mkdir "$dir" || error "cannot create dir $dir"
echo "testing lfs migrate mode when all links fit within xattrs"
- LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
+ LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
echo "testing rsync mode when all links fit within xattrs"
- LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
+ LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
echo "testing lfs migrate mode when all links do not fit within xattrs"
- LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
+ LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
echo "testing rsync mode when all links do not fit within xattrs"
- LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
+ LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
# clean up
- rm -rf $dir0
+ rm -rf $dir
}
run_test 56xb "lfs migration hard link support"
return
local res=""
- local dir0=$DIR/$tdir/$testnum
- test_mkdir -p $dir0
- local f1=$dir0/file1
- local f2=$dir0/file2
+ local dir=$DIR/$tdir
+ local f1=$dir/file1
+ local f2=$dir/file2
+ test_mkdir -p $dir || error "creating dir $dir"
touch $f1 || error "creating std file $f1"
$MULTIOP $f2 H2c || error "creating released file $f2"
# a directory can be raid0, so ask only for files
- res=$($LFIND $dir0 -L raid0 -type f | wc -l)
+ res=$($LFS find $dir -L raid0 -type f | wc -l)
[[ $res == 2 ]] || error "search raid0: found $res files != 2"
- res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
+ res=$($LFS find $dir \! -L raid0 -type f | wc -l)
[[ $res == 0 ]] || error "search !raid0: found $res files != 0"
# only files can be released, so no need to force file search
- res=$($LFIND $dir0 -L released)
+ res=$($LFS find $dir -L released)
[[ $res == $f2 ]] || error "search released: found $res != $f2"
- res=$($LFIND $dir0 \! -L released)
+ res=$($LFS find $dir -type f \! -L released)
[[ $res == $f1 ]] || error "search !released: found $res != $f1"
-
}
run_test 56y "lfs find -L raid0|released"
# errors out
# - If errors are encountered during the search, it should not terminate
# early
+ local dir=$DIR/$tdir
local i
- test_mkdir $DIR/$tdir
+
+ test_mkdir $dir
for i in d{0..9}; do
- test_mkdir $DIR/$tdir/$i
+ test_mkdir $dir/$i
done
- touch $DIR/$tdir/d{0..9}/$tfile
- $LFS find $DIR/non_existent_dir $DIR/$tdir &&
+ touch $dir/d{0..9}/$tfile
+ $LFS find $DIR/non_existent_dir $dir &&
error "$LFS find did not return an error"
# Make a directory unsearchable. This should NOT be the last entry in
# directory order. Arbitrarily pick the 6th entry
- chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
- local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
+ chmod 700 $($LFS find $dir -type d | sed '6!d')
+
+ local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
+
# The user should be able to see 10 directories and 9 files
[ $count == 19 ] || error "$LFS find did not continue after error"
}
test_56aa() { # LU-5937
[ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
- mkdir $DIR/$tdir
- $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
+ local dir=$DIR/$tdir
+
+ mkdir $dir
+ $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
- createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
- local dirs=$(lfs find --size +8k $DIR/$tdir/)
+ createmany -o $dir/striped_dir/${tfile}- 1024
+ local dirs=$(lfs find --size +8k $dir/)
[ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
}
test_56ba() {
# Create composite files with one component
- TDIR=$DIR/$tdir/1Mfiles
- setup_56 5 1 "--component-end 1M"
+ local dir=$DIR/$tdir
+
+ setup_56 $dir/1Mfiles 5 1 "--component-end 1M"
# Create composite files with three components
- TDIR=$DIR/$tdir/2Mfiles
- setup_56 5 2 "-E 2M -E 4M -E 6M"
- TDIR=$DIR/$tdir
+ setup_56 $dir/2Mfiles 5 2 "-E 2M -E 4M -E 6M"
# Create non-composite files
- createmany -o $TDIR/${tfile}- 10
+ createmany -o $dir/${tfile}- 10
+
+ local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
- local nfiles=$($LFIND --component-end 1M --type f $TDIR | wc -l)
[[ $nfiles == 10 ]] ||
error "lfs find -E 1M found $nfiles != 10 files"
- nfiles=$($LFIND ! -E 1M --type f $TDIR | wc -l)
+ nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
[[ $nfiles == 25 ]] ||
error "lfs find ! -E 1M found $nfiles != 25 files"
# All files have a component that starts at 0
- local nfiles=$($LFIND --component-start 0 --type f $TDIR | wc -l)
+ nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
[[ $nfiles == 35 ]] ||
- error "lfs find --component-start 0 found $nfiles != 35 files"
+ error "lfs find --component-start 0 - $nfiles != 35 files"
- nfiles=$($LFIND --component-start 2M --type f $TDIR | wc -l)
+ nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
[[ $nfiles == 15 ]] ||
- error "$LFIND --component-start 2M found $nfiles != 15 files"
+ error "lfs find --component-start 2M - $nfiles != 15 files"
# All files created here have a componenet that does not starts at 2M
- nfiles=$($LFIND ! --component-start 2M --type f $TDIR | wc -l)
+ nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
[[ $nfiles == 35 ]] ||
- error "$LFIND ! --component-start 2M found $nfiles != 35 files"
+ error "lfs find ! --component-start 2M - $nfiles != 35 files"
# Find files with a specified number of components
- local nfiles=$($LFIND --component-count 3 --type f $TDIR | wc -l)
+ local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
[[ $nfiles == 15 ]] ||
- error "lfs find --component-count 3 found $nfiles != 15 files"
+ error "lfs find --component-count 3 - $nfiles != 15 files"
# Remember non-composite files have a component count of zero
- local nfiles=$($LFIND --component-count 0 --type f $TDIR | wc -l)
+ local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
[[ $nfiles == 10 ]] ||
- error "lfs find --component-count 0 found $nfiles != 10 files"
+ error "lfs find --component-count 0 - $nfiles != 10 files"
- nfiles=$($LFIND ! --component-count 3 --type f $TDIR | wc -l)
+ nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
[[ $nfiles == 20 ]] ||
- error "$LFIND ! --component-count 3 found $nfiles != 20 files"
+ error "lfs find ! --component-count 3 - $nfiles != 20 files"
# All files have a flag called "init"
- local nfiles=$($LFIND --component-flags init --type f $TDIR | wc -l)
+ local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
[[ $nfiles == 35 ]] ||
- error "$LFIND --component-flags init found $nfiles != 35 files"
+ error "lfs find --component-flags init - $nfiles != 35 files"
# Multi-component files will have a component not initialized
- local nfiles=$($LFIND ! --component-flags init --type f $TDIR | wc -l)
+ local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
[[ $nfiles == 15 ]] ||
- error "$LFIND !--component-flags init found $nfiles != 15 files"
+ error "lfs find !--component-flags init - $nfiles != 15 files"
- rm -rf $TDIR
+ rm -rf $dir
}
run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
}
run_test 64c "verify grant shrink"
+# this does exactly what osc_request.c:osc_announce_cached() does in
+# order to calculate max amount of grants to ask from server
+want_grant() {
+ local tgt=$1
+
+ local page_size=$(get_page_size client)
+
+ local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
+ local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
+
+ ((rpc_in_flight ++));
+ nrpages=$((nrpages * rpc_in_flight))
+
+ local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
+
+ dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
+
+ [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
+ local undirty=$((nrpages * page_size))
+
+ local max_extent_pages
+ max_extent_pages=$($LCTL get_param osc.${tgt}.import |
+ grep grant_max_extent_size | awk '{print $2}')
+ max_extent_pages=$((max_extent_pages / page_size))
+ local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
+ local grant_extent_tax
+ grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
+ grep grant_extent_tax | awk '{print $2}')
+
+ undirty=$((undirty + nrextents * grant_extent_tax))
+
+ echo $undirty
+}
+
+# this is size of unit for grant allocation. It should be equal to
+# what tgt_grant.c:tgt_grant_chunk() calculates
+grant_chunk() {
+ local tgt=$1
+ local max_brw_size
+ local grant_extent_tax
+
+ max_brw_size=$($LCTL get_param osc.${tgt}.import |
+ grep max_brw_size | awk '{print $2}')
+
+ grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
+ grep grant_extent_tax | awk '{print $2}')
+
+ echo $(((max_brw_size + grant_extent_tax) * 2))
+}
+
+test_64d() {
+ [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
+ skip "OST < 2.10.55 doesn't limit grants enough" && return 0
+
+ local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
+
+ [[ $($LCTL get_param osc.${tgt}.import |
+ grep "connect_flags:.*grant_param") ]] || \
+ { skip "no grant_param connect flag"; return; }
+
+ local olddebug=$($LCTL get_param -n debug 2> /dev/null)
+
+ $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
+
+ local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
+
+ $SETSTRIPE $DIR/$tfile -i 0 -c 1
+ dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
+ ddpid=$!
+
+ while true
+ do
+ local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
+ if [[ $cur_grant -gt $max_cur_granted ]]
+ then
+ kill $ddpid
+ error "cur_grant $cur_grant > $max_cur_granted"
+ fi
+ kill -0 $ddpid
+ [[ $? -ne 0 ]] && break;
+ sleep 2
+ done
+ $LCTL set_param debug="$olddebug" 2> /dev/null || true
+}
+run_test 64d "check grant limit exceed"
+
# bug 1414 - set/get directories' stripe info
test_65a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
test_65j() { # bug6367
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $($LFS getstripe --component-count $MOUNT) -gt 1 ] &&
+ skip "don't delete default PFL layout" && return
sync; sleep 1
# if we aren't already remounting for each test, do so for this test
if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
[[ "$orig_cksum" == "$dump_cksum" ]] ||
error "dump content does not match on Client"
- $check_ost || skip "No need to check cksum dump on OSS"
+ $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
# check cksum dump on OSS
ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
local list=$(comma_list $(osts_nodes))
local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
local brw_size="obdfilter.*.brw_size"
+ local ostver=$(lustre_version_code ost1)
+ local cliver=$(lustre_version_code client)
$LFS setstripe -i 0 -c 1 $DIR/$tfile
local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
- if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) -a \
- $(lustre_version_code client) -ge $(version_code 2.8.52) ]; then
- [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] &&
- suffix="M"
+ if [ $ostver -ge $(version_code 2.8.52) -o \
+ \( $ostver -ge $(version_code 2.7.17) -a \
+ $ostver -lt $(version_code 2.7.50) \) ] &&
+ [ $cliver -ge $(version_code 2.8.52) -o \
+ \( $cliver -ge $(version_code 2.7.17) -a \
+ $cliver -lt $(version_code 2.7.50) \) ]; then
+ [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
if [[ $orig_mb -lt 16 ]]; then
save_lustre_params $osts "$brw_size" > $p
do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
[ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
+test_118n()
+{
+ local begin
+ local end
+
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ remote_ost_nodsh && skip "remote OSTs with nodsh" && return
+
+ # Sleep to avoid a cached response.
+ #define OBD_STATFS_CACHE_SECONDS 1
+ sleep 2
+
+ # Inject a 10 second delay in the OST_STATFS handler.
+ #define OBD_FAIL_OST_STATFS_DELAY 0x242
+ set_nodes_failloc "$(osts_nodes)" 0x242
+
+ begin=$SECONDS
+ stat --file-system $MOUNT > /dev/null
+ end=$SECONDS
+
+ set_nodes_failloc "$(osts_nodes)" 0
+
+ if ((end - begin > 20)); then
+ error "statfs took $((end - begin)) seconds, expected 10"
+ fi
+}
+run_test 118n "statfs() sends OST_STATFS requests in parallel"
+
test_119a() # bug 11737
{
BSIZE=$((512 * 1024))
skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
[ $RC != 0 ] && error "filefrag $fm_file failed"
- filefrag_op=$(filefrag -ve $fm_file |
+ filefrag_op=$(filefrag -ve -k $fm_file |
sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
lun=$($GETSTRIPE -i $fm_file)
error "dd failed on $fm_file"
filefrag -ves $fm_file || error "filefrag $fm_file failed"
- filefrag_op=$(filefrag -ve $fm_file |
+ filefrag_op=$(filefrag -ve -k $fm_file |
sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
last_lun=$(echo $filefrag_op | cut -d: -f5 |
error "dd failed on $fm_file"
filefrag -ves $fm_file || error "filefrag $fm_file failed"
- filefrag_op=$(filefrag -ve $fm_file |
+ filefrag_op=$(filefrag -ve -k $fm_file |
sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
last_lun=$(echo $filefrag_op | cut -d: -f5 |
error "dd failed on $fm_file"
filefrag -ves $fm_file || error "filefrag $fm_file failed"
- filefrag_op=$(filefrag -ve $fm_file |
+ filefrag_op=$(filefrag -ve -k $fm_file |
sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
last_lun=$(echo $filefrag_op | cut -d: -f5 |
done
filefrag -ves $fm_file || error "filefrag $fm_file failed"
- filefrag_op=$(filefrag -ve $fm_file |
+ filefrag_op=$(filefrag -ve -k $fm_file |
sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
last_lun=$(echo $filefrag_op | cut -d: -f5 |
}
run_test 130e "FIEMAP (test continuation FIEMAP calls)"
+test_130f() {
+ filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
+ [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
+ return
+
+ local fm_file=$DIR/$tfile
+ $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
+ error "multiop create with lov_delay_create on $fm_file"
+
+ filefrag -ves $fm_file || error "filefrag $fm_file failed"
+ filefrag_extents=$(filefrag -vek $fm_file |
+ awk '/extents? found/ { print $2 }')
+ if [[ "$filefrag_extents" != "0" ]]; then
+ error "FIEMAP on $fm_file failed; " \
+ "returned $filefrag_extents expected 0"
+ fi
+
+ rm -f $fm_file
+}
+run_test 130f "FIEMAP (unstriped file)"
+
# Test for writev/readv
test_131a() {
rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
echo "proc_dirs='$proc_dirs'"
[ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
find $proc_dirs \
+ -ignore_readdir_race \
-type f \
-not -name force_lbug \
-not -name changelog_mask \
echo "${facet}_proc_dirs='$facet_proc_dirs'"
[ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
do_facet $facet find $facet_proc_dirs \
+ -ignore_readdir_race \
-type f \
-not -name force_lbug \
-not -name changelog_mask \
dot_lustre_fid_permission_check "$fid" $DIR ||
error "dot lustre permission check $fid failed"
+ ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
+
rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
touch $MOUNT/.lustre/file &&
log "cache hits:: before: $BEFORE, after: $AFTER"
fi
- rm -f $file
restore_lustre_params < $p
- rm -f $p
+ rm -f $p $file
}
run_test 156 "Verification of tunables"
}
run_test 160e "changelog negative testing"
+cleanup_160f() {
+ trap 0
+ do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
+ echo "Deregistering changelog client $CL_USER"
+ do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
+ echo "Deregistering changelog client $CL_USER2"
+ do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
+ restore_lustre_params < $save_params
+ rm -f $save_params
+}
+
+test_160f() {
+ # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
+ # should be set by default
+
+ local CL_USERS="mdd.$MDT0.changelog_users"
+ local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
+ local save_params="$TMP/sanity-$TESTNAME.parameters"
+
+ save_lustre_params $SINGLEMDS \
+ "mdd.$MDT0.changelog_max_idle_time" > $save_params
+ save_lustre_params $SINGLEMDS \
+ "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
+ save_lustre_params $SINGLEMDS \
+ "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
+
+ trap cleanup_160f EXIT
+
+ # Create a user
+ CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+ changelog_register -n)
+ echo "Registered as changelog user $CL_USER"
+ CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+ changelog_register -n)
+ echo "Registered as changelog user $CL_USER2"
+ $GET_CL_USERS | grep -q $CL_USER ||
+ error "User $CL_USER not found in changelog_users"
+ $GET_CL_USERS | grep -q $CL_USER2 ||
+ error "User $CL_USER2 not found in changelog_users"
+
+ # generate some changelogs to accumulate
+ mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+ touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
+ touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
+ rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
+
+ # check changelogs have been generated
+ nbcl=$($LFS changelog $MDT0 | wc -l)
+ [[ $nbcl -eq 0 ]] && error "no changelogs found"
+
+ do_facet $SINGLEMDS $LCTL set_param \
+ mdd.$MDT0.changelog_max_idle_time=10
+ do_facet $SINGLEMDS $LCTL set_param \
+ mdd.$MDT0.changelog_min_gc_interval=2
+ do_facet $SINGLEMDS $LCTL set_param \
+ mdd.$MDT0.changelog_min_free_cat_entries=3
+
+ # simulate changelog catalog almost full
+#define OBD_FAIL_CAT_FREE_RECORDS 0x1313
+ do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
+ do_facet $SINGLEMDS $LCTL set_param fail_val=3
+
+ sleep 6
+ USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+ $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
+ USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+ echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
+ [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
+ error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
+ sleep 5
+
+ # generate one more changelog to trigger fail_loc
+ rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
+
+ # ensure gc thread is done
+ wait_update_facet $SINGLEMDS \
+ "ps -e -o comm= | grep chlg_gc_thread" "" 20
+
+ # check user still registered
+ $GET_CL_USERS | grep -q $CL_USER ||
+ error "User $CL_USER not found in changelog_users"
+ # check user2 unregistered
+ $GET_CL_USERS | grep -q $CL_USER2 &&
+ error "User $CL_USER2 still found in changelog_users"
+
+ # check changelogs are present and starting at $USER_REC2 + 1
+ FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
+ echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
+ [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
+ error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
+
+ cleanup_160f
+}
+run_test 160f "changelog garbage collect (timestamped users)"
+
+test_160g() {
+ # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
+ # should be set by default
+
+ local CL_USERS="mdd.$MDT0.changelog_users"
+ local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
+ local save_params="$TMP/sanity-$TESTNAME.parameters"
+
+ save_lustre_params $SINGLEMDS \
+ "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
+ save_lustre_params $SINGLEMDS \
+ "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
+ save_lustre_params $SINGLEMDS \
+ "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
+
+ trap cleanup_160f EXIT
+
+#define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
+ do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
+
+ # Create a user
+ CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+ changelog_register -n)
+ echo "Registered as changelog user $CL_USER"
+ CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+ changelog_register -n)
+ echo "Registered as changelog user $CL_USER2"
+ $GET_CL_USERS | grep -q $CL_USER ||
+ error "User $CL_USER not found in changelog_users"
+ $GET_CL_USERS | grep -q $CL_USER2 ||
+ error "User $CL_USER2 not found in changelog_users"
+
+ # generate some changelogs to accumulate
+ mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+ touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
+ touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
+ rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
+
+ # check changelogs have been generated
+ nbcl=$($LFS changelog $MDT0 | wc -l)
+ [[ $nbcl -eq 0 ]] && error "no changelogs found"
+
+ do_facet $SINGLEMDS $LCTL set_param \
+ mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
+ do_facet $SINGLEMDS $LCTL set_param \
+ mdd.$MDT0.changelog_min_gc_interval=2
+ do_facet $SINGLEMDS $LCTL set_param \
+ mdd.$MDT0.changelog_min_free_cat_entries=3
+
+ # simulate changelog catalog almost full
+#define OBD_FAIL_CAT_FREE_RECORDS 0x1313
+ do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
+ do_facet $SINGLEMDS $LCTL set_param fail_val=3
+
+ USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+ $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
+ USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
+ echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
+ [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
+ error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
+
+ # generate one more changelog to trigger fail_loc
+ rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
+
+ # ensure gc thread is done
+ wait_update_facet $SINGLEMDS \
+ "ps -e -o comm= | grep chlg_gc_thread" "" 20
+
+ # check user still registered
+ $GET_CL_USERS | grep -q $CL_USER ||
+ error "User $CL_USER not found in changelog_users"
+ # check user2 unregistered
+ $GET_CL_USERS | grep -q $CL_USER2 &&
+ error "User $CL_USER2 still found in changelog_users"
+
+ # check changelogs are present and starting at $USER_REC2 + 1
+ FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
+ echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
+ [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
+ error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
+
+ cleanup_160f
+}
+run_test 160g "changelog garbage collect (old users)"
+
test_161a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
test_mkdir -c1 $DIR/$tdir
test_170() {
[ $PARALLEL == "yes" ] && skip "skip parallel run" && return
- $LCTL clear # bug 18514
- $LCTL debug_daemon start $TMP/${tfile}_log_good
- touch $DIR/$tfile
- $LCTL debug_daemon stop
- 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 clear # bug 18514
+ $LCTL debug_daemon start $TMP/${tfile}_log_good
+ touch $DIR/$tfile
+ $LCTL debug_daemon stop
+ 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 > $TMP/${tfile}_log_bad.out 2>&1 ||
error "lctl df log_bad failed"
cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
+
+ lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
}
run_test 184a "Basic layout swap"
$GETSTRIPE -v $DIR/$tfile
local pattern=$($GETSTRIPE -L $DIR/$tfile)
- [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
+ [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
[ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
}
run_test 231b "must not assert on fully utilized OST request buffer"
-test_232() {
+test_232a() {
mkdir -p $DIR/$tdir
+ $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
+
#define OBD_FAIL_LDLM_OST_LVB 0x31c
- $LCTL set_param fail_loc=0x31c
+ do_facet ost1 $LCTL set_param fail_loc=0x31c
# ignore dd failure
dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
- $LCTL set_param fail_loc=0
+ do_facet ost1 $LCTL set_param fail_loc=0
umount_client $MOUNT || error "umount failed"
mount_client $MOUNT || error "mount failed"
+ stop ost1 || error "cannot stop ost1"
+ start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
}
-run_test 232 "failed lock should not block umount"
+run_test 232a "failed lock should not block umount"
+
+test_232b() {
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
+ dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
+ sync
+ cancel_lru_locks osc
+
+ #define OBD_FAIL_LDLM_OST_LVB 0x31c
+ do_facet ost1 $LCTL set_param fail_loc=0x31c
+
+ # ignore failure
+ $LFS data_version $DIR/$tdir/$tfile || true
+
+ do_facet ost1 $LCTL set_param fail_loc=0
+ umount_client $MOUNT || error "umount failed"
+ mount_client $MOUNT || error "mount failed"
+ stop ost1 || error "cannot stop ost1"
+ start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
+}
+run_test 232b "failed data version lock should not block umount"
test_233a() {
[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
touch $DIR/$tdir/$tfile || error "touch failed"
# OBD_FAIL_LLITE_XATTR_ENOMEM
$LCTL set_param fail_loc=0x1405
- # output of the form: attr 2 4 44 3 fc13 x86_64
- V=($(IFS=".-" rpm -q attr))
- if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
- ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
- # attr pre-2.4.44-7 had a bug with rc
- # LU-3703 - SLES 11 and FC13 clients have older attr
- getfattr -n user.attr $DIR/$tdir/$tfile &&
- error "getfattr should have failed with ENOMEM"
- else
- skip "LU-3703: attr version $(getfattr --version) too old"
- fi
+ getfattr -n user.attr $DIR/$tdir/$tfile &&
+ error "getfattr should have failed with ENOMEM"
$LCTL set_param fail_loc=0x0
rm -rf $DIR/$tdir
}
run_test 246 "Read file of size 4095 should return right length"
+cleanup_247() {
+ local submount=$1
+
+ trap 0
+ umount_client $submount
+ rmdir $submount
+}
+
test_247a() {
lctl get_param -n mdc.$FSNAME-MDT0000*.import |
grep -q subtree ||
mkdir -p $submount || error "mkdir $submount failed"
FILESET="$FILESET/$tdir" mount_client $submount ||
error "mount $submount failed"
+ trap "cleanup_247 $submount" EXIT
echo foo > $submount/$tfile || error "write $submount/$tfile failed"
[ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
error "read $MOUNT/$tdir/$tfile failed"
- umount_client $submount || error "umount $submount failed"
- rmdir $submount
+ cleanup_247 $submount
}
run_test 247a "mount subdir as fileset"
mkdir -p $MOUNT/$tdir/dir1
mkdir -p $submount || error "mkdir $submount failed"
+ trap "cleanup_247 $submount" EXIT
FILESET="$FILESET/$tdir" mount_client $submount ||
error "mount $submount failed"
local fid=$($LFS path2fid $MOUNT/)
$LFS fid2path $submount $fid && error "fid2path should fail"
- umount_client $submount || error "umount $submount failed"
- rmdir $submount
+ cleanup_247 $submount
}
run_test 247c "running fid2path outside root"
mkdir -p $submount || error "mkdir $submount failed"
FILESET="$FILESET/$tdir" mount_client $submount ||
error "mount $submount failed"
+ trap "cleanup_247 $submount" EXIT
local fid=$($LFS path2fid $submount/dir1)
$LFS fid2path $submount $fid || error "fid2path should succeed"
- umount_client $submount || error "umount $submount failed"
- rmdir $submount
+ cleanup_247 $submount
}
run_test 247d "running fid2path inside root"
### Data-on-MDT sanity tests ###
test_270a() {
+
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
# create DoM file
local dom=$DIR/$tdir/dom_file
local tmp=$DIR/$tdir/tmp_file
$LFS setstripe -E 1M -L mdt $dom ||
error "Can't create DoM layout"
- [ $($LFS getstripe -L $dom) == 100 ] || error "bad pattern"
+ [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
[ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
[ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
run_test 270a "DoM: basic functionality tests"
test_270b() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
local dom=$DIR/$tdir/dom_file
local max_size=1048576
run_test 270b "DoM: maximum size overflow checks for DoM-only file"
test_270c() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
mkdir -p $DIR/$tdir
$LFS setstripe -E 1024K -L mdt $DIR/$tdir
# check files inherit DoM EA
touch $DIR/$tdir/first
- [ $($GETSTRIPE -L $DIR/$tdir/first) == 100 ] ||
+ [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
error "bad pattern"
[ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
error "bad stripe count"
# check directory inherits DoM EA and uses it as default
mkdir $DIR/$tdir/subdir
touch $DIR/$tdir/subdir/second
- [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == 100 ] ||
+ [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
error "bad pattern in sub-directory"
[ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
error "bad stripe count in sub-directory"
run_test 270c "DoM: DoM EA inheritance tests"
test_270d() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
mkdir -p $DIR/$tdir
$LFS setstripe -E 1024K -L mdt $DIR/$tdir
touch $DIR/$tdir/subdir/f2
[ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
error "wrong default striping in file 2"
- [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == 1 ] ||
+ [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
error "bad pattern in file 2"
return 0
}
run_test 270d "DoM: change striping from DoM to RAID0"
test_270e() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
mkdir -p $DIR/$tdir/dom
mkdir -p $DIR/$tdir/norm
DOMFILES=20
createmany -o $DIR/$tdir/norm/norm- $NORMFILES
# find DoM files by layout
- NUM=$($LFIND -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
+ NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
[ $NUM -eq $DOMFILES ] ||
error "lfs find -L: found $NUM, expected $DOMFILES"
echo "Test 1: lfs find 20 DOM files by layout: OK"
# there should be 1 dir with default DOM striping
- NUM=$($LFIND -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
+ NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
[ $NUM -eq 1 ] ||
error "lfs find -L: found $NUM, expected 1 dir"
echo "Test 2: lfs find 1 DOM dir by layout: OK"
# find DoM files by stripe size
- NUM=$($LFIND -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
+ NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
[ $NUM -eq $DOMFILES ] ||
error "lfs find -S: found $NUM, expected $DOMFILES"
echo "Test 4: lfs find 20 DOM files by stripe size: OK"
# find files by stripe offset except DoM files
- NUM=$($LFIND -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
+ NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
[ $NUM -eq $NORMFILES ] ||
error "lfs find -i: found $NUM, expected $NORMFILES"
echo "Test 5: lfs find no DOM files by stripe index: OK"
run_test 270e "DoM: lfs find with DoM files test"
test_270f() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
local mdtname=${FSNAME}-MDT0000-mdtlov
local dom=$DIR/$tdir/dom_file
local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
run_test 270f "DoM: maximum DoM stripe size checks"
test_271a() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
local dom=$DIR/$tdir/dom
mkdir -p $DIR/$tdir
run_test 271a "DoM: data is cached for read after write"
test_271b() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
local dom=$DIR/$tdir/dom
mkdir -p $DIR/$tdir
run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
test_271ba() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
local dom=$DIR/$tdir/dom
mkdir -p $DIR/$tdir
# test to be enabled with lock_convert
skip "skipped until lock convert will be implemented" && return
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+ skip "Need MDS version at least 2.10.55" && return
+
local dom=$DIR/$tdir/dom
mkdir -p $DIR/$tdir
}
run_test 314 "OSP shouldn't fail after last_rcvd update failure"
+test_315() { # LU-618
+ local file=$DIR/$tfile
+ rm -f $file
+
+ $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
+ $MULTIOP $file oO_RDONLY:r4096000_c &
+ PID=$!
+
+ sleep 2
+
+ local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
+ kill -USR1 $PID
+
+ [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
+ rm -f $file
+}
+run_test 315 "read should be accounted"
+
test_fake_rw() {
local read_write=$1
if [ "$read_write" = "write" ]; then
wait
- [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
+ [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
rm -f $tfile $file1 $file2
}
[ $size -eq $def_stripe_size ] ||
error "$f stripe size $size != $def_stripe_size"
local pool=$($GETSTRIPE -p $f)
- [ "#$pool" == "#" ] || error "$f pool $pool is set"
+ [ $pool == $test_pool ] || error "$f pool $pool isn't set"
done
}
run_test 411 "Slab allocation error with cgroup does not LBUG"
+test_412() {
+ [ $MDSCOUNT -lt 2 ] &&
+ skip "We need at least 2 MDTs for this test" && return
+
+ if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
+ skip "Need server version at least 2.10.55" & exit 0
+ fi
+
+ $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
+ error "mkdir failed"
+ $LFS getdirstripe $DIR/$tdir
+ stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
+ [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
+ error "expect $((MDSCOUT - 1)) get $stripe_index"
+ stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
+ [ $stripe_count -eq 2 ] ||
+ error "expect 2 get $stripe_count"
+}
+run_test 412 "mkdir on specific MDTs"
+
prep_801() {
[[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
[[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
}
run_test 802 "simulate readonly device"
+test_803() {
+ [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
+ skip "MDS needs to be newer than 2.10.54" && return
+
+ mkdir -p $DIR/$tdir
+ # Create some objects on all MDTs to trigger related logs objects
+ for idx in $(seq $MDSCOUNT); do
+ $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
+ $DIR/$tdir/dir${idx} ||
+ error "Fail to create $DIR/$tdir/dir${idx}"
+ done
+
+ sync; sleep 5
+ echo "before create:"
+ $LFS df -i $MOUNT
+ local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
+
+ for ((i=0; i<10; i++)); do
+ $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
+ error "Fail to create $DIR/$tdir/foo$i"
+ done
+
+ sync; sleep 5
+ echo "after create:"
+ $LFS df -i $MOUNT
+ local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
+
+ [ $after_used -ge $((before_used + 10)) ] ||
+ error "before ($before_used) + 10 > after ($after_used)"
+
+ for ((i=0; i<10; i++)); do
+ rm -rf $DIR/$tdir/foo$i ||
+ error "Fail to remove $DIR/$tdir/foo$i"
+ done
+
+ wait_delete_completed
+ echo "after unlink:"
+ $LFS df -i $MOUNT
+ before_used=$after_used
+ after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
+
+ [ $after_used -le $((before_used - 8)) ] ||
+ error "before ($before_used) - 8 < after ($after_used)"
+}
+run_test 803 "verify agent object for remote object"
+
+test_804() {
+ [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
+ skip "MDS needs to be newer than 2.10.54" && return
+
+ [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+ skip "ldiskfs only test" && return 0
+
+ mkdir -p $DIR/$tdir
+ $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
+ error "Fail to create $DIR/$tdir/dir0"
+
+ local fid=$($LFS path2fid $DIR/$tdir/dir0)
+ local dev=$(mdsdevname 2)
+
+ do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+ grep ${fid} || error "NOT found agent entry for dir0"
+
+ $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
+ error "Fail to create $DIR/$tdir/dir1"
+
+ touch $DIR/$tdir/dir1/foo0 ||
+ error "Fail to create $DIR/$tdir/dir1/foo0"
+ fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
+ local rc=0
+
+ for idx in $(seq $MDSCOUNT); do
+ dev=$(mdsdevname $idx)
+ do_facet mds${idx} \
+ "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+ grep ${fid} && rc=$idx
+ done
+
+ mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
+ error "Fail to rename foo0 to foo1"
+ if [ $rc -eq 0 ]; then
+ for idx in $(seq $MDSCOUNT); do
+ dev=$(mdsdevname $idx)
+ do_facet mds${idx} \
+ "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+ grep ${fid} && rc=$idx
+ done
+ fi
+
+ mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
+ error "Fail to rename foo1 to foo2"
+ if [ $rc -eq 0 ]; then
+ for idx in $(seq $MDSCOUNT); do
+ dev=$(mdsdevname $idx)
+ do_facet mds${idx} \
+ "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
+ grep ${fid} && rc=$idx
+ done
+ fi
+
+ [ $rc -ne 0 ] || error "NOT found agent entry for foo"
+
+ ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
+ error "Fail to link to $DIR/$tdir/dir1/foo2"
+ mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
+ error "Fail to rename foo2 to foo0"
+ unlink $DIR/$tdir/dir1/foo0 ||
+ error "Fail to unlink $DIR/$tdir/dir1/foo0"
+ rm -rf $DIR/$tdir/dir0 ||
+ error "Fail to rm $DIR/$tdir/dir0"
+
+ for idx in $(seq $MDSCOUNT); do
+ dev=$(mdsdevname $idx)
+ rc=0
+
+ stop mds${idx}
+ run_e2fsck $(facet_active_host mds$idx) $dev -n ||
+ rc=$?
+ start mds${idx} $dev $MDS_MOUNT_OPTS ||
+ error "mount mds$idx failed"
+ df $MOUNT > /dev/null 2>&1
+
+ # e2fsck should not return error
+ [ $rc -eq 0 ] ||
+ error "e2fsck detected error on MDT${idx}: rc=$rc"
+ done
+}
+run_test 804 "verify agent entry for remote entry"
+
#
# tests that do cleanup/setup should be run at the end
#