. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
init_logging
+[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
+ { skip "Need MDS version at least 2.10.56"; exit 0; }
+
[ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
error "\$RUNAS_ID set to 0, but \$UID is also 0!"
check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
value=$(eval $cmd)
+ [ $attr = lcme_flags ] && {
+ local fl
+ local expected_list=$(comma_list $expected)
+ for fl in ${expected_list//,/ }; do
+ echo $value | grep -q $fl || {
+ $getstripe_cmd $tf
+ error "expected flag $fl existing on $comp_id"
+ }
+ done
+ return
+ }
+
[[ $value = $expected ]] || {
$getstripe_cmd $tf
error "verify $attr failed on $tf: $value != $expected"
verify_comp_attrs_with_parent $tf $id
verify_comp_extent $tf $id 0 EOF
- $mirror_cmd -N $tf &> /dev/null &&
- error "mirrored file $tf already exists"
$mirror_cmd -N0 $tf-1 &> /dev/null && error "invalid mirror count 0"
$mirror_cmd -N$((mirror_count + 1)) $tf-1 &> /dev/null &&
error "invalid mirror count $((mirror_count + 1))"
$mirror_cmd -N $tf &> /dev/null && error "$tf does not exist"
# create a non-mirrored file, convert it to a mirrored file and extend
- if false; then
touch $tf || error "touch $tf failed"
$mirror_cmd -N $tf || error "convert and extend $tf failed"
verify_mirror_count $tf 2
verify_comp_attrs_with_parent $tf ${ids[$i]}
verify_comp_extent $tf ${ids[$i]} 0 EOF
done
- fi
+
+ lfsck_verify_pfid $tf || error "PFID is not set"
# create a mirrored file and extend it
$LFS mirror create -N $tf-1 || error "create mirrored file $tf-1 failed"
}
run_test 0f "lfs mirror extend composite layout mirrors"
+test_0g() {
+ local tf=$DIR/$tfile
+
+ $LFS mirror create -N -E 1M -o0 --flags=prefer -E eof -o1 -N -o1 $tf ||
+ error "create mirrored file $tf failed"
+
+ verify_comp_attr lcme_flags $tf 0x10001 prefer
+ verify_comp_attr lcme_flags $tf 0x10002 prefer
+
+ # write to the mirrored file and check primary
+ cp /etc/hosts $tf || error "error writing file '$tf'"
+
+ verify_comp_attr lcme_flags $tf 0x20003 stale
+
+ # resync file and check prefer flag
+ $LFS mirror resync $tf || error "error resync-ing file '$tf'"
+
+ cancel_lru_locks osc
+ $LCTL set_param osc.*.stats=clear
+ cat $tf &> /dev/null || error "error reading file '$tf'"
+
+ # verify that the data was provided by OST1 where mirror 1 resides
+ local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-ffff*.stats |
+ awk '/ost_read/{print $2}')
+ [ -n "$nr_read" ] || error "read was not provided by OST1"
+}
+run_test 0g "lfs mirror create flags support"
+
+test_0h() {
+ local tf=$DIR/$tfile
+
+ $LFS mirror create -N -E 1M --flags=prefer -E eof -N2 $tf ||
+ error "create mirrored file $tf failed"
+
+ verify_comp_attr lcme_flags $tf 0x10001 prefer
+ verify_comp_attr lcme_flags $tf 0x10002 prefer
+
+ # set flags to the first component
+ $LFS setstripe --comp-set -I 0x10001 --comp-flags=^prefer,stale $tf
+
+ verify_comp_attr lcme_flags $tf 0x10001 stale
+ verify_comp_attr lcme_flags $tf 0x10002 prefer
+
+ $LFS setstripe --comp-set -I0x10001 --comp-flags=^stale $tf &&
+ error "clearing 'stale' should fail"
+
+ # write and resync file. It can't resync the file directly because the
+ # file state is still 'ro'
+ cp /etc/hosts $tf || error "error writing file '$tf'"
+ $LFS mirror resync $tf || error "error resync-ing file '$tf'"
+
+ $LFS setstripe --comp-set -I 0x20003 --comp-flags=prefer $tf ||
+ error "error setting flag prefer"
+
+ verify_comp_attr lcme_flags $tf 0x20003 prefer
+}
+run_test 0h "set, clear and test flags for FLR files"
+
test_1() {
local tf=$DIR/$tfile
local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
}
run_test 3 "create components from files located on different MDTs"
+test_4() {
+ local tf=$DIR/$tdir/$tfile
+ local ids=()
+
+ test_mkdir $DIR/$tdir
+
+ # set mirror with setstripe options to directory
+ $LFS mirror create -N2 -E 1M -E eof $DIR/$tdir ||
+ error "set mirror to directory error"
+
+ [ x$($LFS getstripe -v $DIR/$tdir | awk '/lcm_flags/{print $2}') = \
+ x"mirrored" ] || error "failed to create mirrored dir"
+
+ touch $tf
+ verify_mirror_count $tf 2
+
+ ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+ verify_comp_extent $tf ${ids[0]} 0 1048576
+ verify_comp_extent $tf ${ids[1]} 1048576 EOF
+
+ # sub directory should inherit mirror setting from parent
+ test_mkdir $DIR/$tdir/td
+ [ x$($LFS getstripe -v $DIR/$tdir/td | awk '/lcm_flags/{print $2}') = \
+ x"mirrored" ] || error "failed to inherit mirror from parent"
+
+ # mirror extend won't be applied to directory
+ $LFS mirror extend -N2 $DIR/$tdir &&
+ error "expecting mirror extend failure"
+ true
+}
+run_test 4 "Make sure mirror attributes can be inhertied from directory"
+
+test_5() {
+ local tf=$DIR/$tfile
+ local ids=()
+
+ $MULTIOP $tf oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T12345c ||
+ error "failed to create file with non-empty layout"
+ $CHECKSTAT -t file -s 12345 $tf || error "size error: expecting 12345"
+
+ $LFS mirror create -N3 $tf || error "failed to attach mirror layout"
+ verify_mirror_count $tf 3
+
+ $CHECKSTAT -t file -s 12345 $tf ||
+ error "size error after attaching layout "
+}
+run_test 5 "Make sure init size work for mirrored layout"
+
+# LU=10112: disable dom+flr for phase 1
+test_6() {
+ local tf=$DIR/$tfile
+
+ $LFS mirror create -N -E 1M -L mdt -E eof -N -E eof $tf &&
+ error "expect failure to create mirrored file with DoM"
+
+ $LFS mirror create -N -E 1M -E eof -N -E 1M -L mdt -E eof $tf &&
+ error "expect failure to create mirrored file with DoM"
+
+ $LFS setstripe -E 1M -L mdt -E eof $tf
+ $LFS mirror extend -N2 $tf &&
+ error "expect failure to extend mirror with DoM"
+
+ $LFS mirror create -N2 -E 1M -E eof $tf-2
+ $LFS mirror extend -N -f $tf $tf-2 &&
+ error "expect failure to extend mirrored file with DoM extent"
+
+ true
+}
+run_test 6 "DoM and FLR won't co-exist for phase 1"
+
test_21() {
local tf=$DIR/$tfile
local tf2=$DIR/$tfile-2
$LFS setstripe -E EOF -o 1 $tf2
local dd_count=$((RANDOM % 20 + 1))
- dd if=/dev/zero of=$tf bs=1M count=$dd_count
- dd if=/dev/zero of=$tf2 bs=1M count=1 seek=$((dd_count - 1))
- cancel_lru_locks osc
+ dd if=/dev/zero of=$tf bs=1M count=$dd_count oflag=sync
+ dd if=/dev/zero of=$tf2 bs=1M count=1 seek=$((dd_count - 1)) oflag=sync
+
+ # for zfs - sync OST dataset so that du below will return
+ # accurate results
+ [ "$FSTYPE" = "zfs" ] &&
+ do_nodes $(comma_list $(osts_nodes)) "$ZPOOL sync"
local blocks=$(du -kc $tf $tf2 | awk '/total/{print $1}')
error "mirrored file size is not $fsize"
# read file - all OSTs are available
- echo "reading file (data should be provided by ost1)... "
+ echo "reading file (data can be provided by any ost)... "
local rs=$(cat $DIR/$tfile | head -1)
- [[ "$rs" == "ost1" ]] ||
- error "file content error: expected: \"ost1\", actual: \"$rs\""
+ [[ "$rs" == "ost1" || "$rs" == "ost2" ]] ||
+ error "file content error: expected: \"ost1\" or \"ost2\""
# read file again with ost1 failed
stop_osts 1
}
run_test 40 "PFLR rdonly state instantiation check"
+test_41() {
+ local tf=$DIR/$tfile
+
+ rm -f $tf $tf-1
+ $LFS mirror create -N -E2m -E4m -E-1 -N -E1m -E2m -E3m -E-1 $tf ||
+ error "create PFLR file $tf failed"
+ $LFS mirror create -N -E4m -E-1 -N -E2m -E3m -E-1 $tf-1 ||
+ error "create PFLR file $tf-1 failed"
+
+ # file should be in ro status
+ verify_flr_state $tf "ro"
+ verify_flr_state $tf-1 "ro"
+
+ # write data in [0, 2M)
+ dd if=/dev/zero of=$tf bs=1M count=2 conv=notrunc ||
+ error "writing $tf failed"
+ dd if=/dev/zero of=$tf-1 bs=1M count=4 conv=notrunc ||
+ error "writing $tf-1 failed"
+
+ verify_flr_state $tf "wp"
+ verify_flr_state $tf-1 "wp"
+
+ # file should have stale component
+ $LFS getstripe $tf | grep lcme_flags | grep stale > /dev/null ||
+ error "after writing $tf, it does not contain stale component"
+ $LFS getstripe $tf-1 | grep lcme_flags | grep stale > /dev/null ||
+ error "after writing $tf-1, it does not contain stale component"
+
+ $LFS mirror resync $tf $tf-1 || error "mirror resync $tf $tf-1 failed"
+
+ verify_flr_state $tf "ro"
+ verify_flr_state $tf-1 "ro"
+
+ # file should not have stale component
+ $LFS getstripe $tf | grep lcme_flags | grep stale &&
+ error "after resyncing $tf, it contains stale component"
+ $LFS getstripe $tf-1 | grep lcme_flags | grep stale &&
+ error "after resyncing $tf, it contains stale component"
+
+ return 0
+}
+run_test 41 "lfs mirror resync check"
+
+test_42() {
+ [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
+
+ local td=$DIR/$tdir
+ local tf=$td/$tfile
+ local mirror_cmd="$LFS mirror verify"
+ local i
+
+ # create parent directory
+ mkdir $td || error "mkdir $td failed"
+
+ $mirror_cmd &> /dev/null && error "no file name given"
+ $mirror_cmd $tf &> /dev/null && error "cannot stat file $tf"
+ $mirror_cmd $td &> /dev/null && error "$td is not a regular file"
+
+ # create mirrored files
+ $LFS mirror create -N -E 4M -E 10M -E EOF $tf ||
+ error "create mirrored file $tf failed"
+ $LFS mirror create -N -E 2M -E EOF \
+ -N -E 6M -E 8M -E EOF \
+ -N -E 16M -E EOF $tf-1 ||
+ error "create mirrored file $tf-1 failed"
+ $LFS mirror create -N -c 2 -o 1,3 -N -S 4M -c -1 $tf-2 ||
+ error "create mirrored file $tf-2 failed"
+
+ # write data in [0, 10M)
+ for i in $tf $tf-1 $tf-2; do
+ yes | dd of=$i bs=1M count=10 iflag=fullblock conv=notrunc ||
+ error "write $i failed"
+ done
+
+ # resync the mirrored files
+ $LFS mirror resync $tf-1 $tf-2 ||
+ error "resync $tf-1 $tf-2 failed"
+
+ # verify the mirrored files
+ $mirror_cmd $tf-1 $tf-2 ||
+ error "verify $tf-1 $tf-2 failed"
+
+ get_mirror_ids $tf-1
+ $mirror_cmd --only ${mirror_array[0]} $tf-1 &> /dev/null &&
+ error "at least 2 mirror ids needed with '--only' option"
+ $mirror_cmd --only ${mirror_array[0]},${mirror_array[1]} $tf-1 $tf-2 \
+ &> /dev/null &&
+ error "'--only' option cannot be used upon multiple files"
+ $mirror_cmd --only 65534,${mirror_array[0]},65535 $tf-1 &&
+ error "invalid specified mirror ids"
+
+ # change the content of $tf and merge it into $tf-1
+ for i in 6 10; do
+ echo a | dd of=$tf bs=1M seek=$i conv=notrunc ||
+ error "change $tf with seek=$i failed"
+ echo b | dd of=$tf-1 bs=1M seek=$i conv=notrunc ||
+ error "change $tf-1 with seek=$i failed"
+ done
+
+ $LFS mirror resync $tf-1 || error "resync $tf-1 failed"
+ $LFS mirror extend --no-verify -N -f $tf $tf-1 ||
+ error "merge $tf into $tf-1 failed"
+
+ # verify the mirrored files
+ echo "Verify $tf-1 without -v option:"
+ $mirror_cmd $tf-1 &&
+ error "verify $tf-1 should fail" || echo "PASS"
+
+ echo "Verify $tf-1 with -v option:"
+ $mirror_cmd -v $tf-1 &&
+ error "verify $tf-1 should fail"
+
+ get_mirror_ids $tf-1
+ echo "Verify $tf-1 with --only option:"
+ $mirror_cmd -v --only ${mirror_array[1]},${mirror_array[-1]} $tf-1 &&
+ error "verify $tf-1 with mirror ${mirror_array[1]} and" \
+ "${mirror_array[-1]} should fail"
+
+ $mirror_cmd --only ${mirror_array[0]},${mirror_array[1]} $tf-1 ||
+ error "verify $tf-1 with mirror ${mirror_array[0]} and" \
+ "${mirror_array[1]} should succeed"
+
+ # set stale components in $tf-1
+ for i in 0x40002 0x40003; do
+ $LFS setstripe --comp-set -I$i --comp-flags=stale $tf-1 ||
+ error "set stale flag on component $i failed"
+ done
+
+ # verify the mirrored file
+ echo "Verify $tf-1 with stale components:"
+ $mirror_cmd -vvv $tf-1 ||
+ error "verify $tf-1 with stale components should succeed"
+
+ echo "Verify $tf-1 with stale components and --only option:"
+ $mirror_cmd -vvv --only ${mirror_array[1]},${mirror_array[-1]} $tf-1 ||
+ error "verify $tf-1 with mirror ${mirror_array[1]} and" \
+ "${mirror_array[-1]} should succeed"
+}
+run_test 42 "lfs mirror verify"
+
+test_44() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ rm -rf $DIR/$tdir
+ rm -rf $DIR/$tdir-1
+ local tf=$DIR/$tdir/$tfile
+ local tf1=$DIR/$tdir-1/$tfile-1
+
+ $LFS setdirstripe -i 0 -c 1 $DIR/$tdir ||
+ error "create directory failed"
+ $LFS setdirstripe -i 1 -c 1 $DIR/$tdir-1 ||
+ error "create remote directory failed"
+ rm -f $tf $tf1 $tf.mirror~2
+ # create file with 4 mirrors
+ $LFS mirror create -N -E2m -E4m -E-1 -N -E1m -E2m -E3m -E-1 -N2 $tf ||
+ error "create PFLR file $tf failed"
+
+ # file should be in ro status
+ verify_flr_state $tf "ro"
+
+ # write data in [0, 3M)
+ dd if=/dev/urandom of=$tf bs=1M count=3 conv=notrunc ||
+ error "writing $tf failed"
+
+ verify_flr_state $tf "wp"
+
+ # synchronize all mirrors of the file
+ $LFS mirror resync $tf || error "mirror resync $tf failed"
+
+ verify_flr_state $tf "ro"
+
+ # split mirror 1
+ $LFS mirror split --mirror-id 1 -f $tf1 $tf ||
+ error "split to $tf1 failed"
+
+ local idx0=$($LFS getstripe -m $tf)
+ local idx1=$($LFS getstripe -m $tf1)
+
+ [[ x$idx0 == x0 ]] || error "$tf is not on MDT0"
+ [[ x$idx1 == x1 ]] || error "$tf1 is not on MDT1"
+
+ # verify mirror count
+ verify_mirror_count $tf 3
+ verify_mirror_count $tf1 1
+
+ $LFS mirror split --mirror-id 2 $tf ||
+ error "split mirror 2 failed"
+
+ verify_mirror_count $tf 2
+ verify_mirror_count $tf.mirror~2 1
+
+ $LFS mirror split --mirror-id 3 -d $tf ||
+ error "split and delte mirror 3 failed"
+ verify_mirror_count $tf 1
+
+ # verify splitted file contains the same content as the orig file does
+ diff $tf $tf1 || error "splited file $tf1 diffs from $tf"
+ diff $tf $tf.mirror~2 ||
+ error "splited file $tf.mirror~2 diffs from $tf"
+}
+run_test 44 "lfs mirror split check"
+
ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
lock_file=$(mktemp /var/lock/FLR.XXXXXX)
exec 200<>$lock_file
while [ -f $ctrl_file ]; do
- local index=$((RANDOM % ${#options[@]}))
local lock_taken=false
+ local index=$((RANDOM % ${#options[@]}))
+ local cmd="mirror_io resync ${options[$index]}"
+
+ [ "${options[$index]}" = "" ] && cmd="$LFS mirror resync"
[ $((RANDOM % 4)) -eq 0 ] && {
index=0
echo -n "lock to "
}
- echo -n "resync file $tf with '${options[$index]}' .."
+ echo -n "resync file $tf with '$cmd' .."
$lock_taken && flock -x 200
- mirror_io resync ${options[$index]} $tf &> /dev/null &&
- echo "done" || echo "failed"
-
+ $cmd $tf &> /dev/null && echo "done" || echo "failed"
$lock_taken && flock -u 200
sleep 0.$((RANDOM % 8 + 1))
}
run_test 201 "FLR data mover"
+test_202() {
+ [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+
+ local tf=$DIR/$tfile
+ local ids
+
+ $LFS setstripe -E 1M -c 1 $tf
+ ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+ verify_comp_attr stripe-count $tf ${ids[0]} 1
+
+ $LFS setstripe --component-add -E 2M -c -1 $tf
+ ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+ verify_comp_attr stripe-count $tf ${ids[0]} 1
+ verify_comp_attr stripe-count $tf ${ids[1]} -1
+
+ dd if=/dev/zero of=$tf bs=1M count=2
+ ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+ verify_comp_attr stripe-count $tf ${ids[0]} 1
+ verify_comp_attr stripe-count $tf ${ids[1]} $OSTCOUNT
+}
+run_test 202 "lfs setstripe --add-component wide striping"
+
+
complete $SECONDS
check_and_cleanup_lustre
exit_status