[ "$FSTYPE" != "ldiskfs" ] && skip "can not check trusted.fid FSTYPE=$FSTYPE" && return 0
# check the trusted.fid attribute of the OST objects of the file
- for (( i=0, j=19; i < ${lmm[8]}; i++, j+=4 )); do
+ for (( i=0, j=21; i < ${lmm[8]}; i++, j+=4 )); do
local obdidx=${lmm[$j]}
local devnum=$((obdidx + 1))
local objid=${lmm[$((j+1))]}
remote_ost_nodsh && skip "remote OST with nodsh" && return
mkdir -p $DIR/$tdir
$SETSTRIPE $DIR/$tdir/$tfile-1 -c 1 -o 0 -s 1m ||
- { error "setstripe -c -1 failed"; return 1; }
+ { error "setstripe -c 1 failed"; return 1; }
dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
{ error "dd 1 mb failed"; return 2; }
$SETSTRIPE $DIR/$tdir/$tfile-2 -c -1 -o $(($OSTCOUNT - 1)) -s 1m ||
- { error "setstripe -c 1 failed"; return 3; }
+ { error "setstripe -c -1 failed"; return 3; }
dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
{ error "dd $OSTCOUNT mb failed"; return 4; }
sync
}
run_test 51a "special situations: split htree with empty entry =="
-#export NUMTEST=70000
-# FIXME: I select a relatively small number to do basic test.
-# large number may give panic(). debugging on this is going on.
-export NUMTEST=70
+export NUMTEST=70000
test_51b() {
NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
[ $NUMFREE -lt 21000 ] && \
skip "not enough free inodes ($NUMFREE)" && \
return
- check_kernel_version 40 || NUMTEST=31000
[ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
mkdir -p $DIR/d51b
}
run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
+test_51ba() { # LU-993
+ local BASE=$DIR/d51b
+ # unlink all but 100 subdirectories, then check it still works
+ local LEFT=100
+ local DELETE=$((NUMTEST - LEFT))
+
+ ! [ -d "${BASE}/t-$DELETE" ] && skip "test_51b() not run" && return 0
+
+ # for ldiskfs the nlink count should be 1, but this is OSD specific
+ # and so this is listed for informational purposes only
+ log "nlink before: $(stat -c %h $BASE)"
+ unlinkmany -d $BASE/t- $DELETE ||
+ error "unlink of first $DELETE subdirs failed"
+
+ log "nlink between: $(stat -c %h $BASE)"
+ local FOUND=$(ls -l ${BASE} | wc -l)
+ FOUND=$((FOUND - 1)) # trim the first line of ls output
+ [ $FOUND -ne $LEFT ] &&
+ error "can't find subdirs: found only $FOUND/$LEFT"
+
+ unlinkmany -d $BASE/t- $DELETE $LEFT ||
+ error "unlink of second $LEFT subdirs failed"
+ log "nlink after: $(stat -c %h $BASE)"
+}
+run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
+
test_51bb() {
[ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
mkdir -p $DIR/$tdir
UUID=$(ostuuid_from_index 0 $DIR/$tdir)
OUT=$($LFIND -obd $UUID $DIR/$tdir)
- [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
+ [ "$OUT" ] && error "$LFIND -obd returned directory '$OUT'" || true
}
-run_test 56i "check 'lfs find -ost UUID' skips directories ======="
+run_test 56i "check 'lfs find -obd UUID' skips directories ======="
test_56j() {
setup_56_special $NUMFILES $NUMDIRS
run_test 56r "check lfs find -size works =========================="
+test_56v() {
+ local FIND_MDT_IDX=0
+
+ TDIR=${tdir}g
+ rm -rf $TDIR
+ setup_56 $NUMFILES $NUMDIRS
+
+ UUID=$(mdtuuid_from_index $FIND_MDT_IDX $DIR/$TDIR)
+ for file in $($LFIND -mdt $UUID $DIR/$TDIR); do
+ file_mdt_idx=$($GETSTRIPE -M $file)
+ [ $file_mdt_idx -eq $FIND_MDT_IDX ] ||
+ error "wrong lfind -m not match getstripe -M"
+ done
+}
+run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
+
test_57a() {
# note test will not do anything if MDS is not local
remote_mds_nodsh && skip "remote MDS with nodsh" && return
mkdir -p $DIR/d65
if [ $STRIPECOUNT -le 0 ]; then
sc=1
- elif [ $STRIPECOUNT -gt 160 ]; then
-#LOV_MAX_STRIPE_COUNT is 160
- [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
+ elif [ $STRIPECOUNT -gt 2000 ]; then
+#LOV_MAX_STRIPE_COUNT is 2000
+ [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
else
sc=$(($STRIPECOUNT - 1))
fi
echo "get/set/list trusted.lov xattr ..."
[ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
local testfile=$DIR/$tfile
- $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
+ $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $testfile ||
+ error "setstripe failed"
+ local STRIPECOUNT=$(lfs getstripe -c $testfile) ||
+ error "getstripe failed"
getfattr -d -m "^trusted" $testfile 2> /dev/null | \
grep "trusted.lov" || error "can't get trusted.lov from $testfile"
local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
[ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
- [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
+ [ "$stripe_count" -eq $STRIPECOUNT ] ||
+ error "stripe count $stripe_count != $STRIPECOUNT"
rm -f $DIR/$tfile
}
run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
mkdir -p $DIR/$tdir
chown $RUNAS_ID $DIR/$tdir
local testfile=$DIR/$tdir/$tfile
- $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
+ $RUNAS $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $testfile ||
+ error "setstripe failed"
+ local STRIPECOUNT=$($RUNAS lfs getstripe -c $testfile) ||
+ error "getstripe failed"
$RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
grep "lustre.lov" || error "can't get lustre.lov from $testfile"
local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
[ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
- [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
+ [ $stripe_count -eq $STRIPECOUNT ] ||
+ error "stripe count $stripe_count != $STRIPECOUNT"
}
run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
}
run_test 102f "tar copy files, not keep osts ==========="
-test_102h() { # bug 15777
+grow_xattr() {
+ local xsize=${1:-1024} # in bytes
+ local file=$DIR/$tfile
+
[ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
- skip "must have user_xattr" && return
+ skip "must have user_xattr" && return 0
[ -z "$(which setfattr 2>/dev/null)" ] &&
- skip_env "could not find setfattr" && return
+ skip_env "could not find setfattr" && return 0
+ [ -z "$(which getfattr 2>/dev/null)" ] &&
+ skip_env "could not find getfattr" && return 0
- XBIG=trusted.big
- XSIZE=1024
- touch $DIR/$tfile
- VALUE=datadatadatadatadatadatadatadata
- while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
- VALUE="$VALUE$VALUE"
- done
- log "save $XBIG on $DIR/$tfile"
- setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
- error "saving $XBIG on $DIR/$tfile failed"
- ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
- OSIZE=$(echo $ORIG | wc -c)
- [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
-
- XSML=trusted.sml
- log "save $XSML on $DIR/$tfile"
- setfattr -n $XSML -v val $DIR/$tfile ||
- error "saving $XSML on $DIR/$tfile failed"
- NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
- if [ "$NEW" != "$ORIG" ]; then
- log "orig: $ORIG"
- log "new: $NEW"
- error "$XBIG different after saving $XSML"
- fi
+ touch $file
+
+ local value="$(generate_string $xsize)"
+
+ local xbig=trusted.big
+ log "save $xbig on $file"
+ setfattr -n $xbig -v $value $file ||
+ error "saving $xbig on $file failed"
+
+ local orig=$(get_xattr_value $xbig $file)
+ [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
+
+ local xsml=trusted.sml
+ log "save $xsml on $file"
+ setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
+
+ local new=$(get_xattr_value $xbig $file)
+ [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
+
+ log "grow $xsml on $file"
+ setfattr -n $xsml -v "$value" $file ||
+ error "growing $xsml on $file failed"
+
+ new=$(get_xattr_value $xbig $file)
+ [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
+ log "$xbig still valid after growing $xsml"
- log "grow $XSML on $DIR/$tfile"
- setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
- error "growing $XSML on $DIR/$tfile failed"
- NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
- if [ "$NEW" != "$ORIG" ]; then
- log "orig: $ORIG"
- log "new: $NEW"
- error "$XBIG different after growing $XSML"
- fi
- log "$XBIG still valid after growing $XSML"
rm -f $file
}
+
+test_102h() { # bug 15777
+ grow_xattr 1024
+}
run_test 102h "grow xattr from inside inode to external block"
+test_102ha() {
+ large_xattr_enabled || { skip "large_xattr disabled" && return; }
+ grow_xattr $(max_xattr_size)
+}
+run_test 102ha "grow xattr from inside inode to external inode"
+
test_102i() { # bug 17038
touch $DIR/$tfile
ln -s $DIR/$tfile $DIR/${tfile}link
rmdir ${testdir} || error "rmdir failed"
check_stats $SINGLEMDS "rmdir" 1
+ local testdir1=$DIR/${tdir}/stats_testdir1
+ mkdir -p ${testdir}
+ mkdir -p ${testdir1}
+ touch ${testdir1}/test1
+ mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
+ check_stats $SINGLEMDS "crossdir_rename" 1
+
+ mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
+ check_stats $SINGLEMDS "samedir_rename" 1
+
rm -rf $DIR/${tdir}
}
run_test 133a "Verifying MDT stats ========================================"
do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
- dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=1024k count=1 || error "dd failed"
+ dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
sync
cancel_lru_locks osc
check_stats ost "write" 1
}
run_test 133c "Verifying OST stats ========================================"
+order_2() {
+ local value=$1
+ local orig=$value
+ local order=1
+
+ while [ $value -ge 2 ]; do
+ order=$((order*2))
+ value=$((value/2))
+ done
+
+ if [ $orig -gt $order ]; then
+ order=$((order*2))
+ fi
+ echo $order
+}
+
+size_in_KMGT() {
+ local value=$1
+ local size=('K' 'M' 'G' 'T');
+ local i=0
+ local size_string=$value
+
+ while [ $value -ge 1024 ]; do
+ if [ $i -gt 3 ]; then
+ #T is the biggest unit we get here, if that is bigger,
+ #just return XXXT
+ size_string=${value}T
+ break
+ fi
+ value=$((value >> 10))
+ if [ $value -lt 1024 ]; then
+ size_string=${value}${size[$i]}
+ break
+ fi
+ i=$((i + 1))
+ done
+
+ echo $size_string
+}
+
+get_rename_size() {
+ local size=$1
+ local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+ awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
+ echo $sample
+}
+
+test_133d() {
+ remote_ost_nodsh && skip "remote OST with nodsh" && return
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ local testdir1=$DIR/${tdir}/stats_testdir1
+ local testdir2=$DIR/${tdir}/stats_testdir2
+
+ do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+
+ mkdir -p ${testdir1} || error "mkdir failed"
+ mkdir -p ${testdir2} || error "mkdir failed"
+
+ createmany -o $testdir1/test 512 || error "createmany failed"
+ local testdir1_size=$(ls -l $DIR/${tdir} | \
+ awk '/stats_testdir1/ {print $5}')
+ local testdir2_size=$(ls -l $DIR/${tdir} | \
+ awk '/stats_testdir2/ {print $5}')
+
+ testdir1_size=$(order_2 $testdir1_size)
+ testdir2_size=$(order_2 $testdir2_size)
+
+ testdir1_size=$(size_in_KMGT $testdir1_size)
+ testdir2_size=$(size_in_KMGT $testdir2_size)
+
+ # check samedir rename size
+ mv ${testdir1}/test0 ${testdir1}/test_0
+ local samedir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+ grep 'same_dir')
+ local same_sample=$(get_rename_size $testdir1_size)
+ [ -z "$samedir" ] && error "samedir_rename_size count error"
+ [ $same_sample -eq 1 ] || error "samedir_rename_size count error"
+ echo "Check same dir rename stats success"
+
+ # check crossdir rename size
+ do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+ mv ${testdir1}/test_0 ${testdir2}/test_0
+ local crossdir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+ grep 'crossdir')
+ local src_sample=$(get_rename_size $testdir1_size)
+ local tgt_sample=$(get_rename_size $testdir2_size)
+ [ -z "$crossdir" ] && error "crossdir_rename_size count error"
+ [ $src_sample -eq 1 ] || error "crossdir_rename_size count error"
+ [ $tgt_sample -eq 1 ] || error "crossdir_rename_size count error"
+ echo "Check cross dir rename stats success"
+
+ rm -rf $DIR/${tdir}
+}
+run_test 133d "Verifying rename_stats ========================================"
+
test_140() { #bug-17379
mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
cd $DIR/$tdir || error "Changing to $DIR/$tdir"
}
run_test 221 "make sure fault and truncate race to not cause OOM"
+test_222a () {
+ rm -rf $DIR/$tdir
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir
+ createmany -o $DIR/$tdir/$tfile 10
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
+ $LCTL set_param fail_loc=0x31a
+ ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
+ $LCTL set_param fail_loc=0
+ rm -r $DIR/$tdir
+}
+run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
+
+test_222b () {
+ rm -rf $DIR/$tdir
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir
+ createmany -o $DIR/$tdir/$tfile 10
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
+ $LCTL set_param fail_loc=0x31a
+ rm -r $DIR/$tdir || "AGL for rmdir failed"
+ $LCTL set_param fail_loc=0
+}
+run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
+
+test_223 () {
+ rm -rf $DIR/$tdir
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir
+ createmany -o $DIR/$tdir/$tfile 10
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
+ $LCTL set_param fail_loc=0x31b
+ ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
+ $LCTL set_param fail_loc=0
+ rm -r $DIR/$tdir
+}
+run_test 223 "osc reenqueue if without AGL lock granted ======================="
+
#
# tests that do cleanup/setup should be run at the end
#