}
run_test 34g "truncate long file ==============================="
+test_34h() {
+ local gid=10
+ local sz=1000
+
+ dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
+ multiop $DIR/$tfile OG${gid}T${sz}g${gid}c &
+ MULTIPID=$!
+ sleep 2
+
+ if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
+ error "Multiop blocked on ftruncate, pid=$MULTIPID"
+ kill -9 $MULTIPID
+ fi
+ wait $MULTIPID
+ local nsz=`stat -c %s $DIR/$tfile`
+ [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
+}
+run_test 34h "ftruncate file under grouplock should not block"
+
test_35a() {
cp /bin/sh $DIR/f35a
chmod 444 $DIR/f35a
}
run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
+# Get and check the actual stripe count of one file.
+# Usage: check_stripe_count <file> <expected_stripe_count>
+check_stripe_count() {
+ local file=$1
+ local expected=$2
+ local actual
+
+ [[ -z "$file" || -z "$expected" ]] &&
+ error "check_stripe_count: invalid argument!"
+
+ local cmd="$GETSTRIPE -c $file"
+ actual=$($cmd) || error "$cmd failed"
+ actual=${actual%% *}
+
+ if [[ $actual -ne $expected ]]; then
+ [[ $expected -eq -1 ]] ||
+ error "$cmd wrong: found $actual, expected $expected"
+ [[ $actual -eq $OSTCOUNT ]] ||
+ error "$cmd wrong: found $actual, expected $OSTCOUNT"
+ fi
+}
+
+test_56w() {
+ TDIR=$DIR/${tdir}w
+
+ rm -rf $TDIR || error "remove $TDIR failed"
+ setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
+
+ local stripe_size
+ stripe_size=$($GETSTRIPE -S -d $TDIR) ||
+ error "$GETSTRIPE -S -d $TDIR 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.$LOVNAME.kbytesavail)
+ [[ $free_space -le $((required_space / 1024)) ]] &&
+ skip_env "need at least $required_space bytes free space," \
+ "have $free_space kbytes" && return
+
+ local dd_bs=65536
+ local dd_count=$((file_size / dd_bs))
+
+ # write data into the files
+ local i
+ local j
+ local file
+ for i in $(seq 1 $NUMFILES); do
+ file=$TDIR/file$i
+ yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
+ 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
+ yes | dd bs=$dd_bs count=$dd_count of=$file \
+ >/dev/null 2>&1 ||
+ error "write data into $file failed"
+ done
+ done
+
+ local expected=-1
+ [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
+
+ # lfs_migrate file
+ local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
+ echo "$cmd"
+ eval $cmd || error "$cmd failed"
+
+ check_stripe_count $TDIR/file1 $expected
+
+ # lfs_migrate dir
+ cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
+ echo "$cmd"
+ eval $cmd || error "$cmd failed"
+
+ for j in $(seq 1 $NUMFILES); do
+ check_stripe_count $TDIR/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"
+
+ 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
+}
+run_test 56w "check lfs_migrate -c stripe_count works"
+
test_57a() {
# note test will not do anything if MDS is not local
remote_mds_nodsh && skip "remote MDS with nodsh" && return
test_102a() {
local testfile=$DIR/xattr_testfile
- rm -f $testfile
- touch $testfile
+ touch $testfile
[ "$UID" != 0 ] && skip_env "must run as root" && return
[ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
skip_env "could not find setfattr" && return
echo "set/get xattr..."
- setfattr -n trusted.name1 -v value1 $testfile || error
- [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
- grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
+ setfattr -n trusted.name1 -v value1 $testfile || error
+ getfattr -n trusted.name1 $testfile 2> /dev/null |
+ grep "trusted.name1=.value1" ||
+ error "$testfile missing trusted.name1=value1"
- setfattr -n user.author1 -v author1 $testfile || error
- [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
- grep "user.author1"`" == "user.author1=\"author1\"" ] || error
+ setfattr -n user.author1 -v author1 $testfile || error
+ getfattr -n user.author1 $testfile 2> /dev/null |
+ grep "user.author1=.author1" ||
+ error "$testfile missing trusted.author1=author1"
echo "listxattr..."
- setfattr -n trusted.name2 -v value2 $testfile || error
- setfattr -n trusted.name3 -v value3 $testfile || error
- [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
- grep "trusted.name" | wc -l` -eq 3 ] || error
-
-
- setfattr -n user.author2 -v author2 $testfile || error
- setfattr -n user.author3 -v author3 $testfile || error
- [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
- grep "user" | wc -l` -eq 3 ] || error
+ setfattr -n trusted.name2 -v value2 $testfile ||
+ error "$testfile unable to set trusted.name2"
+ setfattr -n trusted.name3 -v value3 $testfile ||
+ error "$testfile unable to set trusted.name3"
+ [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
+ grep "trusted.name" | wc -l) -eq 3 ] ||
+ error "$testfile missing 3 trusted.name xattrs"
+
+ setfattr -n user.author2 -v author2 $testfile ||
+ error "$testfile unable to set user.author2"
+ setfattr -n user.author3 -v author3 $testfile ||
+ error "$testfile unable to set user.author3"
+ [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
+ grep "user.author" | wc -l) -eq 3 ] ||
+ error "$testfile missing 3 user.author xattrs"
echo "remove xattr..."
- setfattr -x trusted.name1 $testfile || error
- getfattr -d -m trusted $testfile 2> /dev/null | \
- grep "trusted.name1" && error || true
+ setfattr -x trusted.name1 $testfile ||
+ error "$testfile error deleting trusted.name1"
+ getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
+ error "$testfile did not delete trusted.name1 xattr"
- setfattr -x user.author1 $testfile || error
- getfattr -d -m user $testfile 2> /dev/null | \
- grep "user.author1" && error || true
+ setfattr -x user.author1 $testfile ||
+ error "$testfile error deleting user.author1"
+ getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
+ error "$testfile did not delete trusted.name1 xattr"
# b10667: setting lustre special xattr be silently discarded
echo "set lustre special xattr ..."
- setfattr -n "trusted.lov" -v "invalid value" $testfile || error
-
- rm -f $testfile
+ setfattr -n "trusted.lov" -v "invalid value" $testfile ||
+ error "$testfile allowed setting trusted.lov"
}
run_test 102a "user xattr test =================================="
run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
compare_stripe_info1() {
- local stripe_index_all_zero=1
+ local stripe_index_all_zero=true
- for num in 1 2 3 4
- do
- for count in `seq 1 $STRIPE_COUNT`
- do
- for offset in `seq 0 $[$STRIPE_COUNT - 1]`
- do
- local size=`expr $STRIPE_SIZE \* $num`
+ for num in 1 2 3 4; do
+ for count in $(seq 1 $STRIPE_COUNT); do
+ for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
+ local size=$((STRIPE_SIZE * num))
local file=file"$num-$offset-$count"
- get_stripe_info client $PWD/$file "$1"
- if [ $stripe_size -ne $size ]; then
- error "$file: different stripe size $stripe_size, expected $size" && return
- fi
- if [ $stripe_count -ne $count ]; then
- error "$file: different stripe count $stripe_count, expected $count" && return
- fi
- if [ $stripe_index -ne 0 ]; then
- stripe_index_all_zero=0
- fi
+ stripe_size=$(lfs getstripe -S $PWD/$file)
+ [ $stripe_size -ne $size ] &&
+ error "$file: size $stripe_size != $size"
+ stripe_count=$(lfs getstripe -c $PWD/$file)
+ # allow fewer stripes to be created, ORI-601
+ [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
+ error "$file: count $stripe_count != $count"
+ stripe_index=$(lfs getstripe -i $PWD/$file)
+ [ $stripe_index -ne 0 ] &&
+ stripe_index_all_zero=false
done
done
done
- [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
+ $stripe_index_all_zero &&
+ error "all files are being extracted starting from OST index 0"
return 0
}
-compare_stripe_info2() {
- for num in 1 2 3 4
- do
- for count in `seq 1 $STRIPE_COUNT`
- do
- for offset in `seq 0 $[$STRIPE_COUNT - 1]`
- do
- local size=`expr $STRIPE_SIZE \* $num`
- local file=file"$num-$offset-$count"
- get_stripe_info client $PWD/$file
- if [ $stripe_size -ne $size ]; then
- error "$file: different stripe size $stripe_size, expected $size" && return
- fi
- if [ $stripe_count -ne $count ]; then
- error "$file: different stripe count $stripe_count, expected $count" && return
- fi
- if [ $stripe_index -ne $offset ]; then
- error "$file: different stripe offset $stripe_index, expected $offset" && return
- fi
- done
- done
- done
-}
-
find_lustre_tar() {
- [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
+ [ -n "$(which tar 2>/dev/null)" ] &&
+ strings $(which tar) | grep -q "lustre" && echo tar
}
test_102d() {
test_133a() {
remote_ost_nodsh && skip "remote OST with nodsh" && return
remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+ do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
+ { skip "MDS doesn't support rename stats"; return; }
local testdir=$DIR/${tdir}/stats_testdir
mkdir -p $DIR/${tdir}
# extra mdt stats verification.
chmod 444 ${testdir}/${tfile} || error "chmod failed"
check_stats $SINGLEMDS "setattr" 1
+ do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
+ ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
+ check_stats $SINGLEMDS "getattr" 1
$LFS df || error "lfs failed"
check_stats $SINGLEMDS "statfs" 1
get_rename_size() {
local size=$1
- local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
+ 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
+ do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
+ { skip "MDS doesn't support rename stats"; return; }
+
local testdir1=$DIR/${tdir}/stats_testdir1
local testdir2=$DIR/${tdir}/stats_testdir2
mkdir -p ${testdir2} || error "mkdir failed"
createmany -o $testdir1/test 512 || error "createmany failed"
- local testdir1_size=$(ls -l $DIR/${tdir} | \
+ local testdir1_size=$(ls -l $DIR/${tdir} |
awk '/stats_testdir1/ {print $5}')
- local testdir2_size=$(ls -l $DIR/${tdir} | \
+ local testdir2_size=$(ls -l $DIR/${tdir} |
awk '/stats_testdir2/ {print $5}')
testdir1_size=$(order_2 $testdir1_size)
testdir1_size=$(size_in_KMGT $testdir1_size)
testdir2_size=$(size_in_KMGT $testdir2_size)
+ echo "source rename dir size: ${testdir1_size}"
+ echo "target rename dir size: ${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 cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
+ eval $cmd || error "$cmd failed"
+ local samedir=$($cmd | 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"
+ [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
echo "Check same dir rename stats success"
- # check crossdir rename size
do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
+
+ # check crossdir rename size
mv ${testdir1}/test_0 ${testdir2}/test_0
- local crossdir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
- grep 'crossdir')
+ eval $cmd || error "$cmd failed"
+ local crossdir=$($cmd | 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"
+ [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
+ [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
echo "Check cross dir rename stats success"
-
rm -rf $DIR/${tdir}
}
run_test 133d "Verifying rename_stats ========================================"
rc=$?
[ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
- echo "open fid $fid"
- diff /etc/hosts $DIR/.lustre/fid/$fid || error "open by fid failed: did not find expected data in file."
+ ffid=$DIR/.lustre/fid/$fid
+
+ echo "stat fid $fid"
+ stat $ffid > /dev/null || error "stat $ffid failed."
+ echo "touch fid $fid"
+ touch $ffid || error "touch $ffid failed."
+ echo "write to fid $fid"
+ cat /etc/hosts > $ffid || error "write $ffid failed."
+ echo "read fid $fid"
+ diff /etc/hosts $ffid || error "read $ffid failed."
+ echo "append write to fid $fid"
+ cat /etc/hosts >> $ffid || error "append write $ffid failed."
+ echo "rename fid $fid"
+ mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
+ touch $DIR/$tfile.1
+ mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
+ rm -f $DIR/$tfile.1
+ echo "truncate fid $fid"
+ $TRUNCATE $ffid 777 || error "truncate $ffid failed."
+ echo "link fid $fid"
+ ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
+ if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
+ echo "setfacl fid $fid"
+ setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
+ echo "getfacl fid $fid"
+ getfacl $ffid >/dev/null || error "getfacl $ffid failed."
+ fi
+ echo "unlink fid $fid"
+ unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
+ echo "mknod fid $fid"
+ mknod $ffid c 1 3 && error "mknod $ffid should fail."
+
+ fid=[0xf00000400:0x1:0x0]
+ ffid=$DIR/.lustre/fid/$fid
+
+ echo "stat non-exist fid $fid"
+ stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
+ echo "write to non-exist fid $fid"
+ cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
+ echo "link new fid $fid"
+ ln $DIR/$tfile $ffid && error "link $ffid should fail."
+
+ mkdir -p $DIR/$tdir
+ touch $DIR/$tdir/$tfile
+ fid=$($LFS path2fid $DIR/$tdir)
+ rc=$?
+ [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
+
+ ffid=$DIR/.lustre/fid/$fid
+
+ echo "ls $fid"
+ ls $ffid > /dev/null || error "ls $ffid failed."
+ echo "touch $fid/$tfile.1"
+ touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
+
+ echo "touch $DIR/.lustre/fid/$tfile"
+ touch $DIR/.lustre/fid/$tfile && \
+ error "touch $DIR/.lustre/fid/$tfile should fail."
- echo "Opening a file by FID succeeded"
+ echo "Open-by-FID succeeded"
}
-run_test 154 "Opening a file by FID"
+run_test 154 "Open-by-FID"
test_155_small_load() {
local temp=$TMP/$tfile
test_160() {
remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
+ { skip "Need MDS version at least 2.2.0"; return; }
USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
echo "Registered as changelog user $USER"
do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
if [ -z ${MDSSURVEY} ]; then
skip_env "mds-survey not found" && return
fi
+ [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
+ { skip "Need MDS version at least 2.2.51"; return; }
local mds=$(facet_host $SINGLEMDS)
local target=$(do_nodes $mds 'lctl dl' | \
if [ -z ${MDSSURVEY} ]; then
skip_env "mds-survey not found" && return
fi
+ [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
+ { skip "Need MDS version at least 2.2.51"; return; }
if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
skip_env "Need to mount OST to test" && return