}
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() {
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