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-14818 LU-11381
-ALWAYS_EXCEPT+=" 6 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!
# skip all tests for PPC until we can get sanity-pfl to pass
if [[ "$ost1_FSTYPE" == "zfs" ]]; then
# bug #: LU-1941
- ALWAYS_EXCEPT+="49a"
+ ALWAYS_EXCEPT+=" 49a "
fi
build_test_filter
verify_comp_extent $tf-3 ${ids[$i]} 0 EOF
done
- $mirror_cmd -N $tf-3 &> /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"
$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 || "read mirror 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 || "write 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"
$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
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\'"
[ "$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
}
run_test 43b "allow writing to multiple preferred mirror file"
-test_44() {
+test_44a() {
[ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
rm -rf $DIR/$tdir
rm -rf $DIR/$tdir-1
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
}
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"
if [[ "$FSTYPE" == "ldiskfs" ]]; then
# ZFS does not support fallocate for now
- fallocate -p -o 1MiB -l 1MiB $tf ||
- error "punch hole in $tf failed"
+ out=$(fallocate -p -o 1MiB -l 1MiB $tf 2>&1) ||
+ skip_eopnotsupp "$out|punch hole in $tf failed"
verify_flr_state $tf "wp"
fi
}
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"
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[@]}
+ 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[@]}
+ check_times_61 $file "${tim[@]}"
echo "migrate $tfile and test timestamps"
$LFS migrate -n $file || error "cannot migrate $file"
- check_times_61 $file ${tim[@]}
+ 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[@]}
+ check_times_61 $file "${tim[@]}"
}
run_test 61a "mirror extend and migrate preserve timestamps"
echo "mirror extend $tfile and test timestamps"
$LFS mirror extend -N -c1 -i1 $file ||
error "cannot extend mirror $file"
- check_times_61 $file ${tim[@]}
+ 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[@]}
+ 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[@]}
+ check_times_61 $file "${tim[@]}"
}
run_test 61b "mirror extend and split preserve timestamps"
tim=( $(get_times_61 $file) )
sleep $nap
$LFS mirror resync $file || error "cannot resync mirror $file"
- check_times_61 $file ${tim[@]}
+ 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[@]}
+ check_times_61 $file "${tim[@]}"
}
run_test 61c "mirror resync preserves timestamps"
}
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)
rm -f $ctrl_file
- echo "Waiting ${pids[@]}"
- wait ${pids[@]}
+ echo "Waiting ${pids[*]}"
+ wait "${pids[@]}"
umount_client $MOUNT2
umount_client $MOUNT3
$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
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"
$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[@]}"
+ 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[@]}"
+ 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[@]}"
+ 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[@]}"
+ echo "mirror IDs: ${mirror_array[*]}"
drop_client_cache
$LFS mirror verify -v $file || error "verification failed"
}
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