export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
ONLY=${ONLY:-"$*"}
-# Bug number for skipped test:
+# Bug number for skipped test: LU-11381
ALWAYS_EXCEPT="$SANITY_FLR_EXCEPT 201"
# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
done
for idx in "$@"; do
- wait_osc_import_state client ost$idx FULL
+ wait_recovery_complete ost$idx
done
}
local fl
local expected_list=$(comma_list $expected)
for fl in ${expected_list//,/ }; do
- echo $value | grep -q $fl || {
+ local neg=0
+
+ [[ ${fl:0:1} = "^" ]] && neg=1
+ [[ $neg = 1 ]] && fl=${fl:1}
+
+ $(echo $value | grep -q $fl)
+ local match=$?
+ # 0: matched; 1: not matched
+
+ if [[ $neg = 0 && $match != 0 ||
+ $neg = 1 && $match = 0 ]]; then
$getstripe_cmd $tf
- error "expected flag $fl existing on $comp_id"
- }
+ [[ $neg = 0 ]] && # expect the flag
+ error "expected flag '$fl' not in $comp_id"
+ [[ $neg = 1 ]] && # not expect the flag
+ error "not expected flag '$fl' in $comp_id"
+ fi
done
return
}
# assume the mirror id will be 1, 2, and 3
declare -A checksums
- checksums[1]=$(md5sum $tf | cut -f 1 -d' ')
- checksums[2]=$(md5sum $tf2 | cut -f 1 -d' ')
- checksums[3]=$(md5sum $tf3 | cut -f 1 -d' ')
+ checksums[1]=$(cat $tf | md5sum)
+ checksums[2]=$(cat $tf2 | md5sum)
+ checksums[3]=$(cat $tf3 | md5sum)
printf '%s\n' "${checksums[@]}"
local sum
for i in ${mirror_array[@]}; do
- sum=$(mirror_io dump -i $i $tf | md5sum | cut -f 1 -d' ')
+ sum=$($LFS mirror dump -N $i $tf | md5sum)
[ "$sum" = "${checksums[$i]}" ] ||
error "$i: mismatch: \'${checksums[$i]}\' vs. \'$sum\'"
done
# verify copying is successful by checking checksums
remount_client $MOUNT
for i in ${mirror_array[@]}; do
- sum=$(mirror_io dump -i $i $tf | md5sum | cut -f 1 -d' ')
+ sum=$($LFS mirror dump -N $i $tf | md5sum)
[ "$sum" = "${checksums[1]}" ] ||
error "$i: mismatch checksum after copy"
done
local fsize=$((RANDOM << 8 + 1048576))
$TRUNCATE $ref $fsize
- local ref_cksum=$(md5sum $ref | cut -f 1 -d' ')
+ local ref_cksum=$(cat $ref | md5sum)
# case 1: verify write to mirrored file & resync work
cp $ref $tf || error "copy from $ref to $f error"
verify_flr_state $tf "wp"
- local file_cksum=$(md5sum $tf | cut -f 1 -d' ')
+ local file_cksum=$(cat $tf | md5sum)
[ "$file_cksum" = "$ref_cksum" ] || error "write failed, cksum mismatch"
get_mirror_ids $tf
local valid_mirror stale_mirror id mirror_cksum
for id in "${mirror_array[@]}"; do
- mirror_cksum=$(mirror_io dump -i $id $tf |
- md5sum | cut -f 1 -d' ')
+ mirror_cksum=$($LFS mirror dump -N $id $tf | md5sum)
[ "$ref_cksum" == "$mirror_cksum" ] &&
{ valid_mirror=$id; continue; }
mirror_io resync $tf || error "resync failed"
verify_flr_state $tf "ro"
- mirror_cksum=$(mirror_io dump -i $stale_mirror $tf |
- md5sum | cut -f 1 -d' ')
+ mirror_cksum=$($LFS mirror dump -N $stale_mirror $tf | md5sum)
[ "$file_cksum" = "$ref_cksum" ] || error "resync failed"
# case 2: inject an error to make mirror_io exit after changing
# 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 ||
+ dd if=/dev/urandom of=$tf-1 bs=1M count=4 conv=notrunc ||
error "writing $tf-1 failed"
+ local sum0=$(cat $tf-1 | md5sum)
+
echo " **verify files be WRITE_PENDING"
verify_flr_state $tf "wp"
verify_flr_state $tf-1 "wp"
echo " **full resync"
$LFS mirror resync $tf $tf-1 || error "mirror resync $tf $tf-1 failed"
+ echo " **verify $tf-1 data consistency in all mirrors"
+ for i in 1 2 3; do
+ local sum=$($LFS mirror dump -N$i $tf-1 | md5sum)
+ [[ "$sum" = "$sum0" ]] ||
+ error "$tf-1.$i: checksum mismatch: $sum != $sum0"
+ done
+
echo " **verify files be RDONLY"
verify_flr_state $tf "ro"
verify_flr_state $tf-1 "ro"
}
run_test 47 "Verify mirror obj alloc"
+test_48() {
+ local tf=$DIR/$tfile
+
+ rm -f $tf
+ echo " ** create 2 mirrors FLR file $tf"
+ $LFS mirror create -N -E2M -Eeof --flags prefer \
+ -N -E1M -Eeof $tf ||
+ error "create FLR file $tf failed"
+
+ echo " ** write it"
+ dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed"
+ verify_flr_state $tf "wp"
+
+ local sum0=$(md5sum < $tf)
+
+ echo " ** resync the file"
+ $LFS mirror resync $tf
+
+ echo " ** snapshot mirror 2"
+ $LFS setstripe --comp-set -I 0x20003 --comp-flags=nosync $tf
+
+ echo " ** write it again"
+ dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed"
+ echo " ** resync it again"
+ $LFS mirror resync $tf
+
+ verify_flr_state $tf "wp"
+ verify_comp_attr lcme_flags $tf 0x20003 nosync,stale
+
+ local sum1=$($LFS mirror dump -N1 $tf | md5sum)
+ local sum2=$($LFS mirror dump -N2 $tf | md5sum)
+
+ echo " ** verify mirror 2 doesn't change"
+ echo "original checksum: $sum0"
+ echo "mirror 1 checksum: $sum1"
+ echo "mirror 2 checksum: $sum2"
+ [[ $sum0 = $sum2 ]] ||
+ error "original checksum: $sum0, mirror 2 checksum: $sum2"
+ echo " ** mirror 2 stripe info"
+ $LFS getstripe -v --mirror-index=2 $tf
+
+ echo " ** resync mirror 2"
+ $LFS mirror resync --only 2 $tf
+
+ verify_flr_state $tf "ro"
+ verify_comp_attr lcme_flags $tf 0x20003 nosync,^stale
+
+ sum1=$($LFS mirror dump -N1 $tf | md5sum)
+ sum2=$($LFS mirror dump -N2 $tf | md5sum)
+
+ echo " ** verify mirror 2 resync-ed"
+ echo "original checksum: $sum0"
+ echo "mirror 1 checksum: $sum1"
+ echo "mirror 2 checksum: $sum2"
+ [[ $sum1 = $sum2 ]] ||
+ error "mirror 1 checksum: $sum1, mirror 2 checksum: $sum2"
+ echo " ** mirror 2 stripe info"
+ $LFS getstripe -v --mirror-index=2 $tf
+}
+run_test 48 "Verify snapshot mirror"
+
ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
lock_file=$(mktemp /var/lock/FLR.XXXXXX)
echo -n "resync file $tf with '$cmd' .."
- $lock_taken && flock -x 200
- $cmd $tf &> /dev/null && echo "done" || echo "failed"
- $lock_taken && flock -u 200
+ if [[ $lock_taken = "true" ]]; then
+ flock -x 200 -c "$cmd $tf &> /dev/null" &&
+ echo "done" || echo "failed"
+ flock -u 200
+ else
+ $cmd $tf &> /dev/null && echo "done" || echo "failed"
+ fi
sleep 0.$((RANDOM % 8 + 1))
done
mirror_io resync $tf
get_mirror_ids $tf
- local csum=$(mirror_io dump -i ${mirror_array[0]} $tf | md5sum)
+ local csum=$($LFS mirror dump -N ${mirror_array[0]} $tf | md5sum)
for id in ${mirror_array[@]:1}; do
- [ "$(mirror_io dump -i $id $tf | md5sum)" = "$csum" ] ||
+ [ "$($LFS mirror dump -N $id $tf | md5sum)" = "$csum" ] ||
error "checksum error for mirror $id"
done
}
run_test 202 "lfs setstripe --add-component wide striping"
+test_203() {
+ [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+
+ local tf=$DIR/$tfile
+
+ #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 getstripe $tf
+ local old_id=$($LFS getstripe --mirror-id=2 -I $tf)
+ local count=$($LFS getstripe --mirror-id=2 -c $tf) ||
+ error "getstripe count of mirror 2"
+ [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
+
+ #extend a mirror with 2 OSTs
+ $LFS mirror extend -N -c2 $tf || error "extend mirror"
+ $LFS getstripe $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 ]] ||
+ error "mirror 2 changed ID from $old_id to $new_id"
+ [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
+
+ count=$($LFS getstripe --mirror-id=3 -c $tf) ||
+ error "getstripe count of mirror 3"
+ [[ x$count = x2 ]] || error "mirror 3 stripe count $count is not 2"
+}
+run_test 203 "mirror file preserve mirror ID"
+
complete $SECONDS
check_and_cleanup_lustre
exit_status