LUSTRE=${LUSTRE:-$(dirname $0)/..}
. $LUSTRE/tests/test-framework.sh
-init_test_env $@
+init_test_env "$@"
init_logging
ALWAYS_EXCEPT="$SANITY_FLR_EXCEPT "
-# Bug number for skipped test: LU-11381
-ALWAYS_EXCEPT+=" 201"
+# Bug number for skipped test: LU-14818 LU-11381 LU-14765
+ALWAYS_EXCEPT+=" 6 201 44c "
# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-build_test_filter
+# skip all tests for PPC until we can get sanity-pfl to pass
+if [[ $(uname -m) = ppc64 ]]; then
+ skip "Skip FLR testing for PPC clients"
+fi
-[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
- { skip "Need MDS version at least 2.10.56"; exit 0; }
+if [[ "$ost1_FSTYPE" == "zfs" ]]; then
+ # bug #: LU-1941
+ ALWAYS_EXCEPT+=" 49a "
+fi
-[ $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
+build_test_filter
+
+[[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
+ skip "Need MDS version at least 2.10.56"
check_and_setup_lustre
DIR=${DIR:-$MOUNT}
assert_DIR
-
-assert_DIR
rm -rf $DIR/[Rdfs][0-9]*
+[ $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
+
+
# global array to store mirror IDs
declare -a mirror_array
get_mirror_ids() {
verify_comp_attr_with_parent pool $tf $comp_id
}
+verify_flr_state()
+{
+ local tf=$1
+ local expected_state=$2
+
+ local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }')
+ [ $expected_state = $state ] ||
+ error "expected: $expected_state, actual $state"
+}
+
# command line test cases
test_0a() {
local td=$DIR/$tdir
verify_comp_attr stripe-size $tf ${ids[1]} 4194304
verify_comp_attr stripe-count $tf ${ids[1]} 2
verify_comp_attr stripe-index $tf ${ids[1]} 2
- verify_comp_attr pool $tf ${ids[1]} flash
# verify component ${ids[2]}
verify_comp_attr stripe-size $tf ${ids[2]} 16777216
# LU-11022 - remove mirror by pool name
local=cnt cnt=$($LFS getstripe $tf | grep archive | wc -l)
[ "$cnt" != "1" ] && error "unexpected mirror count $cnt"
- $LFS mirror split --pool archive -d $tf || error "delete mirror"
+ $LFS mirror delete --pool archive $tf || error "delete mirror"
cnt=$($LFS getstripe $tf | grep archive | wc -l)
[ "$cnt" != "0" ] && error "mirror count after removal: $cnt"
fi
verify_comp_attr_with_default stripe-size $tf ${ids[$i]}
verify_comp_attr stripe-count $tf ${ids[$i]} 2
verify_comp_attr stripe-index $tf ${ids[$i]} 1
- verify_comp_attr pool $tf ${ids[$i]} flash
verify_comp_extent $tf ${ids[$i]} 0 4194304
done
# create a mirrored file and extend it
$LFS mirror create -N $tf-1 || error "create mirrored file $tf-1 failed"
$LFS mirror create -N $tf-2 || error "create mirrored file $tf-2 failed"
+ $LFS mirror create -N $tf-3 || error "create mirrored file $tf-3 failed"
- $mirror_cmd -N -S 4M -N -f $tf-2 $tf-1 &> /dev/null &&
- error "setstripe options should not be specified with -f option"
+ $mirror_cmd -N -S 4M -N -f $tf-2 $tf-1 ||
+ error "extend mirror with -f failed"
- $mirror_cmd -N$((mirror_count - 1)) $tf-1 ||
- error "extend mirrored file $tf-1 failed"
- verify_mirror_count $tf-1 $mirror_count
- ids=($($LFS getstripe $tf-1 | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+ $mirror_cmd -N$((mirror_count - 1)) $tf-3 ||
+ error "extend mirrored file $tf-3 failed"
+ verify_mirror_count $tf-3 $mirror_count
+ ids=($($LFS getstripe $tf-3 | awk '/lcme_id/{print $2}' | tr '\n' ' '))
for ((i = 0; i < $mirror_count; i++)); do
- verify_comp_attrs $tf-1 ${ids[$i]}
- verify_comp_extent $tf-1 ${ids[$i]} 0 EOF
+ verify_comp_attrs $tf-3 ${ids[$i]}
+ verify_comp_extent $tf-3 ${ids[$i]} 0 EOF
done
- $mirror_cmd -N $tf-1 &> /dev/null &&
- error "exceeded maximum mirror count $mirror_count" || true
+ $mirror_cmd -N $tf-3 &> /dev/null
+ rc=$?
+ [[ $rc == 34 ]] ||
+ error "exceeded maximum mirror count returns $rc not ERANGE(34)"
}
run_test 0d "lfs mirror extend with -N option"
verify_comp_attr stripe-size $tf ${ids[0]} 33554432
verify_comp_attr stripe-count $tf ${ids[0]} 3
verify_comp_attr stripe-index $tf ${ids[0]} 1
- verify_comp_attr pool $tf ${ids[0]} ssd
# verify component ${ids[1]}
verify_comp_attr stripe-size $tf ${ids[1]} 4194304
verify_comp_attr stripe-count $tf ${ids[1]} 2
verify_comp_attr stripe-index $tf ${ids[1]} 2
- verify_comp_attr pool $tf ${ids[1]} flash
# verify component ${ids[2]}
verify_comp_attr stripe-size $tf ${ids[2]} 16777216
error "create mirrored file $tf failed"
# extend the mirrored file with composite layout mirrors
- $mirror_cmd -N2 -E 4M -c 2 -p flash -i 1 -o 1,3 -E eof -S 4M \
+ $mirror_cmd -N -p archive \
+ -N2 -E 4M -c 2 -p flash -i 1 -o 1,3 -E eof -S 4M \
-N -c -1 -p none \
-N3 -E 512M -S 16M -p archive -E -1 -i -1 -c -1 $tf ||
error "extend mirrored file $tf failed"
- verify_mirror_count $tf 7
+ verify_mirror_count $tf 8
ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
# verify component ${ids[0]}
verify_comp_attr pool $tf ${ids[1]} ssd
verify_comp_extent $tf ${ids[1]} 33554432 EOF
- # verify components ${ids[2]} and ${ids[4]}
- for i in 2 4; do
+ # verify component ${ids[2]}
+ verify_comp_attr stripe-size $tf ${ids[0]} 16777216
+ verify_comp_attr_with_default stripe-count $tf ${ids[2]}
+ verify_comp_attr pool $tf ${ids[2]} archive
+ verify_comp_extent $tf ${ids[2]} 0 EOF
+
+ # verify components ${ids[3]} and ${ids[5]}
+ for i in 3 5; do
verify_comp_attr_with_default stripe-size $tf ${ids[$i]}
verify_comp_attr stripe-count $tf ${ids[$i]} 2
verify_comp_attr stripe-index $tf ${ids[$i]} 1
- verify_comp_attr pool $tf ${ids[$i]} flash
verify_comp_extent $tf ${ids[$i]} 0 4194304
done
- # verify components ${ids[3]} and ${ids[5]}
- for i in 3 5; do
+ # verify components ${ids[4]} and ${ids[6]}
+ for i in 4 6; do
verify_comp_attr stripe-size $tf ${ids[$i]} 4194304
verify_comp_attr stripe-count $tf ${ids[$i]} 2
verify_comp_attr pool $tf ${ids[$i]} flash
verify_comp_extent $tf ${ids[$i]} 4194304 EOF
done
- # verify component ${ids[6]}
- verify_comp_attr stripe-size $tf ${ids[6]} 4194304
- verify_comp_attr stripe-count $tf ${ids[6]} $OSTCOUNT
- verify_comp_attr_with_parent pool $tf ${ids[6]}
- verify_comp_extent $tf ${ids[6]} 0 EOF
+ # verify component ${ids[7]}
+ verify_comp_attr stripe-size $tf ${ids[7]} 4194304
+ verify_comp_attr stripe-count $tf ${ids[7]} $OSTCOUNT
+ verify_comp_attr_with_parent pool $tf ${ids[7]}
+ verify_comp_extent $tf ${ids[7]} 0 EOF
- # verify components ${ids[7]}, ${ids[9]} and ${ids[11]}
- for i in 7 9 11; do
+ # verify components ${ids[8]}, ${ids[10]} and ${ids[12]}
+ for i in 8 10 12; do
verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
verify_comp_attr stripe-count $tf ${ids[$i]} $OSTCOUNT
verify_comp_attr pool $tf ${ids[$i]} archive
verify_comp_extent $tf ${ids[$i]} 0 536870912
done
- # verify components ${ids[8]}, ${ids[10]} and ${ids[12]}
- for i in 8 10 12; do
+ # verify components ${ids[9]}, ${ids[11]} and ${ids[13]}
+ for i in 9 11 13; do
verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
verify_comp_attr stripe-count $tf ${ids[$i]} -1
verify_comp_attr pool $tf ${ids[$i]} archive
test_0g() {
local tf=$DIR/$tfile
+ ! $LFS mirror create --flags prefer $tf ||
+ error "creating $tf w/ --flags but w/o -N option should fail"
+
+ ! $LFS mirror create -N --flags foo $tf ||
+ error "creating $tf with '--flags foo' should fail"
+
+ ! $LFS mirror create -N --flags stale $tf ||
+ error "creating $tf with '--flags stale' should fail"
+
+ ! $LFS mirror create -N --flags prefer,init $tf ||
+ error "creating $tf with '--flags prefer,init' should fail"
+
+ ! $LFS mirror create -N --flags ^prefer $tf ||
+ error "creating $tf with '--flags ^prefer' should fail"
+
$LFS mirror create -N -E 1M -S 1M -o0 --flags=prefer -E eof -o1 \
-N -o1 $tf || error "create mirrored file $tf failed"
verify_comp_attr lcme_flags $tf 0x10002 prefer
# set flags to the first component
+ ! $LFS setstripe --comp-set -I 0x10001 --comp-flags=^prefer,foo $tf ||
+ error "setting '^prefer,foo' flags should fail"
+
+ ! $LFS getstripe --component-flags=prefer,foo $tf ||
+ error "getting component(s) with 'prefer,foo' flags should fail"
+
$LFS setstripe --comp-set -I 0x10001 --comp-flags=^prefer,stale $tf
verify_comp_attr lcme_flags $tf 0x10001 stale
error "error setting flag prefer"
verify_comp_attr lcme_flags $tf 0x20003 prefer
+
+ $LFS setstripe --comp-set -I 0x20003 --comp-flags=^prefer $tf ||
+ error "error clearing prefer flag from component 0x20003"
+
+ # MDS disallows setting stale flag on the last non-stale mirror
+ [[ "$MDS1_VERSION" -ge $(version_code 2.12.57) ]] || return 0
+
+ cp /etc/hosts $tf || error "error writing file '$tf'"
+
+ verify_comp_attr lcme_flags $tf 0x10002 prefer
+ verify_comp_attr lcme_flags $tf 0x20003 stale
+ verify_comp_attr lcme_flags $tf 0x30004 stale
+
+ ! $LFS setstripe --comp-set -I 0x10002 --comp-flags=^prefer,stale $tf \
+ > /dev/null 2>&1 ||
+ error "setting stale flag on component 0x10002 should fail"
+
+ $LFS mirror resync $tf || error "error resync-ing file '$tf'"
+
+ $LFS setstripe --comp-set -I 0x10001 --comp-flags=stale $tf ||
+ error "error setting stale flag on component 0x10001"
+ $LFS setstripe --comp-set -I 0x20003 --comp-flags=stale $tf ||
+ error "error setting stale flag on component 0x20003"
+
+ ! $LFS setstripe --comp-set -I 0x30004 --comp-flags=stale $tf \
+ > /dev/null 2>&1 ||
+ error "setting stale flag on component 0x30004 should fail"
+
+ $LFS mirror resync $tf || error "error resync-ing file '$tf'"
}
run_test 0h "set, clear and test flags for FLR files"
+test_0j() {
+ $LFS mirror create -N2 $DIR/$tfile || error "create $DIR/$tfile failed"
+
+ cp /etc/hosts $DIR/$tfile || error "write to $DIR/$tfile failed"
+ $LFS mirror resync $DIR/$tfile || error "resync $DIR/$tfile failed"
+ cmp /etc/hosts $DIR/$tfile || error "cmp with /etc/hosts failed"
+
+ $LFS mirror read -N2 -o $TMP/$tfile $DIR/$tfile || error "read mirror failed"
+ stack_trap "rm -f $TMP/$tfile"
+ cmp $TMP/$tfile $DIR/$tfile || error "cmp with $TMP/$tfile failed"
+ $LFS mirror write -N2 -i /etc/passwd $DIR/$tfile || error "write failed"
+ $LFS setstripe --comp-set -I 65537 --comp-flags=stale $DIR/$tfile ||
+ error "set component 1 stale failed"
+ $LFS mirror resync $DIR/$tfile || error "resync $DIR/$tfile failed"
+ cmp /etc/passwd $DIR/$tfile || error "cmp with /etc/passwd failed"
+}
+run_test 0j "test lfs mirror read/write commands"
+
test_1() {
local tf=$DIR/$tfile
local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
}
run_test 5 "Make sure init size work for mirrored layout"
-# LU=10112: disable dom+flr for phase 1
test_6() {
+ (( $MDS1_VERSION >= $(version_code 2.12.58) )) ||
+ skip "MDS version older than 2.12.58"
+
local tf=$DIR/$tfile
- $LFS mirror create -N -E 1M -S 1M -L mdt -E eof -N -E eof $tf &&
- error "expect failure to create mirrored file with DoM"
+ $LFS mirror create -N -E 1M -L mdt -E eof -S 1M -N -E eof $tf ||
+ error "failure to create DoM file with mirror"
- $LFS mirror create -N -E 1M -S 1M -E eof -N -E 1M -L mdt -E eof $tf &&
- error "expect failure to create mirrored file with DoM"
+ $LFS mirror create -N -E 1M -S 1M -E eof -N -E 1M -L mdt -E eof $tf ||
+ error "failure to create mirrored file with DoM"
- $LFS setstripe -E 1M -S 1M -L mdt -E eof $tf
- $LFS mirror extend -N2 $tf &&
- error "expect failure to extend mirror with DoM"
+ $LFS setstripe -E 1M -L mdt -E eof -S 1M $tf ||
+ error "failure to create PFL with DoM file"
+ $LFS mirror extend -N2 $tf ||
+ error "failure to extend mirror with DoM"
- $LFS mirror create -N2 -E 1M -S 1M -E eof $tf-2
- $LFS mirror extend -N -f $tf $tf-2 &&
- error "expect failure to extend mirrored file with DoM extent"
+ $LFS setstripe -E 1M -L mdt -E eof -S 1M $tf-1 ||
+ error "failure to create PFL with DoM file"
+ $LFS mirror create -N2 -E 1M -S 1M -E eof $tf-2 ||
+ error "failure to create mirrored file"
+ $LFS mirror extend -N -f $tf-1 $tf-2 ||
+ error "failure to extend mirrored file with DoM extent"
+}
+run_test 6 "DoM and FLR work together"
- true
+test_7() {
+ local tf=$DIR/$tfile
+
+ # create DoM with setting stripe_size == component size
+ $LFS mirror create -N -E1M -S1M -L mdt -Eeof $tf ||
+ error "failure to create DoM with stripe_size == comp size"
+ rm -f $tf || error "delete $tf"
+
+ # DoM should not inherit previous component stripe_size
+ $LFS mirror create -N -E4M -S2M -Eeof -N -E1M -L mdt -Eeof $tf ||
+ error "DoM component shouldn't inherit previous stripe_size"
}
-run_test 6 "DoM and FLR won't co-exist for phase 1"
+run_test 7 "Create mirror with DoM component"
test_21() {
local tf=$DIR/$tfile
[[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+ stack_trap "rm -f $tf $tf2"
+
$LFS setstripe -E EOF -o 0 $tf
$LFS setstripe -E EOF -o 1 $tf2
test_22() {
local tf=$DIR/$tfile
+ stack_trap "rm -f $tf"
+
$LFS setstripe -E EOF -o 0 $tf
dd if=/dev/zero of=$tf bs=1M count=$((RANDOM % 20 + 1))
$LFS mirror create -N -o 0 -N -o 1 $tf ||
error "creating mirrored file $tf failed"
- #define OBD_FAIL_GLIMPSE_IMMUTABLE 0x1A00
- $LCTL set_param fail_loc=0x1A00
-
local ost_idx
for ((ost_idx = 1; ost_idx <= 2; ost_idx++)); do
cancel_lru_locks osc
[[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
rm -f $DIR/$tfile $DIR/$tfile-2
+ stack_trap "rm -f $DIR/$tfile"
+
$LFS setstripe -E EOF -o 0 $DIR/$tfile
dd if=/dev/urandom of=$DIR/$tfile bs=1M count=$((RANDOM % 10 + 2))
}
run_test 32 "data should be mirrored to newly created mirror"
-test_33() {
+test_33a() {
[[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
rm -f $DIR/$tfile $DIR/$tfile-2
start_osts 2
}
-run_test 33 "read can choose available mirror to read"
+run_test 33a "read can choose available mirror to read"
+
+test_33b() {
+ [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+
+ rm -f $DIR/$tfile
+
+ stack_trap "rm -f $DIR/$tfile" EXIT
+
+ # create a file with two mirrors on OST0000 and OST0001
+ $LFS setstripe -N -Eeof -o0 -N -Eeof -o1 $DIR/$tfile
+
+ # make sure that $tfile has two mirrors
+ [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
+ { $LFS getstripe $DIR/$tfile; error "expected count 2"; }
+
+ # write 50M
+ dd if=/dev/urandom of=$DIR/$tfile bs=2M count=25 ||
+ error "write failed for $DIR/$tfile"
+ $LFS mirror resync $DIR/$tfile || error "resync failed for $DIR/$tfile"
+ verify_flr_state $DIR/$tfile "ro"
+ drop_client_cache
+
+ ls -l $DIR/$tfile
+
+ # read file - all OSTs are available
+ echo "reading file (data can be provided by any ost)... "
+ local t1=$SECONDS
+ time cat $DIR/$tfile > /dev/null || error "read all"
+ local t2=$SECONDS
+ ra=$((t2 - t1))
+
+ # read file again with ost1 {OST0000} failed
+ stop_osts 1
+ drop_client_cache
+ echo "reading file (data should be provided by ost2)..."
+ t1=$SECONDS
+ time cat $DIR/$tfile > /dev/null || error "read ost2"
+ t2=$SECONDS
+ r1=$((t2 - t1))
+
+ # remount ost1
+ start_osts 1
+
+ # read file again with ost2 {OST0001} failed
+ stop_osts 2
+ drop_client_cache
+
+ echo "reading file (data should be provided by ost1)..."
+ t1=$SECONDS
+ time cat $DIR/$tfile > /dev/null || error "read ost1"
+ t2=$SECONDS
+ r2=$((t2 - t1))
+
+ # remount ost2
+ start_osts 2
+
+ [ $((r1 * 100)) -gt $((ra * 105)) -a $r1 -gt $((ra + 2)) ] &&
+ error "read mirror too slow without ost1, from $ra to $r1"
+ [ $((r2 * 100)) -gt $((ra * 105)) -a $r2 -gt $((ra + 2)) ] &&
+ error "read mirror too slow without ost2, from $ra to $r2"
+
+ wait_osc_import_ready client ost2
+}
+run_test 33b "avoid reading from unhealthy mirror"
+
+test_33c() {
+ [[ $OSTCOUNT -lt 3 ]] && skip "need >= 3 OSTs" && return
+
+ rm -f $DIR/$tfile
+
+ stack_trap "rm -f $DIR/$tfile" EXIT
+
+ # create a file with two mirrors
+ # mirror1: {OST0000, OST0001}
+ # mirror2: {OST0001, OST0002}
+ $LFS setstripe -N -Eeof -c2 -o0,1 -N -Eeof -c2 -o1,2 $DIR/$tfile
+
+ # make sure that $tfile has two mirrors
+ [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
+ { $LFS getstripe $DIR/$tfile; error "expected count 2"; }
+
+ # write 50M
+ dd if=/dev/urandom of=$DIR/$tfile bs=2M count=25 ||
+ error "write failed for $DIR/$tfile"
+ $LFS mirror resync $DIR/$tfile || error "resync failed for $DIR/$tfile"
+ verify_flr_state $DIR/$tfile "ro"
+ drop_client_cache
+
+ ls -l $DIR/$tfile
+
+ # read file - all OSTs are available
+ echo "reading file (data can be provided by any ost)... "
+ time cat $DIR/$tfile > /dev/null || error "read all"
+
+ # read file again with ost2 (OST0001) failed
+ stop_osts 2
+ drop_client_cache
+
+ echo "reading file (data should be provided by ost1 and ost3)..."
+ time cat $DIR/$tfile > /dev/null || error "read ost1 & ost3"
+
+ # remount ost2
+ start_osts 2
+
+ wait_osc_import_ready client ost2
+}
+run_test 33c "keep reading among unhealthy mirrors"
test_34a() {
[[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
test_36() {
local tf=$DIR/$tfile
+ stack_trap "rm -f $tf $tf-2 $tf-3"
+
create_file_36 $tf $tf-2 $tf-3
[ $($LFS getstripe -N $tf) -gt 1 ] || error "wrong mirror count"
local tf3=$DIR/$tfile-3
local tf4=$DIR/$tfile-4
+ stack_trap "rm -f $tf $tf2 $tf3 $tf4"
+
create_files_37 $((RANDOM + 15 * 1048576)) $tf $tf2 $tf3
rm -f $tf4
cp $tf $tf4
echo "Verifying mirror read .."
local sum
- for i in ${mirror_array[@]}; do
+ for i in "${mirror_array[@]}"; do
$LCTL set_param ldlm.namespaces.*.lru_size=clear > /dev/null
sum=$($LFS mirror read -N $i $tf | md5sum)
[ "$sum" = "${checksums[$i]}" ] ||
# verify copying is successful by checking checksums
remount_client $MOUNT
- for i in ${mirror_array[@]}; do
+ for i in "${mirror_array[@]}"; do
sum=$($LFS mirror read -N $i $tf | md5sum)
[ "$sum" = "${checksums[1]}" ] ||
error "$i: mismatch checksum after copy \'$sum\'"
}
run_test 37 "mirror I/O API verification"
-verify_flr_state()
-{
- local tf=$1
- local expected_state=$2
-
- local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }')
- [ $expected_state = $state ] ||
- error "expected: $expected_state, actual $state"
-}
-
test_38() {
local tf=$DIR/$tfile
local ref=$DIR/${tfile}-ref
+ stack_trap "rm -f $tf $ref"
+
$LFS setstripe -E 1M -S 1M -c 1 -E 4M -c 2 -E eof -c -1 $tf ||
error "creating $tf failed"
$LFS setstripe -E 2M -S 1M -c 1 -E 6M -c 2 -E 8M -c -1 -E eof -c -1 \
[ "$file_cksum" = "$ref_cksum" ] || error "write failed, cksum mismatch"
get_mirror_ids $tf
- echo "mirror IDs: ${mirror_array[@]}"
+ echo "mirror IDs: ${mirror_array[*]}"
local valid_mirror stale_mirror id mirror_cksum
for id in "${mirror_array[@]}"; do
[ -z "$stale_mirror" ] && error "stale mirror doesn't exist"
[ -z "$valid_mirror" ] && error "valid mirror doesn't exist"
- mirror_io resync $tf || error "resync failed"
+ $LFS mirror resync $tf || error "resync failed"
verify_flr_state $tf "ro"
mirror_cksum=$($LFS mirror read -N $stale_mirror $tf | md5sum)
verify_flr_state $tf "sp"
# from sync_pending to read_only
- mirror_io resync $tf || error "resync failed"
+ $LFS mirror resync $tf || error "resync failed"
verify_flr_state $tf "ro"
}
run_test 38 "resync"
test_41() {
local tf=$DIR/$tfile
+ stack_trap "rm -f $tf $tf-1"
+
rm -f $tf $tf-1
echo " **create two FLR files $tf $tf-1"
$LFS mirror create -N -E 2M -S 1M -E 4M -E -1 \
local mirror_cmd="$LFS mirror verify"
local i
+ stack_trap "rm -rf $td"
+
# create parent directory
mkdir $td || error "mkdir $td failed"
[ $flags = wp ] || error "file mirror state $flags != wp"
}
-test_43() {
+test_43a() {
[ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
local tf=$DIR/$tfile
verify_comp_attr lcme_flags $tf 0x20002 init,stale
verify_comp_attr lcme_flags $tf 0x30003 init,stale
}
-run_test 43 "mirror pick on write"
+run_test 43a "mirror pick on write"
-test_44() {
+test_43b() {
+ local tf=$DIR/$tdir/$tfile
+
+ test_mkdir $DIR/$tdir
+ rm -f $tf
+ stack_trap "rm -rf $tf"
+
+ # create 3 mirrors FLR file, the first 2 mirrors are preferred
+ $LFS setstripe -N -Eeof --flags=prefer -N -Eeof --flags=prefer \
+ -N -Eeof $tf || error "create 3 mirrors file $tf failed"
+ verify_flr_state $tf "ro"
+
+ echo " ** write to $tf"
+ dd if=/dev/zero of=$tf bs=1M count=1 || error "write $tf failed"
+ verify_flr_state $tf "wp"
+
+ echo " ** resync $tf"
+ $LFS mirror resync $tf || error "resync $tf failed"
+ verify_flr_state $tf "ro"
+}
+run_test 43b "allow writing to multiple preferred mirror file"
+
+test_44a() {
[ $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
+ stack_trap "rm -rf $tf $tf1"
+
$LFS setdirstripe -i 0 -c 1 $DIR/$tdir ||
error "create directory failed"
$LFS setdirstripe -i 1 -c 1 $DIR/$tdir-1 ||
verify_flr_state $tf "wp"
+ # disallow destroying the last non-stale mirror
+ ! $LFS mirror delete --mirror-id 1 $tf > /dev/null 2>&1 ||
+ error "destroying mirror 1 should fail"
+
# synchronize all mirrors of the file
$LFS mirror resync $tf || error "mirror resync $tf failed"
verify_mirror_count $tf 2
verify_mirror_count $tf.mirror~2 1
+ $LFS setstripe --comp-set -I 0x30008 --comp-flags=stale $tf ||
+ error "setting stale flag on component 0x30008 failed"
+
+ # disallow destroying the last non-stale mirror
+ ! $LFS mirror split --mirror-id 4 -d $tf > /dev/null 2>&1 ||
+ error "destroying mirror 4 should fail"
+
+ $LFS mirror resync $tf || error "resynchronizing $tf failed"
+
$LFS mirror split --mirror-id 3 -d $tf ||
- error "split and delte mirror 3 failed"
+ error "destroying mirror 3 failed"
verify_mirror_count $tf 1
# verify splitted file contains the same content as the orig file does
diff $tf $tf.mirror~2 ||
error "splited file $tf.mirror~2 diffs from $tf"
}
-run_test 44 "lfs mirror split check"
+run_test 44a "lfs mirror split check"
+
+test_44b() {
+ (( $MDS1_VERSION >= $(version_code 2.14.56) )) ||
+ skip "Need MDS version at least 2.14.56"
+
+ rm -rf $DIR/$tdir
+ local tf=$DIR/$tdir/$tfile
+
+ mkdir -p $DIR/$tdir || error "create directory failed"
+
+ echo XXX > $tf
+
+ # create 2 mirrors file
+ $LFS mirror extend -N -c1 $tf
+
+ echo YYY > $tf
+
+ verify_flr_state $tf "wp"
+
+ local str=$(cat $tf)
+
+ [[ $str == "YYY" ]] || error "$tf content is not YYY"
+
+ # get the non-stale mirror id
+ local ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' |
+ tr '\n' ' '))
+ local mirror_ids=($($LFS getstripe $tf |
+ awk '/lcme_mirror_id/{print $2}' | tr '\n' ' '))
+ for ((i = 0; i < 2; i++)); do
+ $LFS getstripe -I${ids[$i]} --component-flags $tf |
+ grep stale > /dev/null || break
+ done
+
+ [[ $i -ge 2 ]] && ( $LFS getstripe $tf; error "no stale mirror" )
+
+ $LFS getstripe $tf
+
+ # split the updated mirror, should fail
+ echo "split mirror_id ${mirror_ids[$i]} id ${ids[$i]}, should fail"
+ $LFS mirror split --mirror-id=${mirror_ids[$i]} $tf &> /dev/null &&
+ error "split --mirror-id=${mirror_ids[$i]} $tf should fail"
+
+ i=$(( 1 - i ))
+ # split the stale mirror
+ echo "split mirror_id ${mirror_ids[$i]} id ${ids[$i]}"
+ $LFS mirror split --mirror-id=${mirror_ids[$i]} -d $tf ||
+ error "mirror split --mirror-id=${mirror_ids[$i]} $tf failed"
+
+ echo "make sure there's no stale comp in the file"
+ # make sure there's no stale comp in the file
+ $LFS getstripe $tf | awk '/lcme_flags/{print $2}' | grep stale &&
+ ( $LFS getstripe $tf; error "stale mirror file" )
+
+ str=$(cat $tf)
+ [[ $str == "YYY" ]] ||
+ ( cat $tf; error "$tf content is not YYY after split" )
+}
+run_test 44b "mirror split does not create stale file"
+
+test_44c() {
+ local tf=$DIR/$tdir/$tfile
+
+ stack_trap "rm -f $tf"
+
+ [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
+ skip "Need MDS version at least 2.14.52"
+
+ [ "$FSTYPE" != "zfs" ] || skip "ZFS file's block number is not accurate"
+
+ mkdir -p $DIR/$tdir || error "create directroy failed"
+
+ dd if=/dev/zero of=$tf bs=1M count=10 || error "dd write $tfile failed"
+ sync
+ block1=$(( $(stat -c "%b*%B" $tf) ))
+ echo " ** before mirror ops, file blocks=$((block1/1024)) KiB"
+
+ $LFS mirror extend -N2 -c1 $tf || error "mirror extend $tfile failed"
+ sync
+ block2=$(( $(stat -c "%b*%B" $tf) ))
+ echo " ** after mirror extend, file blocks=$((block2/1024)) KiB"
+
+ $LFS mirror split -d --mirror-id=2 $tf ||
+ error "mirror split $tfile failed"
+ $LFS mirror split -d --mirror-id=3 $tf ||
+ error "mirror split $tfile failed"
+ sync
+ lfs getsom $tf
+ block3=$(( $(stat -c "%b*%B" $tf) ))
+ echo " ** after mirror split, file blocks=$((block3/1024)) KiB"
+
+ [[ $block1 -eq $block3 ]] ||
+ error "mirror split does not reduce block# $block3 != $block1"
+}
+run_test 44c "lfs mirror split reduces block size of a file"
+
+test_44d() {
+ local tf=$DIR/$tdir/$tfile
+ local size1
+ local size2
+ local size3
+ local size4
+
+ stack_trap "rm -f $tf"
+
+ mkdir -p $DIR/$tdir || error "create directroy failed"
+
+ dd if=/dev/zero of=$tf bs=1M count=10 || error "dd write $tfile failed"
+ sync
+ size1=$(stat -c "%s" $tf)
+ echo " ** before mirror ops, file size=$size1"
+
+ $LFS mirror extend -N2 -c1 $tf || error "mirror extend $tfile failed"
+ sync
+ size2=$(stat -c "%s" $tf)
+ echo " ** after mirror extend, file size=$size2"
+
+ (($size1 == $size2)) ||
+ error "mirror extend should not change size, before: $size1, after $size2"
+
+ $LFS mirror split -d --mirror-id=2 $tf ||
+ error "mirror split $tfile failed"
+
+ size2=$(stat -c "%s" $tf)
+ echo " ** after mirror split, file size=$size2"
+ (($size1 == $size2)) ||
+ error "mirror split should not change size, before: $size1, after $size2"
+
+ # Remount client to clear cached size information
+ remount_client $MOUNT
+ size2=$(stat -c "%s" $tf)
+ echo " ** after mirror split & remount, file size=$size2"
+ (($size1 == $size2)) ||
+ error "mirror extend should not change size, before: $size1, after $size2"
+
+}
+run_test 44d "lfs mirror split does not break size"
+
+test_44e() {
+ local tf=$DIR/$tdir/$tfile
+ local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+ local size1
+ local size2
+
+ test_mkdir $DIR/$tdir
+ [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
+ skip "Need MDS version at least 2.14.52"
+
+ $LFS mirror create -N2 $tf || error "create mirrored file $tf failed"
+
+ # Disable xattr caching so we can repeatedly check SOM with lfs getsom
+ $LCTL set_param llite.*.xattr_cache=0
+ stack_trap "$LCTL set_param llite.*.xattr_cache=1"
+
+ dd if=/dev/zero of=$tf bs=1M count=10 || error "dd write $tfile failed"
+ sync
+ size1=$(stat -c "%s" $tf)
+ echo " ** before mirror resync, file size=$size1"
+
+ $LFS mirror resync $tf || error "mirror resync file $tf failed"
+ size1=$(stat -c "%s" $tf)
+ size2=$($LFS getsom -s $tf)
+
+ $LFS getsom $tf
+
+ ((size1 == size2)) ||
+ error "mirrored file with strict SOM $size1 != disabled SOM $size2"
+
+ # Remount client to clear cached size information
+ remount_client $MOUNT
+
+ save_lustre_params $(get_facets MDS) mdt.*MDT*.enable_strict_som > $p
+ stack_trap "restore_lustre_params < $p; rm -f $p"
+ local mds_facet=mds$(($($LFS getstripe -m $tf) + 1))
+
+ do_facet $mds_facet $LCTL set_param mdt.*MDT*.enable_strict_som=0
+
+ size2=$(stat -c "%s" $tf)
+ # 'getsom' here is just for debugging
+ $LFS getsom $tf
+
+ ((size2 == size1)) ||
+ error "mirrored file in sync with som disabled, size with som disabled ($size2) and without som disabled ($size1) should agree"
+}
+run_test 44e "basic FLR SOM tests + disable SOM"
test_45() {
[ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
########################### 3. FLR file #############################
echo " ** 3. FLR file"
+ rm -f $file
$LFS setstripe -N -E1m -S 1M -c2 -o0,1 -E4m -c1 -Eeof -N -E16m -Eeof \
$file || error "3. Create FLR $file failed"
error "6. setstripe FLR $dir failed"
verify_46 $dir $dir.copy "6. FLR dir"
+
+ (( $MDS1_VERSION >= $(version_code 2.13.53.205) )) ||
+ echo "server version $MDS1_VERSION does not support SEL" &&
+ return 0
+
+ ########################### 7. SEL file ##############################
+ echo " ** 7. SEL file"
+ rm -f $file
+ $LFS setstripe -E256M -S 1M -c2 -o0,1 -z 64M -E-1 -o1,0 -z 128M \
+ $file || error "Create $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "7. SEL file"
+
+ ########################### 8. SEL dir ##############################
+ echo " ** 8. SEL dir"
+ $LFS setstripe -E256M -S 1M -c2 -z 64M -E-1 -z 128M \
+ $dir || error "setstripe $dir failed"
+
+ verify_46 $dir $dir.copy "8. SEL dir"
+
+ ########################### 9. FLR SEL file ##########################
+ echo " ** 9. FLR SEL file"
+ rm -f $file
+ $LFS setstripe -N -E256M -c2 -z 64M -E-1 -z 128M \
+ -N -E1G -c4 -z128M -E-1 -z256M $file || error "Create $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "9. SEL file"
+
+ ########################### 10. FLR SEL dir #########################
+ echo " ** 10. FLR SEL dir"
+ $LFS setstripe -N -E256M -c2 -z 64M -E-1 -z 128M \
+ -N -E1G -c4 -z128M -E-1 -z256M $dir || error "Create $file failed"
+
+ verify_46 $dir $dir.copy "10. SEL dir"
}
run_test 46 "Verify setstripe --copy option"
}
run_test 48 "Verify snapshot mirror"
+OLDIFS="$IFS"
+cleanup_49() {
+ trap 0
+ IFS="$OLDIFS"
+}
+
+test_49a() {
+ [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
+
+ trap cleanup_49 EXIT RETURN
+
+ local file=$DIR/$tfile
+
+ $LFS setstripe -N -E eof -c1 -o1 -N -E eof -c1 -o0 $file ||
+ error "setstripe on $file"
+
+ dd if=/dev/zero of=$file bs=1M count=1 || error "dd failed for $file"
+ $LFS mirror resync $file
+
+ filefrag -ves $file || error "filefrag $file failed"
+ filefrag_op=$(filefrag -ve -k $file |
+ sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
+
+#Filesystem type is: bd00bd0
+#File size of /mnt/lustre/f49a.sanity-flr is 1048576 (1024 blocks of 1024 bytes)
+# ext: device_logical: physical_offset: length: dev: flags:
+# 0: 0.. 1023: 1572864.. 1573887: 1024: 0001: net,eof
+# 1: 0.. 1023: 1572864.. 1573887: 1024: 0000: last,net,eof
+#/mnt/lustre/f49a.sanity-flr: 2 extents found
+
+ last_lun=$(echo $filefrag_op | cut -d: -f5)
+ IFS=$'\n'
+ tot_len=0
+ num_luns=1
+ for line in $filefrag_op; do
+ frag_lun=$(echo $line | cut -d: -f5)
+ ext_len=$(echo $line | cut -d: -f4)
+ if [[ "$frag_lun" != "$last_lun" ]]; then
+ if (( tot_len != 1024 )); then
+ cleanup_49
+ error "$file: OST$last_lun $tot_len != 1024"
+ else
+ (( num_luns += 1 ))
+ tot_len=0
+ fi
+ fi
+ (( tot_len += ext_len ))
+ last_lun=$frag_lun
+ done
+ if (( num_luns != 2 || tot_len != 1024 )); then
+ cleanup_49
+ error "$file: $num_luns != 2, $tot_len != 1024 on OST$last_lun"
+ fi
+
+ echo "FIEMAP on $file succeeded"
+}
+run_test 49a "FIEMAP upon FLR file"
+
+test_50A() { # EX-2179
+ mkdir -p $DIR/$tdir
+
+ local file=$DIR/$tdir/$tfile
+
+ $LFS setstripe -c1 -i0 $file || error "setstripe $file failed"
+
+ $LFS mirror extend -N -c1 -i1 $file ||
+ error "extending mirror for $file failed"
+
+ local olv=$($LFS getstripe $file | awk '/lcm_layout_gen/{print $2}')
+
+ fail mds1
+
+ $LFS mirror split -d --mirror-id=1 $file || error "split $file failed"
+
+ local flv=$($LFS getstripe $file | awk '/lcm_layout_gen/{print $2}')
+
+ echo "$file layout generation from $olv to $flv"
+ (( $flv != ($olv + 1) )) &&
+ error "split does not increase layout gen from $olv to $flv"
+
+ dd if=/dev/zero of=$file bs=1M count=1 || error "write $file failed"
+
+ $LFS getstripe -v $file || error "getstripe $file failed"
+}
+run_test 50A "mirror split update layout generation"
+
+test_50a() {
+ $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
+ skip "OST does not support SEEK_HOLE"
+
+ local file=$DIR/$tdir/$tfile
+ local offset
+ local sum1
+ local sum2
+ local blocks
+
+ mkdir -p $DIR/$tdir
+
+ echo " ** create striped file $file"
+ $LFS setstripe -E 1M -c1 -S 1M -E eof -c2 -S1M $file ||
+ error "cannot create file with PFL layout"
+ echo " ** write 1st data chunk at 1M boundary"
+ dd if=/dev/urandom of=$file bs=1k count=20 seek=1021 ||
+ error "cannot write data at 1M boundary"
+ echo " ** write 2nd data chunk at 2M boundary"
+ dd if=/dev/urandom of=$file bs=1k count=20 seek=2041 ||
+ error "cannot write data at 2M boundary"
+ echo " ** create hole at the file end"
+ $TRUNCATE $file 3700000 || error "truncate fails"
+
+ echo " ** verify sparseness"
+ offset=$(lseek_test -d 1000 $file)
+ echo " first data offset: $offset"
+ [[ $offset == 1000 ]] &&
+ error "src: data is not expected at offset $offset"
+ offset=$(lseek_test -l 3500000 $file)
+ echo " hole at the end: $offset"
+ [[ $offset == 3500000 ]] ||
+ error "src: hole is expected at offset $offset"
+
+ echo " ** extend the file with new mirror"
+ # migrate_copy_data() is used
+ $LFS mirror extend -N -E 2M -S 1M -E 1G -S 2M -E eof $file ||
+ error "cannot create mirror"
+ $LFS getstripe $file | grep lcme_flags | grep stale > /dev/null &&
+ error "$file still has stale component"
+
+ # check migrate_data_copy() was correct
+ sum_1=$($LFS mirror read -N 1 $file | md5sum)
+ sum_2=$($LFS mirror read -N 2 $file | md5sum)
+ [[ $sum_1 == $sum_2 ]] ||
+ error "data mismatch: \'$sum_1\' vs. \'$sum_2\'"
+
+ # stale first mirror
+ $LFS setstripe --comp-set -I0x10001 --comp-flags=stale $file
+ $LFS setstripe --comp-set -I0x10002 --comp-flags=stale $file
+
+ echo " ** verify mirror #2 sparseness"
+ offset=$(lseek_test -d 1000 $file)
+ echo " first data offset: $offset"
+ [[ $offset == 1000 ]] &&
+ error "dst: data is not expected at offset $offset"
+ offset=$(lseek_test -l 3500000 $file)
+ echo " hole at the end: $offset"
+ [[ $offset == 3500000 ]] ||
+ error "dst: hole is expected at offset $offset"
+
+ echo " ** copy mirror #2 to mirror #1"
+ $LFS mirror copy -i 2 -o 1 $file || error "mirror copy fails"
+ $LFS getstripe $file | grep lcme_flags | grep stale > /dev/null &&
+ error "$file still has stale component"
+
+ # check llapi_mirror_copy_many correctness
+ sum_1=$($LFS mirror read -N 1 $file | md5sum)
+ sum_2=$($LFS mirror read -N 2 $file | md5sum)
+ [[ $sum_1 == $sum_2 ]] ||
+ error "data mismatch: \'$sum_1\' vs. \'$sum_2\'"
+
+ # stale 1st component of mirror #2 before lseek call
+ $LFS setstripe --comp-set -I0x20001 --comp-flags=stale $file
+
+ echo " ** verify mirror #1 sparseness again"
+ offset=$(lseek_test -d 1000 $file)
+ echo " first data offset: $offset"
+ [[ $offset == 1000 ]] &&
+ error "dst: data is not expected at offset $offset"
+ offset=$(lseek_test -l 3500000 $file)
+ echo " hole at the end: $offset"
+ [[ $offset == 3500000 ]] ||
+ error "dst: hole is expected at offset $offset"
+
+ cancel_lru_locks osc
+
+ blocks=$(stat -c%b $file)
+ echo " ** final consumed blocks: $blocks"
+ # for 3.5Mb file consumes ~6000 blocks, use 1000 to check
+ # that file is still sparse
+ (( blocks < 1000 )) ||
+ error "Mirrored file consumes $blocks blocks"
+
+ rm $file
+}
+run_test 50a "mirror extend/copy preserves sparseness"
+
+test_50b() {
+ $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
+ skip "OST does not support SEEK_HOLE"
+
+ local file=$DIR/$tdir/$tfile
+ local offset
+ local sum1
+ local sum2
+ local blocks
+
+ mkdir -p $DIR/$tdir
+
+ echo " ** create mirrored file $file"
+ $LFS mirror create -N -E1M -c1 -S1M -E eof \
+ -N -E2M -S1M -E eof -S2M $file ||
+ error "cannot create mirrored file"
+ echo " ** write data chunk at 1M boundary"
+ dd if=/dev/urandom of=$file bs=1k count=20 seek=1021 ||
+ error "cannot write data at 1M boundary"
+ echo " ** create hole at the file end"
+ $TRUNCATE $file 3700000 || error "truncate fails"
+
+ echo " ** verify sparseness"
+ offset=$(lseek_test -d 1000 $file)
+ echo " first data offset: $offset"
+ [[ $offset == 1000 ]] &&
+ error "src: data is not expected at offset $offset"
+ offset=$(lseek_test -l 3500000 $file)
+ echo " hole at the end: $offset"
+ [[ $offset == 3500000 ]] ||
+ error "src: hole is expected at 3500000"
+
+ echo " ** resync mirror #2 to mirror #1"
+ $LFS mirror resync $file
+
+ # check llapi_mirror_copy_many correctness
+ sum_1=$($LFS mirror read -N 1 $file | md5sum)
+ sum_2=$($LFS mirror read -N 2 $file | md5sum)
+ [[ $sum_1 == $sum_2 ]] ||
+ error "data mismatch: \'$sum_1\' vs. \'$sum_2\'"
+
+ cancel_lru_locks osc
+
+ blocks=$(stat -c%b $file)
+ echo " ** consumed blocks: $blocks"
+ # without full punch() support the first component can be not sparse
+ # but the last one should be, so file should use far fewer blocks
+ (( blocks < 5000 )) ||
+ error "Mirrored file consumes $blocks blocks"
+
+ # stale first component in mirror #1
+ $LFS setstripe --comp-set -I0x10001 --comp-flags=stale,nosync $file
+ echo " ** truncate file down"
+ $TRUNCATE $file 0
+ echo " ** write data chunk at 2M boundary"
+ dd if=/dev/urandom of=$file bs=1k count=20 seek=2041 conv=notrunc ||
+ error "cannot write data at 2M boundary"
+ echo " ** resync mirror #2 to mirror #1 with nosync 1st component"
+ $LFS mirror resync $file || error "mirror rsync fails"
+ # first component is still stale
+ $LFS getstripe $file | grep 'lcme_flags:.*stale' > /dev/null ||
+ error "$file still has no stale component"
+ echo " ** resync mirror #2 to mirror #1 again"
+ $LFS setstripe --comp-set -I0x10001 --comp-flags=stale,^nosync $file
+ $LFS mirror resync $file || error "mirror rsync fails"
+ $LFS getstripe $file | grep 'lcme_flags:.*stale' > /dev/null &&
+ error "$file still has stale component"
+
+ # check llapi_mirror_copy_many correctness
+ sum_1=$($LFS mirror read -N 1 $file | md5sum)
+ sum_2=$($LFS mirror read -N 2 $file | md5sum)
+ [[ $sum_1 == $sum_2 ]] ||
+ error "data mismatch: \'$sum_1\' vs. \'$sum_2\'"
+
+ cancel_lru_locks osc
+
+ blocks=$(stat -c%b $file)
+ echo " ** final consumed blocks: $blocks"
+ # while the first component can lose sparseness, the last one should
+ # not, so whole file should still use far fewer blocks in total
+ (( blocks < 3000 )) ||
+ error "Mirrored file consumes $blocks blocks"
+ rm $file
+}
+run_test 50b "mirror rsync handles sparseness"
+
+test_50c() {
+ local tf=$DIR/$tdir/$tfile
+
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -N2 -c-1 $tf || error "create FLR $tf failed"
+ verify_flr_state $tf "ro"
+
+ if [[ "$FSTYPE" == "ldiskfs" ]]; then
+ # ZFS does not support fallocate for now
+ out=$(fallocate -p -o 1MiB -l 1MiB $tf 2>&1) ||
+ skip_eopnotsupp "$out|punch hole in $tf failed"
+ verify_flr_state $tf "wp"
+ fi
+
+ dd if=/dev/zero of=$tf bs=4096 count=4 || error "write $tf failed"
+ $LFS mirror resync $tf || error "mirror resync $tf failed"
+ verify_flr_state $tf "ro"
+
+ $MULTIOP $tf OSMWUc || error "$MULTIOP $tf failed"
+ verify_flr_state $tf "wp"
+}
+run_test 50c "punch_hole/mmap_write stale other mirrors"
+
+test_50d() {
+ $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
+ skip "OST does not support SEEK_HOLE"
+ (( $LINUX_VERSION_CODE > $(version_code 3.0.0) )) ||
+ skip "client kernel does not support SEEK_HOLE"
+
+ local file=$DIR/$tdir/$tfile
+ local offset
+ local prt
+ local rc
+
+ mkdir -p $DIR/$tdir
+
+ echo " ** create mirrored file $file"
+ $LFS mirror create -N -E1M -c1 -S1M -E eof \
+ -N -E2M -S1M -E eof -S2M $file ||
+ error "cannot create mirrored file"
+ echo " ** write data chunk at 1M boundary"
+ dd if=/dev/urandom of=$file bs=1k count=20 seek=1021 ||
+ error "cannot write data at 1M boundary"
+ echo " ** create hole at the file start"
+ prt=$(fallocate -p -o 0 -l 1M $file 2>&1)
+ rc=$?
+
+ if [[ $rc -eq 0 ]]; then
+ verify_flr_state $file "wp"
+ elif [[ ! $prt =~ unsupported ]]; then
+ error "punch hole in $file failed: $prt"
+ else
+ skip "Fallocate punch is not supported: $prt"
+ fi
+
+ echo " ** verify sparseness"
+ offset=$(lseek_test -d 1000 $file)
+ echo " first data offset: $offset"
+ (( $offset >= 1024 * 1024 )) ||
+ error "src: data is not expected at offset $offset"
+
+ echo " ** resync mirror #2"
+ $LFS mirror resync $file
+
+ # check llapi_mirror_copy_many correctness
+ sum_1=$($LFS mirror read -N 1 $file | md5sum)
+ sum_2=$($LFS mirror read -N 2 $file | md5sum)
+ [[ $sum_1 == $sum_2 ]] ||
+ error "data mismatch: \'$sum_1\' vs. \'$sum_2\'"
+
+ cancel_lru_locks osc
+
+ # stale first component in mirror #1
+ $LFS setstripe --comp-set -I0x10001 --comp-flags=stale,nosync $file
+ echo " ** verify sparseness of mirror #2"
+ offset=$(lseek_test -d 1000 $file)
+ echo " first data offset: $offset"
+ (( $offset >= 1024 * 1024 )) ||
+ error "src: data is not expected at offset $offset"
+}
+run_test 50d "mirror rsync keep holes"
+
+test_60a() {
+ $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
+ skip "OST does not support SEEK_HOLE"
+
+ local file=$DIR/$tdir/$tfile
+ local old_size=2147483648 # 2GiB
+ local new_size
+
+ mkdir -p $DIR/$tdir
+ dd if=/dev/urandom of=$file bs=4096 count=1 seek=$((134217728 / 4096))
+ $TRUNCATE $file $old_size
+
+ $LFS mirror extend -N -c 1 $file
+ dd if=/dev/urandom of=$file bs=4096 count=1 seek=$((134217728 / 4096)) conv=notrunc
+ $LFS mirror resync $file
+
+ new_size=$(stat --format='%s' $file)
+ if ((new_size != old_size)); then
+ error "new_size ($new_size) is not equal to old_size ($old_size)"
+ fi
+
+ rm $file
+}
+run_test 60a "mirror extend sets correct size on sparse file"
+
+get_flr_layout_gen() {
+ getfattr -n lustre.lov --only-values $tf 2>/dev/null |
+ od -tx4 | awk '/000000/ { print "0x"$4; exit; }'
+}
+
+check_layout_gen() {
+ local tf=$1
+
+ local v1=$(get_flr_layout_gen $tf)
+ local v2=$($LFS getstripe -v $tf | awk '/lcm_layout_gen/ { print $2 }')
+
+ [[ $v1 -eq $v2 ]] ||
+ error "$tf in-memory layout gen $v1 != $v2 after $2"
+}
+
+test_60b() {
+ local tf=$DIR/$tdir/$tfile
+
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -Eeof $tf || error "setstripe $tf failed"
+
+ for ((i = 0; i < 20; i++)); do
+ $LFS mirror extend -N $tf ||
+ error "extending mirror for $tf failed"
+ check_layout_gen $tf "extend"
+
+ $LFS mirror split -d --mirror-id=$((i+1)) $tf ||
+ error "split $tf failed"
+ check_layout_gen $tf "split"
+ done
+}
+run_test 60b "mirror merge/split cancel client's in-memory layout gen"
+
+get_times_61() {
+ stat --format='%X %Y %Z' $file || error "$file: cannot get times"
+}
+
+check_times_61() {
+ local file=$1
+ local -a old=( $2 $3 $4 )
+ local -a new
+
+ new=( $(get_times_61 $file) )
+ ((${old[0]} == ${new[0]})) ||
+ error "$file: atime: old '${old[0]}' != new '${new[0]}'"
+
+ ((${old[1]} == ${new[1]})) ||
+ error "$file: mtime: old '${old[1]}' != new '${new[1]}'"
+}
+
+test_61a() { # LU-14508
+ local file=$DIR/$tdir/$tfile
+ local -a tim
+ local nap=5
+
+ mkdir -p $DIR/$tdir
+ echo "create $file"
+ $LFS setstripe -E1M -Eeof $file || error "setstripe $file failed"
+ echo "create $file-2"
+ $LFS setstripe -E2M -Eeof $file-2 || error "setstripe $file-2 failed"
+
+ echo XXX > $file || error "write $file failed"
+ chown $RUNAS_ID $DIR/$tdir $file || error "chown $file failed"
+
+ echo "sleep $nap seconds, then cat $tfile"
+ sleep $nap
+ cat $file || error "cat $file failed"
+
+ echo "sleep $nap seconds, then re-write $tfile"
+ sleep $nap
+ echo XXXX > $file || error "write $file failed"
+ cp -p $file $file-2 || error "copy $file-2 failed"
+
+ echo "sleep $nap seconds"
+ sleep $nap
+
+ tim=( $(get_times_61 $file) )
+
+ echo "mirror merge $tfile-2 to $tfile and test timestamps"
+ $LFS mirror extend -N -f $file-2 $file ||
+ error "cannot mirror merge $file-2 to $file"
+ check_times_61 $file "${tim[@]}"
+
+ echo "mirror extend $tfile and test timestamps"
+ $LFS mirror extend -N -c1 -i1 $file ||
+ error "cannot extend mirror $file"
+ check_times_61 $file "${tim[@]}"
+
+ echo "migrate $tfile and test timestamps"
+ $LFS migrate -n $file || error "cannot migrate $file"
+ check_times_61 $file "${tim[@]}"
+
+ echo "normal user migrate $tfile and test timestamps"
+ $RUNAS $LFS migrate -n $file || error "cannot migrate $file"
+ check_times_61 $file "${tim[@]}"
+}
+run_test 61a "mirror extend and migrate preserve timestamps"
+
+test_61b() { # LU-14508
+ local file=$DIR/$tdir/$tfile
+ local -a tim
+ local nap=5
+
+ mkdir -p $DIR/$tdir
+ echo "create $file"
+ echo XXX > $file || error "create $file failed"
+ chown $RUNAS_ID $DIR/$tdir $file || error "chown $file failed"
+
+ echo "sleep $nap seconds, then cat $tfile"
+ sleep $nap
+ cat $file || error "cat $file failed"
+
+ echo "sleep $nap seconds, then re-write $tfile"
+ sleep $nap
+ echo XXXX > $file || error "write $file failed"
+
+ echo "sleep $nap seconds, then test timestamps"
+ sleep $nap
+
+ tim=( $(get_times_61 $file) )
+
+ echo "mirror extend $tfile and test timestamps"
+ $LFS mirror extend -N -c1 -i1 $file ||
+ error "cannot extend mirror $file"
+ check_times_61 $file "${tim[@]}"
+
+ echo "mirror split $tfile and test timestamps"
+ $LFS mirror split -d --mirror-id=1 $file ||
+ error "cannot split mirror 1 off $file"
+ check_times_61 $file "${tim[@]}"
+
+ echo "normal user mirror extend $tfile and test timestamps"
+ $RUNAS $LFS mirror extend -N -c1 -i1 $file ||
+ error "cannot extend mirror $file"
+ check_times_61 $file "${tim[@]}"
+}
+run_test 61b "mirror extend and split preserve timestamps"
+
+test_61c() { # LU-14508
+ local file=$DIR/$tdir/$tfile
+ local -a tim
+ local nap=5
+
+ mkdir -p $DIR/$tdir
+ echo "create $file"
+ echo XXX > $file || error "create $file failed"
+ chown $RUNAS_ID $DIR/$tdir $file || error "chown $file failed"
+
+ echo "sleep $nap seconds, then cat $tfile"
+ sleep $nap
+ cat $file || error "cat $file failed"
+
+ echo "sleep $nap seconds, then mirror extend $tfile and write it"
+ sleep $nap
+ $LFS mirror extend -N -c1 -i1 $file ||
+ error "cannot extend mirror $file"
+ echo XXXX > $file || error "write $file failed"
+
+ echo "sleep $nap seconds, then resync $tfile and test timestamps"
+ tim=( $(get_times_61 $file) )
+ sleep $nap
+ $LFS mirror resync $file || error "cannot resync mirror $file"
+ check_times_61 $file "${tim[@]}"
+
+ echo XXXXXX > $file || error "write $tfile failed"
+
+ echo "normal user resync $tfile and test timestamps"
+ tim=( $(get_times_61 $file) )
+ $RUNAS $LFS mirror resync $file || error "cannot resync mirror $file"
+ check_times_61 $file "${tim[@]}"
+}
+run_test 61c "mirror resync preserves timestamps"
+
+test_70() {
+ local tf=$DIR/$tdir/$tfile
+
+ test_mkdir $DIR/$tdir
+
+ while true; do
+ rm -f $tf
+ $LFS mirror create -N -E 1M -c -1 -E eof -N $tf
+ echo xxxx > $tf
+ done &
+ c_pid=$!
+ echo "mirror create pid $c_pid"
+
+ while true; do
+ $LFS mirror split -d --mirror-id=1 $tf &> /dev/null
+ done &
+ s_pid=$!
+ echo "mirror split pid $s_pid"
+
+ echo "mirror create and split race for 60 seconds, should not crash"
+ sleep 60
+ kill -9 $c_pid &> /dev/null
+ kill -9 $s_pid &> /dev/null
+
+ rm -f $tf
+ true
+}
+run_test 70 "mirror create and split race"
+
+test_100() {
+ local tf=$DIR/$tdir/$tfile
+
+ (( $OST1_VERSION >= $(version_code 2.14.51) )) ||
+ skip "Need OST version at least 2.14.51"
+
+
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -N -E1M -c-1 -Eeof -c-1 $tf ||
+ error "setstripe $tf failed"
+
+ FSXNUM=${FSXNUM:-1000}
+ $FSX -p 5 -N $FSXNUM -S 0 -M $tf || error "fsx FLR file $tf failed"
+}
+run_test 100 "flr mode fsx test"
+
ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
lock_file=$(mktemp /var/lock/FLR.XXXXXX)
echo -n "resync file $tf with '$cmd' .."
if [[ $lock_taken = "true" ]]; then
- flock -x 200 -c "$cmd $tf &> /dev/null" &&
- echo "done" || echo "failed"
+ flock -x 200
+ $cmd $tf &> /dev/null && echo "done" || echo "failed"
flock -u 200
else
$cmd $tf &> /dev/null && echo "done" || echo "failed"
rm -f $ctrl_file
- echo "Waiting ${pids[@]}"
- wait ${pids[@]}
+ echo "Waiting ${pids[*]}"
+ wait "${pids[@]}"
umount_client $MOUNT2
umount_client $MOUNT3
rm -f $lock_file
# resync and verify mirrors
- mirror_io resync $tf
+ $LFS mirror resync $tf || error "final resync failed"
get_mirror_ids $tf
- local csum=$($LFS mirror read -N ${mirror_array[0]} $tf | md5sum)
- for id in ${mirror_array[@]:1}; do
+ local csum=$($LFS mirror read -N "${mirror_array[0]}" $tf | md5sum)
+
+ for id in "${mirror_array[@]:1}"; do
[ "$($LFS mirror read -N $id $tf | md5sum)" = "$csum" ] ||
error "checksum error for mirror $id"
done
[ $now -lt $((ts + delay)) ] && sleep $((ts + delay - now))
- mirror_io resync $file
+ $LFS mirror resync $file
echo "$file resync done"
done
#create 2 mirrors
$LFS mirror create -N2 -c1 $tf || error "create FLR file $tf"
#delete first mirror
- $LFS mirror split --mirror-id=1 -d $tf || error "delete first mirror"
+ $LFS mirror delete --mirror-id=1 $tf || error "delete first mirror"
$LFS getstripe $tf
local old_id=$($LFS getstripe --mirror-id=2 -I $tf)
local new_id=$($LFS getstripe --mirror-id=2 -I $tf)
count=$($LFS getstripe --mirror-id=2 -c $tf) ||
error "getstripe count of mirror 2"
- [[ x$oldid = x$newid ]] ||
+ [[ x$old_id = x$new_id ]] ||
error "mirror 2 changed ID from $old_id to $new_id"
[[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
# Simple test of FLR + self-extending layout, SEL in non-primary mirror
test_204a() {
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
skip "skipped for lustre < $SEL_VER"
local comp_file=$DIR/$tdir/$tfile
# Simple test of FLR + self-extending layout, SEL in primary mirror
test_204b() {
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
skip "skipped for lustre < $SEL_VER"
local comp_file=$DIR/$tdir/$tfile
# FLR + SEL failed extension & component removal
# extension space in second mirror
test_204c() {
- [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
skip "skipped for lustre < $SEL_VER"
local comp_file=$DIR/$tdir/$tfile
# Successful repeated component in primary mirror
test_204d() {
- [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
- skip "skipped for lustre < $SEL_VERSION"
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
+ skip "skipped for lustre < $SEL_VER"
local comp_file=$DIR/$tdir/$tfile
local found=""
# Successful repeated component, SEL in non-primary mirror
test_204e() {
- [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
- skip "skipped for lustre < $SEL_VERSION"
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
+ skip "skipped for lustre < $SEL_VER"
local comp_file=$DIR/$tdir/$tfile
local found=""
# FLR + SEL: failed repeated component, SEL in non-primary mirror
test_204f() {
- [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code $SEL_VER) ] &&
- skip "skipped for lustre < $SEL_VERSION"
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
+ skip "skipped for lustre < $SEL_VER"
local comp_file=$DIR/$tdir/$tfile
local found=""
}
run_test 204f "FLR write/stale/resync sel w/forced extension"
+function test_205() {
+ local tf=$DIR/$tfile
+ local mirrors
+
+ $LFS setstripe -c1 $tf
+ $LFS mirror extend -N $tf
+ mirrors=$($LFS getstripe $tf | grep lcme_mirror_id | wc -l )
+ (( $mirrors == 2 )) || error "no new mirror was created?"
+
+ $LFS mirror extend -N --flags=prefer $tf
+ mirrors=$($LFS getstripe $tf | grep lcme_mirror_id | wc -l )
+ (( $mirrors == 3 )) || error "no new mirror was created?"
+
+ $($LFS getstripe $tf | grep lcme_flags: | tail -1 | grep -q prefer) ||
+ error "prefer flag was not set on the new mirror"
+}
+run_test 205 "lfs mirror extend to set prefer flag"
+
+function test_206() {
+ # create a new OST pool
+ local pool_name=$TESTNAME
+
+ create_pool $FSNAME.$pool_name ||
+ error "create OST pool $pool_name failed"
+ # add OSTs into the pool
+ pool_add_targets $pool_name 0 1 ||
+ error "add OSTs into pool $pool_name failed"
+
+ $LFS setstripe -c1 --pool=$pool_name $DIR/$tfile ||
+ error "can't setstripe"
+ $LFS mirror extend -N $DIR/$tfile ||
+ error "can't create replica"
+ if $LFS getstripe $DIR/$tfile | grep -q prefer ; then
+ $LFS getstripe $DIR/$tfile
+ error "prefer found"
+ fi
+ $LFS setstripe --comp-set --comp-flags=prefer -p $pool_name $DIR/$tfile || {
+ $LFS getstripe $DIR/$tfile
+ error "can't setstripe prefer"
+ }
+
+ if ! $LFS getstripe $DIR/$tfile | grep -q prefer ; then
+ $LFS getstripe $DIR/$tfile
+ error "no prefer found"
+ fi
+
+ # destroy OST pool
+ destroy_test_pools
+}
+run_test 206 "lfs setstripe -pool .. --comp-flags=.. "
+
+test_207() {
+ local file=$DIR/$tfile
+ local tmpfile=$DIR/$tfile-tt
+
+ [ $MDS1_VERSION -lt $(version_code 2.14.50) ] &&
+ skip "Need MDS version at least 2.14.50"
+
+ stack_trap "rm -f $tmpfile $file"
+
+ # generate data for verification
+ dd if=/dev/urandom of=$tmpfile bs=1M count=1 ||
+ error "can't generate file with random data"
+
+ # create a mirrored file with one stale replica
+ $LFS mirror create -N -S 4M -c 2 -N -S 1M -c -1 $file ||
+ error "create mirrored file $file failed"
+ get_mirror_ids $file
+ echo "mirror IDs: ${mirror_array[*]}"
+
+ dd if=$tmpfile of=$file bs=1M || error "can't copy"
+ get_mirror_ids $file
+ echo "mirror IDs: ${mirror_array[*]}"
+
+ drop_client_cache
+ cmp $tmpfile $file || error "files don't match"
+ get_mirror_ids $file
+ echo "mirror IDs: ${mirror_array[*]}"
+
+ # mirror creation should work fine
+ $LFS mirror extend -N -S 8M -c -1 $file ||
+ error "mirror extend $file failed"
+
+ get_mirror_ids $file
+ echo "mirror IDs: ${mirror_array[*]}"
+
+ drop_client_cache
+ $LFS mirror verify -v $file || error "verification failed"
+ cmp $tmpfile $file || error "files don't match"
+}
+run_test 207 "create another replica with existing out-of-sync one"
+
+function check_ost_used() {
+ local ddarg
+ local ost
+ local i
+ local file=$1
+ local io=$2
+
+ shift 2
+
+ cancel_lru_locks osc # to drop pages
+ cancel_lru_locks mdc # to refresh layout
+ # XXX: cancel_lru_locks mdc doesn't work
+ # XXX: need a better way to reload the layout
+ umount_client $MOUNT || error "umount failed"
+ mount_client $MOUNT || error "mount failed"
+
+ # refresh non-rotation status on MDTs
+ sleep 10
+ touch $DIR/$tfile-temp
+ rm -f $DIR/$tfile-temp
+ # refresh non-rotational status on the client
+ $LFS df >&/dev/null
+ sleep 2
+
+ $LCTL set_param osc.*.stats=clear >/dev/null
+ if [[ $io == "read" ]]; then
+ ddarg="if=$file of=/dev/null"
+ elif [[ $io == "write" ]]; then
+ ddarg="if=/dev/zero of=$file"
+ else
+ error "unknown type $io"
+ fi
+ dd $ddarg bs=2M count=1 || error "can't $io $file"
+ cancel_lru_locks osc
+
+ # check only specified OSTs got reads
+ for ((ost = 0; ost < $OSTCOUNT; ost++)); do
+ local nr=$($LCTL get_param -n \
+ osc.$FSNAME-OST000$ost-osc-[-0-9a-f]*.stats |
+ awk "/ost_$io/{print \$2}")
+ nr=${nr:-0}
+ if [[ " $* " =~ $ost ]]; then
+ (( nr > 0 )) || error "expected reads on $ost"
+ else
+ (( nr == 0 )) || error "unexpected $nr reads on $ost"
+ fi
+ done
+}
+
+test_208a() {
+ local tf=$DIR/$tfile
+ local osts=$(comma_list $(osts_nodes))
+
+ (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
+ (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
+ skip "Need MDS version at least 2.14.55"
+
+ local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+ save_lustre_params $(get_facets OST) osd*.*OST*.nonrotational > $p
+ stack_trap "restore_lustre_params < $p; rm -f $p"
+
+ stack_trap "rm -f $tf"
+ $LFS setstripe -i0 -c1 $tf || error "can't setstripe"
+ dd if=/dev/zero of=$tf bs=2M count=1 || error "can't dd (1)"
+ $LFS mirror extend -N -c1 -o1 $tf || error "can't create mirror"
+ $LFS mirror extend -N -c2 -o 2,3 $tf || error "can't create mirror"
+ $LFS mirror resync $tf || error "can't resync"
+ $LFS getstripe $tf
+
+ log "set OST0000 non-rotational"
+ do_nodes $osts \
+ $LCTL set_param osd*.*OST0000*.nonrotational=1
+ check_ost_used $tf read 0
+
+ log "set OST0002 and OST0003 non-rotational, two fast OSTs is better"
+ do_nodes $osts \
+ $LCTL set_param osd*.*OST0002*.nonrotational=1 \
+ osd*.*OST0003*.nonrotational=1
+ check_ost_used $tf read 2 3
+
+ log "set mirror 1 on OST0001 preferred"
+ $LFS setstripe --comp-set -I 0x20001 --comp-flags=prefer $tf ||
+ error "can't set prefer"
+ check_ost_used $tf read 1
+}
+run_test 208a "mirror selection to prefer non-rotational devices for reads"
+
+test_208b() {
+ local tf=$DIR/$tfile
+ local osts=$(comma_list $(osts_nodes))
+
+ (( $OSTCOUNT >= 4 )) || skip "needs >= 4 OSTs"
+ (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
+ skip "Need MDS version at least 2.14.55"
+
+ local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+ save_lustre_params $(get_facets OST) osd*.*OST*.nonrotational > $p
+ stack_trap "restore_lustre_params < $p; rm -f $p"
+
+ stack_trap "rm -f $tf"
+ $LFS setstripe -i0 -c1 $tf || error "can't setstripe"
+ dd if=/dev/zero of=$tf bs=2M count=1 || error "can't dd (1)"
+ $LFS mirror extend -N -c1 -o1 $tf || error "can't create mirror"
+ $LFS mirror extend -N -c2 -o 2,3 $tf || error "can't create mirror"
+ $LFS mirror resync $tf || error "can't resync"
+ $LFS getstripe $tf | grep -q flags.*stale && error "still stale"
+
+ log "set OST0000 non-rotational"
+ do_nodes $osts \
+ $LCTL set_param osd*.*OST0000*.nonrotational=1
+ check_ost_used $tf write 0
+ $LFS mirror resync $tf || error "can't resync"
+
+ log "set OST0002 and OST0003 non-rotational, two fast OSTs is better"
+ do_nodes $osts \
+ $LCTL set_param osd*.*OST0002*.nonrotational=1 \
+ osd*.*OST0003*.nonrotational=1
+ check_ost_used $tf write 2 3
+ $LFS mirror resync $tf || error "can't resync"
+
+ log "set mirror 1 on OST0001 preferred"
+ $LFS setstripe --comp-set -I 0x20001 --comp-flags=prefer $tf ||
+ error "can't set prefer"
+ check_ost_used $tf write 1
+}
+run_test 208b "mirror selection to prefer non-rotational devices for writes"
+
complete $SECONDS
check_and_cleanup_lustre
exit_status