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() {
}
run_test 102k "setfattr without parameter of value shouldn't cause a crash"
+test_102l() {
+ # LU-532 trusted. xattr is invisible to non-root
+ local testfile=$DIR/$tfile
+
+ touch $testfile
+
+ echo "listxattr as user..."
+ chown $RUNAS_ID $testfile
+ $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
+ grep -q "trusted" &&
+ error "$testfile trusted xattrs are user visible"
+
+ return 0;
+}
+run_test 102l "listxattr filter test =================================="
+
cleanup_test102
run_acl_subtest()
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 ========================================"
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 | \
}
test_215() { # for bugs 18102, 21079, 21517
- local N='(0|[1-9][0-9]*)' # non-negative numeric
- local P='[1-9][0-9]*' # positive numeric
- local I='(0|-?[1-9][0-9]*)' # any numeric (0 | >0 | <0)
- local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
- local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
- local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
+ local N='(0|[1-9][0-9]*)' # non-negative numeric
+ local P='[1-9][0-9]*' # positive numeric
+ local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
+ local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
+ local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
+ local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
local L1 # regexp for 1st line
local L2 # regexp for 2nd line (optional)
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
}
run_test 225b "Metadata survey sanity with stripe_count = 1"
+mcreate_path2fid () {
+ local mode=$1
+ local major=$2
+ local minor=$3
+ local name=$4
+ local desc=$5
+ local path=$DIR/$tdir/$name
+ local fid
+ local rc
+ local fid_path
+
+ $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
+ error "error: cannot create $desc"
+
+ fid=$($LFS path2fid $path)
+ rc=$?
+ [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
+
+ fid_path=$($LFS fid2path $DIR $fid)
+ rc=$?
+ [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
+
+ [ "$path" == "$fid_path" ] || \
+ error "error: fid2path returned \`$fid_path', expected \`$path'"
+}
+
+test_226 () {
+ rm -rf $DIR/$tdir
+ mkdir -p $DIR/$tdir
+
+ mcreate_path2fid 0010666 0 0 fifo "FIFO"
+ mcreate_path2fid 0020666 1 3 null "character special file (null)"
+ mcreate_path2fid 0020666 1 255 none "character special file (no device)"
+ mcreate_path2fid 0040666 0 0 dir "directory"
+ mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
+ mcreate_path2fid 0100666 0 0 file "regular file"
+ mcreate_path2fid 0120666 0 0 link "symbolic link"
+ mcreate_path2fid 0140666 0 0 sock "socket"
+}
+run_test 226 "call path2fid and fid2path on files of all type"
+
#
# tests that do cleanup/setup should be run at the end
#