+test_38() {
+ local tf=$DIR/$tfile
+ local ref=$DIR/${tfile}-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 \
+ $tf-2 || error "creating $tf-2 failed"
+ $LFS setstripe -E 4M -c 1 -E 8M -c 2 -E eof -c -1 $tf-3 ||
+ error "creating $tf-3 failed"
+
+ # instantiate all components
+ $LFS mirror extend -N -f $tf-2 $tf ||
+ error "merging $tf-2 into $tf failed"
+ $LFS mirror extend -N -f $tf-3 $tf ||
+ error "merging $tf-3 into $tf failed"
+ $LFS mirror extend -N -c 1 $tf ||
+ error "extending mirrored file $tf failed"
+
+ verify_flr_state $tf "ro"
+
+ dd if=/dev/urandom of=$ref bs=1M count=16 &> /dev/null
+
+ local fsize=$((RANDOM << 8 + 1048576))
+ $TRUNCATE $ref $fsize
+
+ 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=$(cat $tf | md5sum)
+ [ "$file_cksum" = "$ref_cksum" ] || error "write failed, cksum mismatch"
+
+ get_mirror_ids $tf
+ echo "mirror IDs: ${mirror_array[@]}"
+
+ local valid_mirror stale_mirror id mirror_cksum
+ for id in "${mirror_array[@]}"; do
+ mirror_cksum=$($LFS mirror read -N $id $tf | md5sum)
+ [ "$ref_cksum" == "$mirror_cksum" ] &&
+ { valid_mirror=$id; continue; }
+
+ stale_mirror=$id
+ done
+
+ [ -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"
+ verify_flr_state $tf "ro"
+
+ mirror_cksum=$($LFS mirror read -N $stale_mirror $tf | md5sum)
+ [ "$file_cksum" = "$ref_cksum" ] || error "resync failed"
+
+ # case 2: inject an error to make mirror_io exit after changing
+ # the file state to sync_pending so that we can start a concurrent
+ # write.
+ $MULTIOP $tf oO_WRONLY:w$((RANDOM % 1048576 + 1024))c
+ verify_flr_state $tf "wp"
+
+ mirror_io resync -e resync_start $tf && error "resync succeeded"
+ verify_flr_state $tf "sp"
+
+ # from sync_pending to write_pending
+ $MULTIOP $tf oO_WRONLY:w$((RANDOM % 1048576 + 1024))c
+ verify_flr_state $tf "wp"
+
+ mirror_io resync -e resync_start $tf && error "resync succeeded"
+ verify_flr_state $tf "sp"
+
+ # from sync_pending to read_only
+ mirror_io resync $tf || error "resync failed"
+ verify_flr_state $tf "ro"
+}
+run_test 38 "resync"
+
+test_39() {
+ local tf=$DIR/$tfile
+
+ rm -f $tf
+ $LFS mirror create -N2 -E1m -c1 -S1M -E-1 $tf ||
+ error "create PFL file $tf failed"
+
+ verify_mirror_count $tf 2
+ verify_comp_count $tf 4
+
+ rm -f $tf || error "delete $tf failed"
+}
+run_test 39 "check FLR+PFL (a.k.a. PFLR) creation"
+
+test_40() {
+ local tf=$DIR/$tfile
+ local ops
+
+ for ops in "conv=notrunc" ""; do
+ rm -f $tf
+
+ $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 --flags=prefer \
+ -N -E 1M -E 2M -E 4M -E -1 $tf ||
+ error "create PFLR file $tf failed"
+ dd if=/dev/zero of=$tf $ops bs=1M seek=2 count=1 ||
+ error "write PFLR file $tf failed"
+
+ lfs getstripe -vy $tf
+
+ local flags
+
+ # file mirror state should be write_pending
+ flags=$($LFS getstripe -v $tf | awk '/lcm_flags:/ { print $2 }')
+ [ $flags = wp ] ||
+ error "file mirror state $flags"
+ # the 1st component (in mirror 1) should be inited
+ verify_comp_attr lcme_flags $tf 0x10001 init
+ # the 2nd component (in mirror 1) should be inited
+ verify_comp_attr lcme_flags $tf 0x10002 init
+ # the 3rd component (in mirror 1) should be uninited
+ verify_comp_attr lcme_flags $tf 0x10003 prefer
+ # the 4th component (in mirror 2) should be inited
+ verify_comp_attr lcme_flags $tf 0x20004 init
+ # the 5th component (in mirror 2) should be uninited
+ verify_comp_attr lcme_flags $tf 0x20005 0
+ # the 6th component (in mirror 2) should be stale
+ verify_comp_attr lcme_flags $tf 0x20006 stale
+ # the 7th component (in mirror 2) should be uninited
+ if [[ x$ops = "xconv=notrunc" ]]; then
+ verify_comp_attr lcme_flags $tf 0x20007 0
+ elif [[ x$ops = "x" ]]; then
+ verify_comp_attr lcme_flags $tf 0x20007 stale
+ fi
+ done
+
+ rm -f $tf || error "delete $tf failed"
+}
+run_test 40 "PFLR rdonly state instantiation check"
+
+test_41() {
+ local tf=$DIR/$tfile
+
+ 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 \
+ -N -E 1M -E 2M -E 3M -E -1 $tf ||
+ error "create PFLR file $tf failed"
+ $LFS mirror create -N -E 2M -S 1M -E eof \
+ -N -E 1M -E eof --flags prefer \
+ -N -E 4m -E eof $tf-1 ||
+ error "create PFLR file $tf-1 failed"
+
+ # file should be in ro status
+ echo " **verify files be RDONLY"
+ 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/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"
+
+ # file should have stale component
+ echo " **verify files 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"
+
+ 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 read -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"
+
+ # file should not have stale component
+ echo " **verify files do not contain 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"
+
+ # verify partial resync
+ echo " **write $tf-1 for partial resync test"
+ dd if=/dev/zero of=$tf-1 bs=1M count=2 conv=notrunc ||
+ error "writing $tf-1 failed"
+
+ echo " **only resync mirror 2"
+ verify_flr_state $tf-1 "wp"
+ $LFS mirror resync --only 2 $tf-1 ||
+ error "resync mirror 2 of $tf-1 failed"
+ verify_flr_state $tf "ro"
+
+ # resync synced mirror
+ echo " **resync mirror 2 again"
+ $LFS mirror resync --only 2 $tf-1 ||
+ error "resync mirror 2 of $tf-1 failed"
+ verify_flr_state $tf "ro"
+ echo " **verify $tf-1 contains stale component"
+ $LFS getstripe $tf-1 | grep lcme_flags | grep stale > /dev/null ||
+ error "after writing $tf-1, it does not contain stale component"
+
+ echo " **full resync $tf-1"
+ $LFS mirror resync $tf-1 || error "resync of $tf-1 failed"
+ verify_flr_state $tf "ro"
+ echo " **full resync $tf-1 again"
+ $LFS mirror resync $tf-1 || error "resync of $tf-1 failed"
+ echo " **verify $tf-1 does not contain stale component"
+ $LFS getstripe $tf | 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 -S 1M -E 10M -E EOF $tf ||
+ error "create mirrored file $tf failed"
+ $LFS mirror create -N -E 2M -S 1M -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 2M -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"
+
+# inactivate one OST && write && restore the OST
+write_file_43() {
+ local file=$1
+ local ost=$2
+ local PARAM="osp.${FSNAME}-OST000${ost}-osc-M*.active"
+ local wait
+
+ wait=$(do_facet $SINGLEMDS \
+ "$LCTL get_param -n lod.*MDT0000-*.qos_maxage")
+ wait=${wait%%[^0-9]*}
+
+ echo " **deactivate OST$ost, waiting for $((wait*2+2)) seconds"
+ $(do_facet $SINGLEMDS "$LCTL set_param -n $PARAM 0")
+ # lod_qos_statfs_update needs 2*$wait seconds to refresh targets statfs
+ sleep $(($wait * 2 + 2))
+ echo " **write $file"
+ dd if=/dev/zero of=$file bs=1M count=1 || error "write $file failed"
+ echo " **restore activating OST$ost, waiting for $((wait*2+2)) seconds"
+ $(do_facet $SINGLEMDS "$LCTL set_param -n $PARAM 1")
+ sleep $((wait * 2 + 2))
+
+ local flags=$($LFS getstripe -v $file | awk '/lcm_flags:/ { print $2 }')
+ [ $flags = wp ] || error "file mirror state $flags != wp"
+}
+
+test_43a() {
+ [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
+
+ local tf=$DIR/$tfile
+ local flags
+
+ rm -f $tf
+ ## mirror 0 ost (0, 1)
+ ## mirror 1 ost (1, 2)
+ ## mirror 2 ost (2, 0)
+ $LFS mirror create -N -Eeof -c2 -o0,1 -N -Eeof -c2 -o1,2 \
+ -N -Eeof -c2 -o2,0 $tf ||
+ error "create 3 mirrors file $tf failed"
+
+ ################## OST0 ###########################################
+ write_file_43 $tf 0
+ echo " **verify components"
+ verify_comp_attr lcme_flags $tf 0x10001 init,stale
+ verify_comp_attr lcme_flags $tf 0x20002 init
+ verify_comp_attr lcme_flags $tf 0x30003 init,stale
+
+ # resync
+ echo " **resync $tf"
+ $LFS mirror resync $tf
+ flags=$($LFS getstripe -v $tf | awk '/lcm_flags:/ { print $2 }')
+ [ $flags = ro ] || error "file mirror state $flags != ro"
+
+ ################## OST1 ###########################################
+ write_file_43 $tf 1
+ echo " **verify components"
+ verify_comp_attr lcme_flags $tf 0x10001 init,stale
+ verify_comp_attr lcme_flags $tf 0x20002 init,stale
+ verify_comp_attr lcme_flags $tf 0x30003 init
+
+ # resync
+ echo " **resync $tf"
+ $LFS mirror resync $tf
+ flags=$($LFS getstripe -v $tf | awk '/lcm_flags:/ { print $2 }')
+ [ $flags = ro ] || error "file mirror state $flags != ro"
+
+ ################## OST2 ###########################################
+ write_file_43 $tf 2
+ echo " **verify components"
+ verify_comp_attr lcme_flags $tf 0x10001 init
+ verify_comp_attr lcme_flags $tf 0x20002 init,stale
+ verify_comp_attr lcme_flags $tf 0x30003 init,stale
+}
+run_test 43a "mirror pick on write"
+
+test_43b() {
+ local tf=$DIR/$tdir/$tfile
+
+ test_mkdir $DIR/$tdir
+ rm -f $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_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 -E 2M -S 1M -E 4M -E -1 \
+ -N -E 1M -E 2M -E 3M -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"
+
+ # 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_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 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 "destroying 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"
+
+test_45() {
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+
+ local file=$DIR/$tdir/$tfile
+ local dir=$DIR/$tdir/$dir
+ local temp=$DIR/$tdir/template
+ rm -rf $DIR/$tdir
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
+ -N -E3m -S1m -Eeof -N -E8m -Eeof $file ||
+ error "Create $file failed"
+
+ verify_yaml_layout $file $file.copy $temp "1. FLR file"
+ rm -f $file $file.copy
+
+ $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
+ -N -E3m -S1m -Eeof -N -E8m --flags=prefer -Eeof $file ||
+ error "Create $file failed"
+
+ verify_yaml_layout $file $file.copy $temp "2. FLR file with flags"
+}
+run_test 45 "Verify setstripe/getstripe with YAML with FLR file"
+
+verify_46() {
+ local src=$1
+ local dst=$2
+ local msg_prefix=$3
+
+ $LFS setstripe --copy=$src $dst || error "setstripe $dst failed"
+
+ local layout1=$(get_layout_param $src)
+ local layout2=$(get_layout_param $dst)
+ # compare their layout info
+ [ "$layout1" == "$layout2" ] ||
+ error "$msg_prefix $src <=> $dst layouts are not equal"
+}
+
+test_46() {
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+
+ local file=$DIR/$tdir/$tfile
+ test_mkdir $DIR/$tdir
+
+ ########################### 1. PFL file #############################
+ echo " ** 1. PFL file"
+ rm -f $file
+ $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
+ $file || error "1. Create PFL $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "1. PFL file"
+
+ ########################### 2. plain file ###########################
+ echo " ** 2. plain file"
+ rm -f $file
+ $LFS setstripe -c2 -o0,1 -i1 $file ||
+ error "2. Create plain $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "2. plain file"
+
+ ########################### 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"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "3. FLR file"
+
+ local dir=$DIR/$tdir/dir
+ ########################### 4. PFL dir ##############################
+ echo " ** 4. PFL dir"
+ test_mkdir $dir
+ $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
+ error "4. setstripe PFL $dir failed"
+
+ test_mkdir $dir.copy
+ verify_46 $dir $dir.copy "4. PFL dir"
+
+ ########################### 5. plain dir ############################
+ echo " ** 5. plain dir"
+ $LFS setstripe -c2 -i-1 $dir || error "5. setstripe plain $dir failed"
+
+ verify_46 $dir $dir.copy "5. plain dir"
+
+ ########################### 6. FLR dir ##############################
+ echo " ** 6. FLR dir"
+ $LFS setstripe -N -E1m -S 1M -c2 -E2m -c1 -Eeof -N -E4m -Eeof $dir ||
+ error "6. setstripe FLR $dir failed"
+
+ verify_46 $dir $dir.copy "6. FLR dir"
+
+ ########################### 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"
+
+test_47() {
+ [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
+
+ local file=$DIR/$tdir/$tfile
+ local ids
+ local ost
+ local osts
+
+ test_mkdir $DIR/$tdir
+
+ # test case 1:
+ rm -f $file
+ # mirror1: [comp0]ost0, [comp1]ost1 and ost2
+ # mirror2: [comp2] , [comp3] should not use ost1 or ost2
+ $LFS mirror create -N -E2m -c1 -o0 --flags=prefer -Eeof -c2 -o1,2 \
+ -N -E2m -c1 -Eeof -c1 $file || error "create FLR $file failed"
+ ids=($($LFS getstripe $file | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+
+ dd if=/dev/zero of=$file bs=1M count=3 || error "dd $file failed"
+ $LFS mirror resync $file || error "resync $file failed"
+
+ ost=$($LFS getstripe -I${ids[2]} $file | awk '/l_ost_idx/{print $5}')
+ if [[ x$ost == "x0," ]]; then
+ $LFS getstripe $file
+ error "component ${ids[2]} objects allocated on $ost " \
+ "shouldn't on OST0"
+ fi
+
+ ost=$($LFS getstripe -I${ids[3]} $file | awk '/l_ost_idx/{print $5}')
+ if [[ x$ost == "x1," || x$ost == "x2," ]]; then
+ $LFS getstripe $file
+ error "component ${ids[3]} objects allocated on $ost " \
+ "shouldn't on OST1 or on OST2"
+ fi
+
+ ## test case 2:
+ rm -f $file
+ # mirror1: [comp0] [comp1]
+ # mirror2: [comp2] [comp3]
+ # mirror3: [comp4] [comp5]
+ # mirror4: [comp6] [comp7]
+ $LFS mirror create -N4 -E1m -c1 -Eeof -c1 $file ||
+ error "create FLR $file failed"
+ ids=($($LFS getstripe $file | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+
+ dd if=/dev/zero of=$file bs=1M count=3 || error "dd $file failed"
+ $LFS mirror resync $file || error "resync $file failed"
+
+ for ((i = 0; i < 6; i++)); do
+ osts[$i]=$($LFS getstripe -I${ids[$i]} $file |
+ awk '/l_ost_idx/{print $5}')
+ done
+ # comp[0],comp[2],comp[4] should use different osts
+ if [[ ${osts[0]} == ${osts[2]} || ${osts[0]} == ${osts[4]} ||
+ ${osts[2]} == ${osts[4]} ]]; then
+ $LFS getstripe $file
+ error "component ${ids[0]}, ${ids[2]}, ${ids[4]} have objects "\
+ "allocated on duplicated OSTs"
+ fi
+ # comp[1],comp[3],comp[5] should use different osts
+ if [[ ${osts[1]} == ${osts[3]} || ${osts[1]} == ${osts[5]} ||
+ ${osts[3]} == ${osts[5]} ]]; then
+ $LFS getstripe $file
+ error "component ${ids[1]}, ${ids[3]}, ${ids[5]} have objects "\
+ "allocated on duplicated OSTs"
+ fi
+
+ return 0
+}
+run_test 47 "Verify mirror obj alloc"
+
+test_48() {
+ [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
+ skip "Need MDS version at least 2.11.55"
+
+ 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 read -N1 $tf | md5sum)
+ local sum2=$($LFS mirror read -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 read -N1 $tf | md5sum)
+ sum2=$($LFS mirror read -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"
+
+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_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"
+
+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"
+
+ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
+lock_file=$(mktemp /var/lock/FLR.XXXXXX)
+
+write_file_200() {
+ local tf=$1
+
+ local fsize=$(stat --printf=%s $tf)
+
+ while [ -f $ctrl_file ]; do
+ local off=$((RANDOM << 8))
+ local len=$((RANDOM << 5 + 131072))
+
+ [ $((off + len)) -gt $fsize ] && {
+ fsize=$((off + len))
+ echo "Extending file size to $fsize .."
+ }
+
+ flock -s $lock_file -c \
+ "$MULTIOP $tf oO_WRONLY:z${off}w${len}c" ||
+ { rm -f $ctrl_file;
+ error "failed writing to $off:$len"; }
+ sleep 0.$((RANDOM % 2 + 1))
+ done
+}
+
+read_file_200() {
+ local tf=$1
+
+ while [ -f $ctrl_file ]; do
+ flock -s $lock_file -c "cat $tf &> /dev/null" ||
+ { rm -f $ctrl_file; error "read failed"; }
+ sleep 0.$((RANDOM % 2 + 1))
+ done
+}
+
+resync_file_200() {
+ local tf=$1
+
+ options=("" "-e resync_start" "-e delay_before_copy -d 1" "" "")
+
+ exec 200<>$lock_file
+ while [ -f $ctrl_file ]; do
+ 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
+ lock_taken=true
+ echo -n "lock to "
+ }
+
+ 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 -u 200
+ else
+ $cmd $tf &> /dev/null && echo "done" || echo "failed"
+ fi
+
+ sleep 0.$((RANDOM % 8 + 1))
+ done
+}
+
+test_200() {
+ local tf=$DIR/$tfile
+ local tf2=$DIR2/$tfile
+ local tf3=$DIR3/$tfile
+
+ $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E 4M -E 16M -E eof $tf
+ $LFS setstripe -E 2M -S 1M -E 6M -c 2 -E 8M -E 32M -E eof $tf-2
+ $LFS setstripe -E 4M -c 2 -E 8M -E 64M -E eof $tf-3
+
+ $LFS mirror extend -N -f $tf-2 $tf ||
+ error "merging $tf-2 into $tf failed"
+ $LFS mirror extend -N -f $tf-3 $tf ||
+ error "merging $tf-3 into $tf failed"
+
+ mkdir -p $MOUNT2 && mount_client $MOUNT2
+
+ mkdir -p $MOUNT3 && mount_client $MOUNT3
+
+ verify_flr_state $tf3 "ro"
+
+ #define OBD_FAIL_FLR_RANDOM_PICK_MIRROR 0x1A03
+ $LCTL set_param fail_loc=0x1A03
+
+ local mds_idx=mds$(($($LFS getstripe -m $tf) + 1))
+ do_facet $mds_idx $LCTL set_param fail_loc=0x1A03
+
+ declare -a pids
+
+ write_file_200 $tf &
+ pids+=($!)
+
+ read_file_200 $tf &
+ pids+=($!)
+
+ write_file_200 $tf2 &
+ pids+=($!)
+
+ read_file_200 $tf2 &
+ pids+=($!)
+
+ resync_file_200 $tf3 &
+ pids+=($!)
+
+ local sleep_time=60
+ [ "$SLOW" = "yes" ] && sleep_time=360
+ while [ $sleep_time -gt 0 -a -f $ctrl_file ]; do
+ sleep 1
+ ((--sleep_time))
+ done
+
+ rm -f $ctrl_file
+
+ echo "Waiting ${pids[@]}"
+ wait ${pids[@]}
+
+ umount_client $MOUNT2
+ umount_client $MOUNT3
+
+ rm -f $lock_file
+
+ # resync and verify mirrors
+ mirror_io resync $tf
+ get_mirror_ids $tf
+
+ 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
+
+ true
+}
+run_test 200 "stress test"
+
+cleanup_test_201() {
+ trap 0
+ do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
+
+ umount_client $MOUNT2
+}
+
+test_201() {
+ local delay=${RESYNC_DELAY:-5}
+
+ MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
+ awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
+
+ trap cleanup_test_201 EXIT
+
+ CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+ changelog_register -n)
+
+ mkdir -p $MOUNT2 && mount_client $MOUNT2
+
+ local index=0
+ while :; do
+ local log=$($LFS changelog $MDT0 $index | grep FLRW)
+ [ -z "$log" ] && { sleep 1; continue; }
+
+ index=$(echo $log | awk '{print $1}')
+ local ts=$(date -d "$(echo $log | awk '{print $3}')" "+%s" -u)
+ local fid=$(echo $log | awk '{print $6}' | sed -e 's/t=//')
+ local file=$($LFS fid2path $MOUNT2 $fid 2> /dev/null)
+
+ ((++index))
+ [ -z "$file" ] && continue
+
+ local now=$(date +%s)
+
+ echo "file: $file $fid was modified at $ts, now: $now, " \
+ "will be resynced at $((ts+delay))"
+
+ [ $now -lt $((ts + delay)) ] && sleep $((ts + delay - now))
+
+ mirror_io resync $file
+ echo "$file resync done"
+ done
+
+ cleanup_test_201
+}
+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 -S 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"
+
+test_203() {
+ [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
+ skip "Need MDS version at least 2.11.55"
+ [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs"
+
+ local tf=$DIR/$tfile
+
+ #create 2 mirrors
+ $LFS mirror create -N2 -c1 $tf || error "create FLR file $tf"
+ #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 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"
+
+# Simple test of FLR + self-extending layout, SEL in non-primary mirror
+test_204a() {
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
+ skip "skipped for lustre < $SEL_VER"
+
+ local comp_file=$DIR/$tdir/$tfile
+ local flg_opts=""
+ local found=""
+
+ test_mkdir $DIR/$tdir
+
+ # first mirror is 0-10M, then 10M-(-1), second mirror is 1M followed
+ # by extension space to -1
+ $LFS setstripe -N -E 10M -E-1 -N -E 1M -E-1 -z64M $comp_file ||
+ error "Create $comp_file failed"
+
+ # Write to first component, extending & staling second mirror
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc ||
+ error "dd to extend + stale failed"
+
+ $LFS getstripe $comp_file
+
+ flg_opts="--component-flags init,stale"
+ found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: Second comp end incorrect"
+
+ flg_opts="--component-flags extension"
+ found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: Third comp start incorrect"
+
+ # mirror resync should not change the extents
+ $LFS mirror resync $comp_file
+
+ flg_opts="--component-flags init"
+ found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: Second comp end incorrect"
+
+ flg_opts="--component-flags extension"
+ found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: Third comp start incorrect"
+
+ sel_layout_sanity $comp_file 5
+
+ rm -f $comp_file
+}
+run_test 204a "FLR write/stale/resync tests with self-extending mirror"
+
+# Simple test of FLR + self-extending layout, SEL in primary mirror
+test_204b() {
+ [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
+ skip "skipped for lustre < $SEL_VER"
+
+ local comp_file=$DIR/$tdir/$tfile
+ local flg_opts=""
+ local found=""
+
+ test_mkdir $DIR/$tdir
+
+ # first mirror is 1M followed by extension space to -1, second mirror
+ # is 0-10M, then 10M-(-1),
+ $LFS setstripe -N -E 1M -E-1 -z64M -N -E 10M -E-1 $comp_file ||
+ error "Create $comp_file failed"
+
+ # Write to first component, extending first component & staling
+ # other mirror
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc ||
+ error "dd to extend + stale failed"
+
+ $LFS getstripe $comp_file
+
+ flg_opts="--component-flags init"
+ found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: First comp end incorrect"
+
+ flg_opts="--component-flags extension"
+ found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: Second comp start incorrect"
+
+ flg_opts="--component-flags init,stale"
+ found=$($LFS find --component-end 10M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: First mirror comp flags incorrect"
+
+ # This component is staled because it overlaps the extended first
+ # component of the primary mirror, even though it doesn't overlap
+ # the actual write - thus not inited.
+ flg_opts="--component-flags stale"
+ found=$($LFS find --component-start 10M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: Second mirror comp flags incorrect"
+
+ # mirror resync should not change the extents
+ $LFS mirror resync $comp_file
+
+ $LFS getstripe $comp_file
+
+ flg_opts="--component-flags init"
+ found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: First comp end incorrect"
+
+ flg_opts="--component-flags extension"
+ found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: Second comp start incorrect"
+
+ flg_opts="--component-flags init"
+ found=$($LFS find --component-end 10M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: First mirror comp flags incorrect"
+
+ flg_opts="--component-flags init"
+ found=$($LFS find --component-start 10M $flg_opts $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: Second mirror comp flags incorrect"
+
+ sel_layout_sanity $comp_file 5
+
+ rm -f $comp_file
+}
+run_test 204b "FLR write/stale/resync tests with self-extending primary"
+
+# FLR + SEL failed extension & component removal
+# extension space in second mirror
+test_204c() {
+ [ $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=""
+ local ost_idx1=0
+ local ost_name=$(ostname_from_index $ost_idx1)
+
+ test_mkdir $DIR/$tdir
+
+ # first mirror is is 0-10M, then 10M-(-1), second mirror is 0-1M, then
+ # extension space from 1M to 1G, then normal space to -1
+ $LFS setstripe -N -E 10M -E-1 -N -E 1M -E 1G -i $ost_idx1 -z 64M \
+ -E -1 $comp_file || error "Create $comp_file failed"
+
+ do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
+ sleep_maxage
+
+ # write to first comp (0 - 10M) of mirror 1, extending + staling
+ # first + second comp of mirror 2
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
+ RC=$?
+
+ do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
+ sleep_maxage
+
+ [ $RC -eq 0 ] || error "dd to extend + stale failed"
+
+ $LFS getstripe $comp_file
+
+ found=$($LFS find --component-start 0m --component-end 1m \
+ --comp-flags init,stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: First mirror comp incorrect"
+
+ found=$($LFS find --component-start 1m --component-end EOF \
+ --comp-flags stale,^init $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: Second mirror comp incorrect"
+
+ local mirror_id=$($LFS getstripe --component-start=1m \
+ --component-end=EOF $comp_file | \
+ grep lcme_mirror_id | awk '{ print $2 }')
+
+ [[ $mirror_id -eq 2 ]] ||
+ error "component not in correct mirror? $mirror_id"
+
+ $LFS mirror resync $comp_file
+
+ $LFS getstripe $comp_file
+
+ # component dimensions should not change from resync
+ found=$($LFS find --component-start 1m --component-end EOF \
+ --component-flags init $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: Second mirror comp incorrect"
+
+ sel_layout_sanity $comp_file 4
+
+ rm -f $comp_file
+}
+run_test 204c "FLR write/stale/resync test with component removal"
+
+# Successful repeated component in primary mirror
+test_204d() {
+ [ $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=""
+
+ wait_delete_completed
+ wait_mds_ost_sync
+ test_mkdir $DIR/$tdir
+
+ # first mirror is 64M followed by extension space to -1, second mirror
+ # is 0-10M, then 10M-(-1)
+ $LFS setstripe -N -E-1 -z64M -N -E 10M -E-1 $comp_file ||
+ error "Create $comp_file failed"
+
+ local ost_idx1=$($LFS getstripe -I65537 -i $comp_file)
+ local ost_name=$(ostname_from_index $ost_idx1)
+ # degrade OST for first comp so we won't extend there
+ do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
+ obdfilter.$ost_name.degraded=1
+ sleep_maxage
+
+ # Write beyond first component, causing repeat & stale second mirror
+ dd if=/dev/zero bs=1M count=1 seek=66 of=$comp_file conv=notrunc
+ RC=$?
+
+ do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
+ obdfilter.$ost_name.degraded=0
+ sleep_maxage
+
+ [ $RC -eq 0 ] || error "dd to repeat & stale failed"
+
+ $LFS getstripe $comp_file
+
+ found=$($LFS find --component-start 64m --component-end 128m \
+ --component-flags init $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: Repeat comp incorrect"
+
+ local ost_idx2=$($LFS getstripe --component-start=64m \
+ --component-end=128m --component-flags=init \
+ -i $comp_file)
+ [[ $ost_idx1 -eq $ost_idx2 ]] && error "$ost_idx1 == $ost_idx2"
+ local mirror_id=$($LFS getstripe --component-start=64m \
+ --component-end=128m --component-flags=init \
+ $comp_file | grep lcme_mirror_id | awk '{ print $2 }')
+ [[ $mirror_id -eq 1 ]] ||
+ error "component not in correct mirror: $mirror_id, not 1"
+
+ $LFS mirror resync $comp_file
+
+ $LFS getstripe $comp_file
+
+ # component dimensions should not change from resync
+ found=$($LFS find --component-start 0m --component-end 64m \
+ --component-flags init $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: first comp incorrect"
+ found=$($LFS find --component-start 64m --component-end 128m \
+ --component-flags init $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: repeat comp incorrect"
+
+ sel_layout_sanity $comp_file 5
+
+ rm -f $comp_file
+}
+run_test 204d "FLR write/stale/resync sel test with repeated comp"
+
+# Successful repeated component, SEL in non-primary mirror
+test_204e() {
+ [ $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=""
+
+ wait_delete_completed
+ wait_mds_ost_sync
+
+ test_mkdir $DIR/$tdir
+
+ # first mirror is is 0-100M, then 100M-(-1), second mirror is extension
+ # space to -1 (-z 64M, so first comp is 0-64M)
+ # Note: we have to place both 1st components on OST0, otherwise 2 OSTs
+ # will be not enough - one will be degraded, the other is used on
+ # an overlapping mirror.
+ $LFS setstripe -N -E 100M -i 0 -E-1 -N -E-1 -i 0 -z 64M $comp_file ||
+ error "Create $comp_file failed"
+
+ local ost_idx1=$($LFS getstripe --component-start=0 \
+ --component-end=64m -i $comp_file)
+ local ost_name=$(ostname_from_index $ost_idx1)
+ # degrade OST for first comp of 2nd mirror so we won't extend there
+ do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
+ obdfilter.$ost_name.degraded=1
+ sleep_maxage
+
+ $LFS getstripe $comp_file
+
+ # Write to first component, stale & instantiate second mirror components
+ # overlapping with the written component (0-100M);
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
+ RC=$?
+
+ do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
+ obdfilter.$ost_name.degraded=0
+ sleep_maxage
+ $LFS getstripe $comp_file
+
+ [ $RC -eq 0 ] || error "dd to repeat & stale failed"
+
+ found=$($LFS find --component-start 0m --component-end 64m \
+ --component-flags init,stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: first comp incorrect"
+
+ # was repeated due to degraded ost
+ found=$($LFS find --component-start 64m --component-end 128m \
+ --component-flags init,stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: repeated comp incorrect"
+
+ local ost_idx2=$($LFS getstripe --component-start=64m \
+ --component-end=128m --component-flags=init \
+ -i $comp_file)
+ [[ $ost_idx1 -eq $ost_idx2 ]] && error "$ost_idx1 == $ost_idx2"
+ local mirror_id=$($LFS getstripe --component-start=0m \
+ --component-end=64m --component-flags=init \
+ $comp_file | grep lcme_mirror_id | awk '{ print $2 }')
+ [[ $mirror_id -eq 2 ]] ||
+ error "component not in correct mirror? $mirror_id"
+
+ $LFS mirror resync $comp_file
+
+ $LFS getstripe $comp_file
+
+ # component dimensions should not change from resync
+ found=$($LFS find --component-start 0m --component-end 64m \
+ --component-flags init,^stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: first comp incorrect"
+ found=$($LFS find --component-start 64m --component-end 128m \
+ --component-flags init,^stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: repeated comp incorrect"
+
+ sel_layout_sanity $comp_file 5
+
+ rm -f $comp_file
+}
+run_test 204e "FLR write/stale/resync sel test with repeated comp"
+
+# FLR + SEL: failed repeated component, SEL in non-primary mirror
+test_204f() {
+ [ $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=""
+
+ wait_delete_completed
+ wait_mds_ost_sync
+ test_mkdir $DIR/$tdir
+
+ pool_add $TESTNAME || error "Pool creation failed"
+ pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
+
+ # first mirror is is 0-100M, then 100M-(-1), second mirror is extension
+ # space to -1 (-z 64M, so first comp is 0-64M)
+ $LFS setstripe -N -E 100M -E-1 -N --pool="$TESTNAME" \
+ -E-1 -c 1 -z 64M $comp_file || error "Create $comp_file failed"
+
+ local ost_name0=$(ostname_from_index 0)
+ local ost_name1=$(ostname_from_index 1)
+
+ # degrade both OSTs in pool, so we'll try to repeat, then fail and
+ # extend original comp
+ do_facet ost1 $LCTL set_param -n obdfilter.$ost_name0.degraded=1
+ do_facet ost2 $LCTL set_param -n obdfilter.$ost_name1.degraded=1
+ sleep_maxage
+
+ # a write to the 1st component, 100M length, which will try to stale
+ # the first 100M of mirror 2, attempting to extend its 0-64M component
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
+ RC=$?
+
+ do_facet ost1 $LCTL set_param -n obdfilter.$ost_name0.degraded=0
+ do_facet ost2 $LCTL set_param -n obdfilter.$ost_name1.degraded=0
+ sleep_maxage
+
+ [ $RC -eq 0 ] || error "dd to extend mirror comp failed"
+
+ $LFS getstripe $comp_file
+
+ found=$($LFS find --component-start 0m --component-end 128m \
+ --component-flags init,stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "write: First mirror comp incorrect"
+
+ local mirror_id=$($LFS getstripe --component-start=0m \
+ --component-end=128m --component-flags=init \
+ $comp_file | grep lcme_mirror_id | awk '{ print $2 }')
+
+ [[ $mirror_id -eq 2 ]] ||
+ error "component not in correct mirror? $mirror_id, not 2"
+
+ $LFS mirror resync $comp_file
+
+ $LFS getstripe $comp_file
+
+ # component dimensions should not change from resync
+ found=$($LFS find --component-start 0m --component-end 128m \
+ --component-flags init,^stale $comp_file | wc -l)
+ [ $found -eq 1 ] || error "resync: First mirror comp incorrect"
+
+ sel_layout_sanity $comp_file 4
+
+ rm -f $comp_file
+}
+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"
+