3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
16 ALWAYS_EXCEPT="$SANITY_FLR_EXCEPT "
17 # Bug number for skipped test: LU-11381
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
23 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
24 skip "Need MDS version at least 2.10.56"
26 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
27 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
28 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
30 check_and_setup_lustre
35 rm -rf $DIR/[Rdfs][0-9]*
37 # global array to store mirror IDs
38 declare -a mirror_array
45 for id in $($LFS getstripe $tf | awk '/lcme_id/{print $2}'); do
46 array[${#array[@]}]=$((id >> 16))
49 mirror_array=($(printf "%s\n" "${array[@]}" | sort -u))
51 echo ${#mirror_array[@]}
55 echo 3 > /proc/sys/vm/drop_caches
66 wait_osc_import_state client ost$idx "\(DISCONN\|IDLE\)"
74 start ost$idx $(ostdevname $idx) $OST_MOUNT_OPTS ||
75 error "start ost$idx failed"
79 wait_recovery_complete ost$idx
84 # Verify mirror count with an expected value for a given file.
86 verify_mirror_count() {
89 local mirror_count=$($LFS getstripe -N $tf)
91 [[ $mirror_count = $expected ]] || {
93 error "verify mirror count failed on $tf:" \
94 "$mirror_count != $expected"
99 # Verify component count with an expected value for a given file.
100 # $1 coposited layout file
101 # $2 expected component number
103 verify_comp_count() {
106 local comp_count=$($LFS getstripe --component-count $tf)
108 [[ $comp_count = $expected ]] || {
109 $LFS getstripe -v $tf
110 error "verify component count failed on $tf:" \
111 "$comp_count != $expected"
116 # Verify component attribute with an expected value for a given file
124 local cmd="$LFS getstripe -I$comp_id"
125 local getstripe_cmd="$cmd -v"
129 stripe-size) cmd+=" -S $tf" ;;
130 stripe-count) cmd+=" -c $tf" ;;
131 stripe-index) cmd+=" -i $tf" ;;
132 pool) cmd+=" -p $tf" ;;
133 comp-start) cmd+=" --component-start $tf" ;;
134 comp-end) cmd+=" --component-end $tf" ;;
135 lcme_flags) cmd+=" $tf | awk '/lcme_flags:/ { print \$2 }'" ;;
136 *) error "invalid attribute $attr";;
141 [ $attr = lcme_flags ] && {
143 local expected_list=$(comma_list $expected)
144 for fl in ${expected_list//,/ }; do
147 [[ ${fl:0:1} = "^" ]] && neg=1
148 [[ $neg = 1 ]] && fl=${fl:1}
150 $(echo $value | grep -q $fl)
152 # 0: matched; 1: not matched
154 if [[ $neg = 0 && $match != 0 ||
155 $neg = 1 && $match = 0 ]]; then
157 [[ $neg = 0 ]] && # expect the flag
158 error "expected flag '$fl' not in $comp_id"
159 [[ $neg = 1 ]] && # not expect the flag
160 error "not expected flag '$fl' in $comp_id"
166 [[ $value = $expected ]] || {
168 error "verify $attr failed on $tf: $value != $expected"
173 # Verify component extent with expected start and end extent values
174 # for a given file and component ID.
176 verify_comp_extent() {
179 local expected_start=$3
180 local expected_end=$4
182 verify_comp_attr comp-start $tf $comp_id $expected_start
183 verify_comp_attr comp-end $tf $comp_id $expected_end
187 # Verify component attribute with parent directory for a given file
190 verify_comp_attr_with_parent() {
194 local td=$(cd $(dirname $tf); echo $PWD)
195 local tf_cmd="$LFS getstripe -I$comp_id"
196 local td_cmd="$LFS getstripe"
202 stripe-size) opt="-S" ;;
203 stripe-count) opt="-c" ;;
205 *) error "invalid attribute $attr";;
208 expected=$($td_cmd $opt $td)
209 [[ $expected = -1 ]] && expected=$OSTCOUNT
211 value=$($tf_cmd $opt $tf)
212 [[ $value = -1 ]] && value=$OSTCOUNT
214 [[ $value = $expected ]] || {
217 error "verify $attr failed with parent on $tf:" \
218 "$value != $expected"
223 # Verify component attribute with filesystem-wide default value for a given file
226 verify_comp_attr_with_default() {
230 local tf_cmd="$LFS getstripe -I$comp_id"
238 expected=$($LCTL get_param -n \
239 lov.$FSNAME-clilov-*.stripesize)
243 expected=$($LCTL get_param -n \
244 lov.$FSNAME-clilov-*.stripecount)
245 [[ $expected = -1 ]] && expected=$OSTCOUNT
247 *) error "invalid attribute $attr";;
250 value=$($tf_cmd $opt $tf)
251 [[ $value = -1 ]] && value=$OSTCOUNT
253 [[ $value = $expected ]] || {
255 error "verify $attr failed with default value on $tf:" \
256 "$value != $expected"
261 # Verify unspecified component attributes for a given file
264 # This will only verify the inherited attributes:
265 # stripe size, stripe count and OST pool name
267 verify_comp_attrs() {
271 verify_comp_attr_with_default stripe-size $tf $comp_id
272 verify_comp_attr_with_default stripe-count $tf $comp_id
273 verify_comp_attr_with_parent pool $tf $comp_id
276 # command line test cases
280 local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
281 local mirror_cmd="$LFS mirror create"
286 # create parent directory
287 mkdir $td || error "mkdir $td failed"
289 $mirror_cmd $tf &> /dev/null && error "miss -N option"
291 $mirror_cmd -N $tf || error "create mirrored file $tf failed"
292 verify_mirror_count $tf 1
293 id=$($LFS getstripe -I $tf)
294 verify_comp_attrs $tf $id
295 verify_comp_extent $tf $id 0 EOF
297 $mirror_cmd -N0 $tf-1 &> /dev/null && error "invalid mirror count 0"
298 $mirror_cmd -N$((mirror_count + 1)) $tf-1 &> /dev/null &&
299 error "invalid mirror count $((mirror_count + 1))"
301 $mirror_cmd -N$mirror_count $tf-1 ||
302 error "create mirrored file $tf-1 failed"
303 verify_mirror_count $tf-1 $mirror_count
304 ids=($($LFS getstripe $tf-1 | awk '/lcme_id/{print $2}' | tr '\n' ' '))
305 for ((i = 0; i < $mirror_count; i++)); do
306 verify_comp_attrs $tf-1 ${ids[$i]}
307 verify_comp_extent $tf-1 ${ids[$i]} 0 EOF
310 $mirror_cmd -N -N2 -N3 -N4 $tf-2 ||
311 error "create mirrored file $tf-2 failed"
312 verify_mirror_count $tf-2 10
313 ids=($($LFS getstripe $tf-2 | awk '/lcme_id/{print $2}' | tr '\n' ' '))
314 for ((i = 0; i < 10; i++)); do
315 verify_comp_attrs $tf-2 ${ids[$i]}
316 verify_comp_extent $tf-2 ${ids[$i]} 0 EOF
319 run_test 0a "lfs mirror create with -N option"
322 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
326 local mirror_cmd="$LFS mirror create"
330 # create a new OST pool
331 local pool_name=$TESTNAME
332 create_pool $FSNAME.$pool_name ||
333 error "create OST pool $pool_name failed"
335 # add OSTs into the pool
336 pool_add_targets $pool_name 0 $((OSTCOUNT - 1)) ||
337 error "add OSTs into pool $pool_name failed"
339 # create parent directory
340 mkdir $td || error "mkdir $td failed"
341 $LFS setstripe -S 8M -c -1 -p $pool_name $td ||
342 error "$LFS setstripe $td failed"
344 # create a mirrored file with plain layout mirrors
345 $mirror_cmd -N -N -S 4M -c 2 -p flash -i 2 -o 2,3 \
346 -N -S 16M -N -c -1 -N -p archive -N -p none $tf ||
347 error "create mirrored file $tf failed"
348 verify_mirror_count $tf 6
349 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
350 for ((i = 0; i < 6; i++)); do
351 verify_comp_extent $tf ${ids[$i]} 0 EOF
354 # verify component ${ids[0]}
355 verify_comp_attrs $tf ${ids[0]}
357 # verify component ${ids[1]}
358 verify_comp_attr stripe-size $tf ${ids[1]} 4194304
359 verify_comp_attr stripe-count $tf ${ids[1]} 2
360 verify_comp_attr stripe-index $tf ${ids[1]} 2
361 verify_comp_attr pool $tf ${ids[1]} flash
363 # verify component ${ids[2]}
364 verify_comp_attr stripe-size $tf ${ids[2]} 16777216
365 verify_comp_attr stripe-count $tf ${ids[2]} 2
366 verify_comp_attr pool $tf ${ids[2]} flash
368 # verify component ${ids[3]}
369 verify_comp_attr stripe-size $tf ${ids[3]} 16777216
370 verify_comp_attr stripe-count $tf ${ids[3]} $OSTCOUNT
371 verify_comp_attr pool $tf ${ids[3]} flash
373 # verify component ${ids[4]}
374 verify_comp_attr stripe-size $tf ${ids[4]} 16777216
375 verify_comp_attr stripe-count $tf ${ids[4]} $OSTCOUNT
376 verify_comp_attr pool $tf ${ids[4]} archive
378 # verify component ${ids[5]}
379 verify_comp_attr stripe-size $tf ${ids[5]} 16777216
380 verify_comp_attr stripe-count $tf ${ids[5]} $OSTCOUNT
381 verify_comp_attr_with_parent pool $tf ${ids[5]}
383 if [ $MDS1_VERSION -ge $(version_code 2.12.55) ]; then
384 # LU-11022 - remove mirror by pool name
385 local=cnt cnt=$($LFS getstripe $tf | grep archive | wc -l)
386 [ "$cnt" != "1" ] && error "unexpected mirror count $cnt"
387 $LFS mirror split --pool archive -d $tf || error "delete mirror"
388 cnt=$($LFS getstripe $tf | grep archive | wc -l)
389 [ "$cnt" != "0" ] && error "mirror count after removal: $cnt"
395 run_test 0b "lfs mirror create plain layout mirrors"
398 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
402 local mirror_cmd="$LFS mirror create"
406 # create a new OST pool
407 local pool_name=$TESTNAME
408 create_pool $FSNAME.$pool_name ||
409 error "create OST pool $pool_name failed"
411 # add OSTs into the pool
412 pool_add_targets $pool_name 0 $((OSTCOUNT - 1)) ||
413 error "add OSTs into pool $pool_name failed"
415 # create parent directory
416 mkdir $td || error "mkdir $td failed"
417 $LFS setstripe -E 32M -S 8M -c -1 -p $pool_name -E eof -S 16M $td ||
418 error "$LFS setstripe $td failed"
420 # create a mirrored file with composite layout mirrors
421 $mirror_cmd -N2 -E 4M -c 2 -p flash -i 1 -o 1,3 -E eof -S 4M \
423 -N3 -E 512M -S 16M -p archive -E -1 -i -1 -c -1 $tf ||
424 error "create mirrored file $tf failed"
425 verify_mirror_count $tf 6
426 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
428 # verify components ${ids[0]} and ${ids[2]}
430 verify_comp_attr_with_default stripe-size $tf ${ids[$i]}
431 verify_comp_attr stripe-count $tf ${ids[$i]} 2
432 verify_comp_attr stripe-index $tf ${ids[$i]} 1
433 verify_comp_attr pool $tf ${ids[$i]} flash
434 verify_comp_extent $tf ${ids[$i]} 0 4194304
437 # verify components ${ids[1]} and ${ids[3]}
439 verify_comp_attr stripe-size $tf ${ids[$i]} 4194304
440 verify_comp_attr stripe-count $tf ${ids[$i]} 2
441 verify_comp_attr pool $tf ${ids[$i]} flash
442 verify_comp_extent $tf ${ids[$i]} 4194304 EOF
445 # verify component ${ids[4]}
446 verify_comp_attr stripe-size $tf ${ids[4]} 4194304
447 verify_comp_attr stripe-count $tf ${ids[4]} 4
448 verify_comp_attr_with_parent pool $tf ${ids[4]}
449 verify_comp_extent $tf ${ids[4]} 0 EOF
451 # verify components ${ids[5]}, ${ids[7]} and ${ids[9]}
453 verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
454 verify_comp_attr stripe-count $tf ${ids[$i]} 4
455 verify_comp_attr pool $tf ${ids[$i]} archive
456 verify_comp_extent $tf ${ids[$i]} 0 536870912
459 # verify components ${ids[6]}, ${ids[8]} and ${ids[10]}
461 verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
462 verify_comp_attr stripe-count $tf ${ids[$i]} -1
463 verify_comp_attr pool $tf ${ids[$i]} archive
464 verify_comp_extent $tf ${ids[$i]} 536870912 EOF
470 run_test 0c "lfs mirror create composite layout mirrors"
475 local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
476 local mirror_cmd="$LFS mirror extend"
480 # create parent directory
481 mkdir $td || error "mkdir $td failed"
483 $mirror_cmd $tf &> /dev/null && error "miss -N option"
484 $mirror_cmd -N $tf &> /dev/null && error "$tf does not exist"
486 # create a non-mirrored file, convert it to a mirrored file and extend
487 touch $tf || error "touch $tf failed"
488 $mirror_cmd -N $tf || error "convert and extend $tf failed"
489 verify_mirror_count $tf 2
490 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
491 for ((i = 0; i < 2; i++)); do
492 verify_comp_attrs $tf ${ids[$i]}
493 verify_comp_extent $tf ${ids[$i]} 0 EOF
496 lfsck_verify_pfid $tf || error "PFID is not set"
498 # create a mirrored file and extend it
499 $LFS mirror create -N $tf-1 || error "create mirrored file $tf-1 failed"
500 $LFS mirror create -N $tf-2 || error "create mirrored file $tf-2 failed"
502 $mirror_cmd -N -S 4M -N -f $tf-2 $tf-1 &> /dev/null &&
503 error "setstripe options should not be specified with -f option"
505 $mirror_cmd -N$((mirror_count - 1)) $tf-1 ||
506 error "extend mirrored file $tf-1 failed"
507 verify_mirror_count $tf-1 $mirror_count
508 ids=($($LFS getstripe $tf-1 | awk '/lcme_id/{print $2}' | tr '\n' ' '))
509 for ((i = 0; i < $mirror_count; i++)); do
510 verify_comp_attrs $tf-1 ${ids[$i]}
511 verify_comp_extent $tf-1 ${ids[$i]} 0 EOF
514 $mirror_cmd -N $tf-1 &> /dev/null &&
515 error "exceeded maximum mirror count $mirror_count" || true
517 run_test 0d "lfs mirror extend with -N option"
520 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
524 local mirror_cmd="$LFS mirror extend"
528 # create parent directory
529 mkdir $td || error "mkdir $td failed"
531 # create a mirrored file with plain layout mirrors
532 $LFS mirror create -N -S 32M -c 3 -p ssd -i 1 -o 1,2,3 $tf ||
533 error "create mirrored file $tf failed"
535 # extend the mirrored file with plain layout mirrors
536 $mirror_cmd -N -S 4M -c 2 -p flash -i 2 -o 2,3 \
537 -N -S 16M -N -c -1 -N -p archive -N -p none $tf ||
538 error "extend mirrored file $tf failed"
539 verify_mirror_count $tf 6
540 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
541 for ((i = 0; i < 6; i++)); do
542 verify_comp_extent $tf ${ids[$i]} 0 EOF
545 # verify component ${ids[0]}
546 verify_comp_attr stripe-size $tf ${ids[0]} 33554432
547 verify_comp_attr stripe-count $tf ${ids[0]} 3
548 verify_comp_attr stripe-index $tf ${ids[0]} 1
549 verify_comp_attr pool $tf ${ids[0]} ssd
551 # verify component ${ids[1]}
552 verify_comp_attr stripe-size $tf ${ids[1]} 4194304
553 verify_comp_attr stripe-count $tf ${ids[1]} 2
554 verify_comp_attr stripe-index $tf ${ids[1]} 2
555 verify_comp_attr pool $tf ${ids[1]} flash
557 # verify component ${ids[2]}
558 verify_comp_attr stripe-size $tf ${ids[2]} 16777216
559 verify_comp_attr stripe-count $tf ${ids[2]} 2
560 verify_comp_attr pool $tf ${ids[2]} flash
562 # verify component ${ids[3]}
563 verify_comp_attr stripe-size $tf ${ids[3]} 16777216
564 verify_comp_attr stripe-count $tf ${ids[3]} $OSTCOUNT
565 verify_comp_attr pool $tf ${ids[3]} flash
567 # verify component ${ids[4]}
568 verify_comp_attr stripe-size $tf ${ids[4]} 16777216
569 verify_comp_attr stripe-count $tf ${ids[4]} $OSTCOUNT
570 verify_comp_attr pool $tf ${ids[4]} archive
572 # verify component ${ids[5]}
573 verify_comp_attr stripe-size $tf ${ids[5]} 16777216
574 verify_comp_attr stripe-count $tf ${ids[5]} $OSTCOUNT
575 verify_comp_attr_with_parent pool $tf ${ids[5]}
577 run_test 0e "lfs mirror extend plain layout mirrors"
580 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
584 local mirror_cmd="$LFS mirror extend"
588 # create parent directory
589 mkdir $td || error "mkdir $td failed"
591 # create a mirrored file with composite layout mirror
592 $LFS mirror create -N -E 32M -S 16M -p ssd -E eof -S 32M $tf ||
593 error "create mirrored file $tf failed"
595 # extend the mirrored file with composite layout mirrors
596 $mirror_cmd -N2 -E 4M -c 2 -p flash -i 1 -o 1,3 -E eof -S 4M \
598 -N3 -E 512M -S 16M -p archive -E -1 -i -1 -c -1 $tf ||
599 error "extend mirrored file $tf failed"
600 verify_mirror_count $tf 7
601 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
603 # verify component ${ids[0]}
604 verify_comp_attr stripe-size $tf ${ids[0]} 16777216
605 verify_comp_attr_with_default stripe-count $tf ${ids[0]}
606 verify_comp_attr pool $tf ${ids[0]} ssd
607 verify_comp_extent $tf ${ids[0]} 0 33554432
609 # verify component ${ids[1]}
610 verify_comp_attr stripe-size $tf ${ids[1]} 33554432
611 verify_comp_attr_with_default stripe-count $tf ${ids[1]}
612 verify_comp_attr pool $tf ${ids[1]} ssd
613 verify_comp_extent $tf ${ids[1]} 33554432 EOF
615 # verify components ${ids[2]} and ${ids[4]}
617 verify_comp_attr_with_default stripe-size $tf ${ids[$i]}
618 verify_comp_attr stripe-count $tf ${ids[$i]} 2
619 verify_comp_attr stripe-index $tf ${ids[$i]} 1
620 verify_comp_attr pool $tf ${ids[$i]} flash
621 verify_comp_extent $tf ${ids[$i]} 0 4194304
624 # verify components ${ids[3]} and ${ids[5]}
626 verify_comp_attr stripe-size $tf ${ids[$i]} 4194304
627 verify_comp_attr stripe-count $tf ${ids[$i]} 2
628 verify_comp_attr pool $tf ${ids[$i]} flash
629 verify_comp_extent $tf ${ids[$i]} 4194304 EOF
632 # verify component ${ids[6]}
633 verify_comp_attr stripe-size $tf ${ids[6]} 4194304
634 verify_comp_attr stripe-count $tf ${ids[6]} $OSTCOUNT
635 verify_comp_attr_with_parent pool $tf ${ids[6]}
636 verify_comp_extent $tf ${ids[6]} 0 EOF
638 # verify components ${ids[7]}, ${ids[9]} and ${ids[11]}
640 verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
641 verify_comp_attr stripe-count $tf ${ids[$i]} $OSTCOUNT
642 verify_comp_attr pool $tf ${ids[$i]} archive
643 verify_comp_extent $tf ${ids[$i]} 0 536870912
646 # verify components ${ids[8]}, ${ids[10]} and ${ids[12]}
648 verify_comp_attr stripe-size $tf ${ids[$i]} 16777216
649 verify_comp_attr stripe-count $tf ${ids[$i]} -1
650 verify_comp_attr pool $tf ${ids[$i]} archive
651 verify_comp_extent $tf ${ids[$i]} 536870912 EOF
654 run_test 0f "lfs mirror extend composite layout mirrors"
659 $LFS mirror create -N -E 1M -S 1M -o0 --flags=prefer -E eof -o1 \
660 -N -o1 $tf || error "create mirrored file $tf failed"
662 verify_comp_attr lcme_flags $tf 0x10001 prefer
663 verify_comp_attr lcme_flags $tf 0x10002 prefer
665 # write to the mirrored file and check primary
666 cp /etc/hosts $tf || error "error writing file '$tf'"
668 verify_comp_attr lcme_flags $tf 0x20003 stale
670 # resync file and check prefer flag
671 $LFS mirror resync $tf || error "error resync-ing file '$tf'"
674 $LCTL set_param osc.*.stats=clear
675 cat $tf &> /dev/null || error "error reading file '$tf'"
677 # verify that the data was provided by OST1 where mirror 1 resides
678 local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[-0-9a-f]*.stats |
679 awk '/ost_read/{print $2}')
680 [ -n "$nr_read" ] || error "read was not provided by OST1"
682 run_test 0g "lfs mirror create flags support"
685 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
686 skip "Need MDS version at least 2.11.57"
693 # create parent directory
694 test_mkdir $td || error "mkdir $td failed"
696 $LFS setstripe -N -E 1M -S 1M --flags=prefer -E eof -N2 $td ||
697 error "set default mirrored layout on directory $td failed"
699 # verify flags are inherited from the directory
702 verify_comp_attr lcme_flags $tf 0x10001 prefer
703 verify_comp_attr lcme_flags $tf 0x10002 prefer
705 # set flags to the first component
706 $LFS setstripe --comp-set -I 0x10001 --comp-flags=^prefer,stale $tf
708 verify_comp_attr lcme_flags $tf 0x10001 stale
709 verify_comp_attr lcme_flags $tf 0x10002 prefer
711 $LFS setstripe --comp-set -I0x10001 --comp-flags=^stale $tf &&
712 error "clearing 'stale' should fail"
714 # write and resync file. It can't resync the file directly because the
715 # file state is still 'ro'
716 cp /etc/hosts $tf || error "error writing file '$tf'"
717 $LFS mirror resync $tf || error "error resync-ing file '$tf'"
719 $LFS setstripe --comp-set -I 0x20003 --comp-flags=prefer $tf ||
720 error "error setting flag prefer"
722 verify_comp_attr lcme_flags $tf 0x20003 prefer
724 $LFS setstripe --comp-set -I 0x20003 --comp-flags=^prefer $tf ||
725 error "error clearing prefer flag from component 0x20003"
727 # MDS disallows setting stale flag on the last non-stale mirror
728 [[ "$MDS1_VERSION" -ge $(version_code 2.12.57) ]] || return 0
730 cp /etc/hosts $tf || error "error writing file '$tf'"
732 verify_comp_attr lcme_flags $tf 0x10002 prefer
733 verify_comp_attr lcme_flags $tf 0x20003 stale
734 verify_comp_attr lcme_flags $tf 0x30004 stale
736 ! $LFS setstripe --comp-set -I 0x10002 --comp-flags=^prefer,stale $tf \
738 error "setting stale flag on component 0x10002 should fail"
740 $LFS mirror resync $tf || error "error resync-ing file '$tf'"
742 $LFS setstripe --comp-set -I 0x10001 --comp-flags=stale $tf ||
743 error "error setting stale flag on component 0x10001"
744 $LFS setstripe --comp-set -I 0x20003 --comp-flags=stale $tf ||
745 error "error setting stale flag on component 0x20003"
747 ! $LFS setstripe --comp-set -I 0x30004 --comp-flags=stale $tf \
749 error "setting stale flag on component 0x30004 should fail"
751 $LFS mirror resync $tf || error "error resync-ing file '$tf'"
753 run_test 0h "set, clear and test flags for FLR files"
757 local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX
758 local mirror_create_cmd="$LFS mirror create"
759 local stripes[0]=$OSTCOUNT
761 mirror_create_cmd+=" -N -c ${stripes[0]}"
762 for ((i = 1; i < $mirror_count; i++)); do
763 # add mirrors with different stripes to the file
764 stripes[$i]=$((RANDOM % OSTCOUNT))
765 [ ${stripes[$i]} -eq 0 ] && stripes[$i]=1
767 mirror_create_cmd+=" -N -c ${stripes[$i]}"
770 $mirror_create_cmd $tf || error "create mirrored file $tf failed"
771 verify_mirror_count $tf $mirror_count
773 # can't create mirrors exceeding LUSTRE_MIRROR_COUNT_MAX
774 $LFS mirror extend -N $tf &&
775 error "Creating the $((mirror_count+1))th mirror succeeded"
777 local ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' |
780 # verify the range of components and stripe counts
781 for ((i = 0; i < $mirror_count; i++)); do
782 verify_comp_attr stripe-count $tf ${ids[$i]} ${stripes[$i]}
783 verify_comp_extent $tf ${ids[$i]} 0 EOF
786 run_test 1 "create components with setstripe options"
790 local tf2=$DIR/$tfile-2
792 $LFS setstripe -E 1M -S 1M -E EOF -c 1 $tf
793 $LFS setstripe -E 2M -S 1M -E EOF -c -1 $tf2
795 $LFS mirror extend -N -f $tf2 $tf ||
796 error "merging $tf2 into $tf failed"
798 verify_mirror_count $tf 2
799 [[ ! -e $tf2 ]] || error "$tf2 was not unlinked"
801 run_test 2 "create components from existing files"
804 [[ $MDSCOUNT -lt 2 ]] && skip "need >= 2 MDTs" && return
806 for ((i = 0; i < 2; i++)); do
807 $LFS mkdir -i $i $DIR/$tdir-$i
808 $LFS setstripe -E -1 $DIR/$tdir-$i/$tfile
811 $LFS mirror extend -N -f $DIR/$tdir-1/$tfile \
812 $DIR/$tdir-0/$tfile || error "creating mirrors"
814 # mdt doesn't support to cancel layout lock for remote objects, do
818 # make sure the mirrorted file was created successfully
819 [[ $($LFS getstripe --component-count $DIR/$tdir-0/$tfile) -eq 2 ]] ||
820 { $LFS getstripe $DIR/$tdir-0/$tfile;
821 error "expected 2 components"; }
826 run_test 3 "create components from files located on different MDTs"
829 local tf=$DIR/$tdir/$tfile
832 test_mkdir $DIR/$tdir
834 # set mirror with setstripe options to directory
835 $LFS mirror create -N2 -E 1M -S 1M -E eof $DIR/$tdir ||
836 error "set mirror to directory error"
838 [ x$($LFS getstripe -v $DIR/$tdir | awk '/lcm_flags/{print $2}') = \
839 x"mirrored" ] || error "failed to create mirrored dir"
842 verify_mirror_count $tf 2
844 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
845 verify_comp_extent $tf ${ids[0]} 0 1048576
846 verify_comp_extent $tf ${ids[1]} 1048576 EOF
848 # sub directory should inherit mirror setting from parent
849 test_mkdir $DIR/$tdir/td
850 [ x$($LFS getstripe -v $DIR/$tdir/td | awk '/lcm_flags/{print $2}') = \
851 x"mirrored" ] || error "failed to inherit mirror from parent"
853 # mirror extend won't be applied to directory
854 $LFS mirror extend -N2 $DIR/$tdir &&
855 error "expecting mirror extend failure"
858 run_test 4 "Make sure mirror attributes can be inhertied from directory"
864 $MULTIOP $tf oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T12345c ||
865 error "failed to create file with non-empty layout"
866 $CHECKSTAT -t file -s 12345 $tf || error "size error: expecting 12345"
868 $LFS mirror create -N3 $tf || error "failed to attach mirror layout"
869 verify_mirror_count $tf 3
871 $CHECKSTAT -t file -s 12345 $tf ||
872 error "size error after attaching layout "
874 run_test 5 "Make sure init size work for mirrored layout"
876 # LU=10112: disable dom+flr for phase 1
880 $LFS mirror create -N -E 1M -S 1M -L mdt -E eof -N -E eof $tf &&
881 error "expect failure to create mirrored file with DoM"
883 $LFS mirror create -N -E 1M -S 1M -E eof -N -E 1M -L mdt -E eof $tf &&
884 error "expect failure to create mirrored file with DoM"
886 $LFS setstripe -E 1M -S 1M -L mdt -E eof $tf
887 $LFS mirror extend -N2 $tf &&
888 error "expect failure to extend mirror with DoM"
890 $LFS mirror create -N2 -E 1M -S 1M -E eof $tf-2
891 $LFS mirror extend -N -f $tf $tf-2 &&
892 error "expect failure to extend mirrored file with DoM extent"
896 run_test 6 "DoM and FLR won't co-exist for phase 1"
900 local tf2=$DIR/$tfile-2
902 [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
904 $LFS setstripe -E EOF -o 0 $tf
905 $LFS setstripe -E EOF -o 1 $tf2
907 local dd_count=$((RANDOM % 20 + 1))
908 dd if=/dev/zero of=$tf bs=1M count=$dd_count oflag=sync
909 dd if=/dev/zero of=$tf2 bs=1M count=1 seek=$((dd_count - 1)) oflag=sync
911 # for zfs - sync OST dataset so that du below will return
913 [ "$FSTYPE" = "zfs" ] &&
914 do_nodes $(comma_list $(osts_nodes)) "$ZPOOL sync"
916 local blocks=$(du -kc $tf $tf2 | awk '/total/{print $1}')
919 $LFS mirror extend -N -f $tf2 $tf ||
920 error "merging $tf2 into $tf failed"
925 local new_blocks=$(du -k $tf | awk '{print $1}')
926 [ $new_blocks -eq $blocks ] ||
927 error "i_blocks error expected: $blocks, actual: $new_blocks"
929 run_test 21 "glimpse should report accurate i_blocks"
931 get_osc_lock_count() {
938 osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'[-0-9a-f]*'
939 count=$($LCTL get_param -n ldlm.namespaces.$osc_name.lock_count)
940 lock_count=$((lock_count + count))
948 $LFS setstripe -E EOF -o 0 $tf
949 dd if=/dev/zero of=$tf bs=1M count=$((RANDOM % 20 + 1))
951 # add component, two mirrors located on the same OST ;-)
952 $LFS mirror extend -N -o 0 $tf ||
953 error "extending mirrored file $tf failed"
955 size_blocks=$(stat --format="%b %s" $tf)
960 local new_size_blocks=$(stat --format="%b %s" $tf)
962 # make sure there is no lock cached
963 [ $(get_osc_lock_count 1) -eq 0 ] || error "glimpse requests were sent"
965 [ "$new_size_blocks" = "$size_blocks" ] ||
966 echo "size expected: $size_blocks, actual: $new_size_blocks"
970 run_test 22 "no glimpse to OSTs for READ_ONLY files"
975 $LFS mirror create -N -o 0 -N -o 1 $tf ||
976 error "creating mirrored file $tf failed"
978 #define OBD_FAIL_GLIMPSE_IMMUTABLE 0x1A00
979 $LCTL set_param fail_loc=0x1A00
982 for ((ost_idx = 1; ost_idx <= 2; ost_idx++)); do
986 local tmpfile=$(mktemp)
987 stat --format="%b %s" $tf > $tmpfile &
991 while [ $cnt -le 5 ]; do
992 kill -0 $pid > /dev/null 2>&1 || break
996 kill -0 $pid > /dev/null 2>&1 &&
997 error "stat process stuck due to unavailable OSTs"
999 # make sure glimpse request has been sent
1000 [ $(get_osc_lock_count 1 2) -ne 0 ] ||
1001 error "OST $ost_idx: no glimpse request was sent"
1006 run_test 31 "make sure glimpse request can be retried"
1009 [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
1010 rm -f $DIR/$tfile $DIR/$tfile-2
1012 $LFS setstripe -E EOF -o 0 $DIR/$tfile
1013 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=$((RANDOM % 10 + 2))
1015 local fsize=$(stat -c %s $DIR/$tfile)
1016 [[ $fsize -ne 0 ]] || error "file size is (wrongly) zero"
1018 local cksum=$(md5sum $DIR/$tfile)
1020 # create a new mirror in sync mode
1021 $LFS mirror extend -N -o 1 $DIR/$tfile ||
1022 error "extending mirrored file $DIR/$tfile failed"
1024 # make sure the mirrored file was created successfully
1025 [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
1026 { $LFS getstripe $DIR/$tfile; error "expected 2 mirrors"; }
1031 # check size is correct, glimpse request should go to the 2nd mirror
1032 $CHECKSTAT -t file -s $fsize $DIR/$tfile ||
1033 error "file size error $fsize vs. $(stat -c %s $DIR/$tfile)"
1035 echo "reading file from the 2nd mirror and verify checksum"
1036 [[ "$cksum" == "$(md5sum $DIR/$tfile)" ]] ||
1037 error "checksum error: expected $cksum"
1041 run_test 32 "data should be mirrored to newly created mirror"
1044 [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
1046 rm -f $DIR/$tfile $DIR/$tfile-2
1048 # create a file with two mirrors
1049 $LFS setstripe -E EOF -o 0 $DIR/$tfile
1052 while [ $count -lt $max_count ]; do
1053 echo "ost1" >> $DIR/$tfile
1054 count=$((count + 1));
1057 # tmp file that will be used as mirror
1058 $LFS setstripe -E EOF -o 1 $DIR/$tfile-2
1060 while [ $count -lt $max_count ]; do
1061 echo "ost2" >> $DIR/$tfile-2
1062 count=$((count + 1));
1065 # create a mirrored file
1066 $LFS mirror extend -N -f $DIR/$tfile-2 $DIR/$tfile &&
1067 error "merging $DIR/$tfile-2 into $DIR/$tfile" \
1068 "with verification should fail"
1069 $LFS mirror extend --no-verify -N -f $DIR/$tfile-2 $DIR/$tfile ||
1070 error "merging $DIR/$tfile-2 into $DIR/$tfile" \
1071 "without verification failed"
1073 # make sure that $tfile has two mirrors and $tfile-2 does not exist
1074 [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
1075 { $LFS getstripe $DIR/$tfile; error "expected count 2"; }
1077 [[ ! -e $DIR/$tfile-2 ]] || error "$DIR/$tfile-2 was not unlinked"
1079 # execpted file size
1080 local fsize=$((5 * max_count))
1081 $CHECKSTAT -t file -s $fsize $DIR/$tfile ||
1082 error "mirrored file size is not $fsize"
1084 # read file - all OSTs are available
1085 echo "reading file (data can be provided by any ost)... "
1086 local rs=$(cat $DIR/$tfile | head -1)
1087 [[ "$rs" == "ost1" || "$rs" == "ost2" ]] ||
1088 error "file content error: expected: \"ost1\" or \"ost2\""
1090 # read file again with ost1 failed
1094 echo "reading file (data should be provided by ost2)..."
1095 local rs=$(cat $DIR/$tfile | head -1)
1096 [[ "$rs" == "ost2" ]] ||
1097 error "file content error: expected: \"ost2\", actual: \"$rs\""
1102 # read file again with ost2 failed
1106 # check size, glimpse should work
1107 $CHECKSTAT -t file -s $fsize $DIR/$tfile ||
1108 error "mirrored file size is not $fsize"
1110 echo "reading file (data should be provided by ost1)..."
1111 local rs=$(cat $DIR/$tfile | head -1)
1112 [[ "$rs" == "ost1" ]] ||
1113 error "file content error: expected: \"ost1\", actual: \"$rs\""
1117 run_test 33 "read can choose available mirror to read"
1120 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
1122 rm -f $DIR/$tfile $DIR/$tfile-2 $DIR/$tfile-ref
1125 $LFS setstripe -o 0 $DIR/$tfile-ref
1126 dd if=/dev/urandom of=$DIR/$tfile-ref bs=1M count=3
1128 # create a file with two mirrors
1129 $LFS setstripe -E -1 -o 0,1 -S 1M $DIR/$tfile
1130 dd if=$DIR/$tfile-ref of=$DIR/$tfile bs=1M
1132 $LFS setstripe -E -1 -o 2,3 -S 1M $DIR/$tfile-2
1133 dd if=$DIR/$tfile-ref of=$DIR/$tfile-2 bs=1M
1135 $CHECKSTAT -t file -s $((3 * 1024 * 1024)) $DIR/$tfile ||
1136 error "mirrored file size is not 3M"
1138 # merge a mirrored file
1139 $LFS mirror extend -N -f $DIR/$tfile-2 $DIR/$tfile ||
1140 error "merging $DIR/$tfile-2 into $DIR/$tfile failed"
1142 cancel_lru_locks osc
1144 # stop two OSTs, so the 2nd stripe of the 1st mirror and
1145 # the 1st stripe of the 2nd mirror will be inaccessible, ...
1148 echo "comparing files ... "
1150 # however, read can still return the correct data. It should return
1151 # the 1st stripe from mirror 1 and 2st stripe from mirror 2.
1152 cmp -n 2097152 <(rwv -f $DIR/$tfile -r -o -n 1 2097152) \
1153 $DIR/$tfile-ref || error "file reading error"
1157 run_test 34a "read mirrored file with multiple stripes"
1160 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
1162 rm -f $DIR/$tfile $DIR/$tfile-2 $DIR/$tfile-ref
1165 $LFS setstripe -o 0 $DIR/$tfile-ref
1166 dd if=/dev/urandom of=$DIR/$tfile-ref bs=1M count=3
1168 $LFS setstripe -E 1M -S 1M -o 0 -E eof -o 1 $DIR/$tfile
1169 dd if=$DIR/$tfile-ref of=$DIR/$tfile bs=1M
1171 $LFS setstripe -E 1M -S 1M -o 2 -E eof -o 3 $DIR/$tfile-2
1172 dd if=$DIR/$tfile-ref of=$DIR/$tfile-2 bs=1M
1174 $CHECKSTAT -t file -s $((3 * 1024 * 1024)) $DIR/$tfile ||
1175 error "mirrored file size is not 3M"
1177 # merge a mirrored file
1178 $LFS mirror extend -N -f $DIR/$tfile-2 $DIR/$tfile ||
1179 error "merging $DIR/$tfile-2 into $DIR/$tfile failed"
1181 cancel_lru_locks osc
1183 # stop two OSTs, so the 2nd component of the 1st mirror and
1184 # the 1st component of the 2nd mirror will be inaccessible, ...
1187 echo "comparing files ... "
1189 # however, read can still return the correct data. It should return
1190 # the 1st stripe from mirror 1 and 2st stripe from mirror 2.
1191 cmp -n 2097152 <(rwv -f $DIR/$tfile -r -o -n 1 2097152) \
1192 $DIR/$tfile-ref || error "file reading error"
1196 run_test 34b "read mirrored file with multiple components"
1199 local tf=$DIR/$tfile
1201 $LFS setstripe -E eof $tf
1203 # add an out-of-sync mirror to the file
1204 $LFS mirror extend -N -c 2 $tf ||
1205 error "extending mirrored file $tf failed"
1207 $MULTIOP $tf oO_WRONLY:c ||
1208 error "write open a mirrored file failed"
1210 # truncate file should return error
1211 $TRUNCATE $tf 100 || error "error truncating a mirrored file"
1213 run_test 35 "allow to write to mirrored files"
1215 verify_ost_layout_version() {
1218 # get file layout version
1219 local flv=$($LFS getstripe $tf | awk '/lcm_layout_gen/{print $2}')
1221 # layout version from OST objects
1222 local olv=$($MULTIOP $tf oXc | awk '/ostlayoutversion/{print $2}')
1224 [ $flv -eq $olv ] || error "layout version mismatch: $flv vs. $olv"
1231 $LFS setstripe -E 1M -S 1M -E 2M -E 4M -E eof -c -1 $tf
1232 $LFS setstripe -E 3M -S 1M -E 6M -E eof -c -1 $tf-tmp
1234 $LFS mirror extend -N -f $tf-tmp $tf ||
1235 error "merging $tf-tmp into $tf failed"
1240 local tf=$DIR/$tfile
1242 create_file_36 $tf $tf-2 $tf-3
1244 [ $($LFS getstripe -N $tf) -gt 1 ] || error "wrong mirror count"
1246 # test case 1 - check file write and verify layout version
1247 $MULTIOP $tf oO_WRONLY:c ||
1248 error "write open a mirrored file failed"
1250 # write open file should not return error
1251 $MULTIOP $tf oO_WRONLY:w1024Yc || error "write mirrored file error"
1253 # instantiate components should work
1254 dd if=/dev/zero of=$tf bs=1M count=12 || error "write file error"
1256 # verify OST layout version
1257 verify_ost_layout_version $tf
1260 local mds_facet=mds$(($($LFS getstripe -m $tf-2) + 1))
1263 do_facet $mds_facet $LCTL set_param fail_val=$delay_sec
1265 #define OBD_FAIL_FLR_LV_DELAY 0x1A01
1266 do_facet $mds_facet $LCTL set_param fail_loc=0x1A01
1268 # write should take at least $fail_loc seconds and succeed
1269 local st=$(date +%s)
1270 $MULTIOP $tf-2 oO_WRONLY:w1024Yc || error "write mirrored file error"
1272 [ $(date +%s) -ge $((st+delay_sec)) ] ||
1273 error "write finished before layout version is transmitted"
1275 # verify OST layout version
1276 verify_ost_layout_version $tf
1278 do_facet $mds_facet $LCTL set_param fail_loc=0
1281 mds_idx=mds$(($($LFS getstripe -m $tf-3) + 1))
1283 #define OBD_FAIL_FLR_LV_INC 0x1A02
1284 do_facet $mds_facet $LCTL set_param fail_loc=0x1A02
1286 # write open file should return error
1287 $MULTIOP $tf-3 oO_WRONLY:O_SYNC:w1024c &&
1288 error "write a mirrored file succeeded" || true
1290 do_facet $mds_facet $LCTL set_param fail_loc=0
1292 run_test 36 "write to mirrored files"
1298 echo "create test files with size $fsize .."
1302 $LFS setstripe -E 1M -S 1M -c 1 -E eof -c -1 $tf
1304 dd if=/dev/urandom of=$tf bs=1M count=16 &> /dev/null
1305 $TRUNCATE $tf $fsize
1311 [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
1312 skip "Need MDS version at least 2.11.57"
1314 local tf=$DIR/$tfile
1315 local tf2=$DIR/$tfile-2
1316 local tf3=$DIR/$tfile-3
1317 local tf4=$DIR/$tfile-4
1319 create_files_37 $((RANDOM + 15 * 1048576)) $tf $tf2 $tf3
1323 # assume the mirror id will be 1, 2, and 3
1324 declare -A checksums
1325 checksums[1]=$(cat $tf | md5sum)
1326 checksums[2]=$(cat $tf2 | md5sum)
1327 checksums[3]=$(cat $tf3 | md5sum)
1329 printf '%s\n' "${checksums[@]}"
1331 # merge these files into a mirrored file
1332 $LFS mirror extend --no-verify -N -f $tf2 $tf ||
1333 error "merging $tf2 into $tf failed"
1334 $LFS mirror extend --no-verify -N -f $tf3 $tf ||
1335 error "merging $tf3 into $tf failed"
1339 # verify mirror read, checksums should equal to the original files'
1340 echo "Verifying mirror read .."
1343 for i in ${mirror_array[@]}; do
1344 $LCTL set_param ldlm.namespaces.*.lru_size=clear > /dev/null
1345 sum=$($LFS mirror read -N $i $tf | md5sum)
1346 [ "$sum" = "${checksums[$i]}" ] ||
1347 error "$i: mismatch: \'${checksums[$i]}\' vs. \'$sum\'"
1350 # verify mirror write
1351 echo "Verifying mirror write .."
1352 $LFS mirror write -N2 $tf < $tf4
1354 sum=$($LFS mirror read -N2 $tf | md5sum)
1355 [[ "$sum" = "${checksums[1]}" ]] ||
1356 error "2: mismatch \'${checksums[1]}\' vs. \'$sum\'"
1358 # verify mirror copy, write to this mirrored file will invalidate
1359 # the other two mirrors
1360 echo "Verifying mirror copy .."
1362 local osts=$(comma_list $(osts_nodes))
1364 $LFS mirror copy -i ${mirror_array[0]} -o-1 $tf ||
1365 error "mirror copy error"
1367 # verify copying is successful by checking checksums
1368 remount_client $MOUNT
1369 for i in ${mirror_array[@]}; do
1370 sum=$($LFS mirror read -N $i $tf | md5sum)
1371 [ "$sum" = "${checksums[1]}" ] ||
1372 error "$i: mismatch checksum after copy \'$sum\'"
1377 run_test 37 "mirror I/O API verification"
1382 local expected_state=$2
1384 local state=$($LFS getstripe -v $tf | awk '/lcm_flags/{ print $2 }')
1385 [ $expected_state = $state ] ||
1386 error "expected: $expected_state, actual $state"
1390 local tf=$DIR/$tfile
1391 local ref=$DIR/${tfile}-ref
1393 $LFS setstripe -E 1M -S 1M -c 1 -E 4M -c 2 -E eof -c -1 $tf ||
1394 error "creating $tf failed"
1395 $LFS setstripe -E 2M -S 1M -c 1 -E 6M -c 2 -E 8M -c -1 -E eof -c -1 \
1396 $tf-2 || error "creating $tf-2 failed"
1397 $LFS setstripe -E 4M -c 1 -E 8M -c 2 -E eof -c -1 $tf-3 ||
1398 error "creating $tf-3 failed"
1400 # instantiate all components
1401 $LFS mirror extend -N -f $tf-2 $tf ||
1402 error "merging $tf-2 into $tf failed"
1403 $LFS mirror extend -N -f $tf-3 $tf ||
1404 error "merging $tf-3 into $tf failed"
1405 $LFS mirror extend -N -c 1 $tf ||
1406 error "extending mirrored file $tf failed"
1408 verify_flr_state $tf "ro"
1410 dd if=/dev/urandom of=$ref bs=1M count=16 &> /dev/null
1412 local fsize=$((RANDOM << 8 + 1048576))
1413 $TRUNCATE $ref $fsize
1415 local ref_cksum=$(cat $ref | md5sum)
1417 # case 1: verify write to mirrored file & resync work
1418 cp $ref $tf || error "copy from $ref to $f error"
1419 verify_flr_state $tf "wp"
1421 local file_cksum=$(cat $tf | md5sum)
1422 [ "$file_cksum" = "$ref_cksum" ] || error "write failed, cksum mismatch"
1425 echo "mirror IDs: ${mirror_array[@]}"
1427 local valid_mirror stale_mirror id mirror_cksum
1428 for id in "${mirror_array[@]}"; do
1429 mirror_cksum=$($LFS mirror read -N $id $tf | md5sum)
1430 [ "$ref_cksum" == "$mirror_cksum" ] &&
1431 { valid_mirror=$id; continue; }
1436 [ -z "$stale_mirror" ] && error "stale mirror doesn't exist"
1437 [ -z "$valid_mirror" ] && error "valid mirror doesn't exist"
1439 mirror_io resync $tf || error "resync failed"
1440 verify_flr_state $tf "ro"
1442 mirror_cksum=$($LFS mirror read -N $stale_mirror $tf | md5sum)
1443 [ "$file_cksum" = "$ref_cksum" ] || error "resync failed"
1445 # case 2: inject an error to make mirror_io exit after changing
1446 # the file state to sync_pending so that we can start a concurrent
1448 $MULTIOP $tf oO_WRONLY:w$((RANDOM % 1048576 + 1024))c
1449 verify_flr_state $tf "wp"
1451 mirror_io resync -e resync_start $tf && error "resync succeeded"
1452 verify_flr_state $tf "sp"
1454 # from sync_pending to write_pending
1455 $MULTIOP $tf oO_WRONLY:w$((RANDOM % 1048576 + 1024))c
1456 verify_flr_state $tf "wp"
1458 mirror_io resync -e resync_start $tf && error "resync succeeded"
1459 verify_flr_state $tf "sp"
1461 # from sync_pending to read_only
1462 mirror_io resync $tf || error "resync failed"
1463 verify_flr_state $tf "ro"
1465 run_test 38 "resync"
1468 local tf=$DIR/$tfile
1471 $LFS mirror create -N2 -E1m -c1 -S1M -E-1 $tf ||
1472 error "create PFL file $tf failed"
1474 verify_mirror_count $tf 2
1475 verify_comp_count $tf 4
1477 rm -f $tf || error "delete $tf failed"
1479 run_test 39 "check FLR+PFL (a.k.a. PFLR) creation"
1482 local tf=$DIR/$tfile
1485 for ops in "conv=notrunc" ""; do
1488 $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 --flags=prefer \
1489 -N -E 1M -E 2M -E 4M -E -1 $tf ||
1490 error "create PFLR file $tf failed"
1491 dd if=/dev/zero of=$tf $ops bs=1M seek=2 count=1 ||
1492 error "write PFLR file $tf failed"
1494 lfs getstripe -vy $tf
1498 # file mirror state should be write_pending
1499 flags=$($LFS getstripe -v $tf | awk '/lcm_flags:/ { print $2 }')
1501 error "file mirror state $flags"
1502 # the 1st component (in mirror 1) should be inited
1503 verify_comp_attr lcme_flags $tf 0x10001 init
1504 # the 2nd component (in mirror 1) should be inited
1505 verify_comp_attr lcme_flags $tf 0x10002 init
1506 # the 3rd component (in mirror 1) should be uninited
1507 verify_comp_attr lcme_flags $tf 0x10003 prefer
1508 # the 4th component (in mirror 2) should be inited
1509 verify_comp_attr lcme_flags $tf 0x20004 init
1510 # the 5th component (in mirror 2) should be uninited
1511 verify_comp_attr lcme_flags $tf 0x20005 0
1512 # the 6th component (in mirror 2) should be stale
1513 verify_comp_attr lcme_flags $tf 0x20006 stale
1514 # the 7th component (in mirror 2) should be uninited
1515 if [[ x$ops = "xconv=notrunc" ]]; then
1516 verify_comp_attr lcme_flags $tf 0x20007 0
1517 elif [[ x$ops = "x" ]]; then
1518 verify_comp_attr lcme_flags $tf 0x20007 stale
1522 rm -f $tf || error "delete $tf failed"
1524 run_test 40 "PFLR rdonly state instantiation check"
1527 local tf=$DIR/$tfile
1530 echo " **create two FLR files $tf $tf-1"
1531 $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 \
1532 -N -E 1M -E 2M -E 3M -E -1 $tf ||
1533 error "create PFLR file $tf failed"
1534 $LFS mirror create -N -E 2M -S 1M -E eof \
1535 -N -E 1M -E eof --flags prefer \
1536 -N -E 4m -E eof $tf-1 ||
1537 error "create PFLR file $tf-1 failed"
1539 # file should be in ro status
1540 echo " **verify files be RDONLY"
1541 verify_flr_state $tf "ro"
1542 verify_flr_state $tf-1 "ro"
1544 # write data in [0, 2M)
1545 dd if=/dev/zero of=$tf bs=1M count=2 conv=notrunc ||
1546 error "writing $tf failed"
1547 dd if=/dev/urandom of=$tf-1 bs=1M count=4 conv=notrunc ||
1548 error "writing $tf-1 failed"
1550 local sum0=$(cat $tf-1 | md5sum)
1552 echo " **verify files be WRITE_PENDING"
1553 verify_flr_state $tf "wp"
1554 verify_flr_state $tf-1 "wp"
1556 # file should have stale component
1557 echo " **verify files have stale component"
1558 $LFS getstripe $tf | grep lcme_flags | grep stale > /dev/null ||
1559 error "after writing $tf, it does not contain stale component"
1560 $LFS getstripe $tf-1 | grep lcme_flags | grep stale > /dev/null ||
1561 error "after writing $tf-1, it does not contain stale component"
1563 echo " **full resync"
1564 $LFS mirror resync $tf $tf-1 || error "mirror resync $tf $tf-1 failed"
1566 echo " **verify $tf-1 data consistency in all mirrors"
1568 local sum=$($LFS mirror read -N$i $tf-1 | md5sum)
1569 [[ "$sum" = "$sum0" ]] ||
1570 error "$tf-1.$i: checksum mismatch: $sum != $sum0"
1573 echo " **verify files be RDONLY"
1574 verify_flr_state $tf "ro"
1575 verify_flr_state $tf-1 "ro"
1577 # file should not have stale component
1578 echo " **verify files do not contain stale component"
1579 $LFS getstripe $tf | grep lcme_flags | grep stale &&
1580 error "after resyncing $tf, it contains stale component"
1581 $LFS getstripe $tf-1 | grep lcme_flags | grep stale &&
1582 error "after resyncing $tf, it contains stale component"
1584 # verify partial resync
1585 echo " **write $tf-1 for partial resync test"
1586 dd if=/dev/zero of=$tf-1 bs=1M count=2 conv=notrunc ||
1587 error "writing $tf-1 failed"
1589 echo " **only resync mirror 2"
1590 verify_flr_state $tf-1 "wp"
1591 $LFS mirror resync --only 2 $tf-1 ||
1592 error "resync mirror 2 of $tf-1 failed"
1593 verify_flr_state $tf "ro"
1595 # resync synced mirror
1596 echo " **resync mirror 2 again"
1597 $LFS mirror resync --only 2 $tf-1 ||
1598 error "resync mirror 2 of $tf-1 failed"
1599 verify_flr_state $tf "ro"
1600 echo " **verify $tf-1 contains stale component"
1601 $LFS getstripe $tf-1 | grep lcme_flags | grep stale > /dev/null ||
1602 error "after writing $tf-1, it does not contain stale component"
1604 echo " **full resync $tf-1"
1605 $LFS mirror resync $tf-1 || error "resync of $tf-1 failed"
1606 verify_flr_state $tf "ro"
1607 echo " **full resync $tf-1 again"
1608 $LFS mirror resync $tf-1 || error "resync of $tf-1 failed"
1609 echo " **verify $tf-1 does not contain stale component"
1610 $LFS getstripe $tf | grep lcme_flags | grep stale &&
1611 error "after resyncing $tf, it contains stale component"
1615 run_test 41 "lfs mirror resync check"
1618 [[ $OSTCOUNT -lt 4 ]] && skip "need >= 4 OSTs" && return
1622 local mirror_cmd="$LFS mirror verify"
1625 # create parent directory
1626 mkdir $td || error "mkdir $td failed"
1628 $mirror_cmd &> /dev/null && error "no file name given"
1629 $mirror_cmd $tf &> /dev/null && error "cannot stat file $tf"
1630 $mirror_cmd $td &> /dev/null && error "$td is not a regular file"
1632 # create mirrored files
1633 $LFS mirror create -N -E 4M -S 1M -E 10M -E EOF $tf ||
1634 error "create mirrored file $tf failed"
1635 $LFS mirror create -N -E 2M -S 1M -E EOF \
1636 -N -E 6M -E 8M -E EOF \
1637 -N -E 16M -E EOF $tf-1 ||
1638 error "create mirrored file $tf-1 failed"
1639 $LFS mirror create -N -c 2 -o 1,3 -N -S 2M -c -1 $tf-2 ||
1640 error "create mirrored file $tf-2 failed"
1642 # write data in [0, 10M)
1643 for i in $tf $tf-1 $tf-2; do
1644 yes | dd of=$i bs=1M count=10 iflag=fullblock conv=notrunc ||
1645 error "write $i failed"
1648 # resync the mirrored files
1649 $LFS mirror resync $tf-1 $tf-2 ||
1650 error "resync $tf-1 $tf-2 failed"
1652 # verify the mirrored files
1653 $mirror_cmd $tf-1 $tf-2 ||
1654 error "verify $tf-1 $tf-2 failed"
1656 get_mirror_ids $tf-1
1657 $mirror_cmd --only ${mirror_array[0]} $tf-1 &> /dev/null &&
1658 error "at least 2 mirror ids needed with '--only' option"
1659 $mirror_cmd --only ${mirror_array[0]},${mirror_array[1]} $tf-1 $tf-2 \
1661 error "'--only' option cannot be used upon multiple files"
1662 $mirror_cmd --only 65534,${mirror_array[0]},65535 $tf-1 &&
1663 error "invalid specified mirror ids"
1665 # change the content of $tf and merge it into $tf-1
1667 echo a | dd of=$tf bs=1M seek=$i conv=notrunc ||
1668 error "change $tf with seek=$i failed"
1669 echo b | dd of=$tf-1 bs=1M seek=$i conv=notrunc ||
1670 error "change $tf-1 with seek=$i failed"
1673 $LFS mirror resync $tf-1 || error "resync $tf-1 failed"
1674 $LFS mirror extend --no-verify -N -f $tf $tf-1 ||
1675 error "merge $tf into $tf-1 failed"
1677 # verify the mirrored files
1678 echo "Verify $tf-1 without -v option:"
1679 $mirror_cmd $tf-1 &&
1680 error "verify $tf-1 should fail" || echo "PASS"
1682 echo "Verify $tf-1 with -v option:"
1683 $mirror_cmd -v $tf-1 &&
1684 error "verify $tf-1 should fail"
1686 get_mirror_ids $tf-1
1687 echo "Verify $tf-1 with --only option:"
1688 $mirror_cmd -v --only ${mirror_array[1]},${mirror_array[-1]} $tf-1 &&
1689 error "verify $tf-1 with mirror ${mirror_array[1]} and" \
1690 "${mirror_array[-1]} should fail"
1692 $mirror_cmd --only ${mirror_array[0]},${mirror_array[1]} $tf-1 ||
1693 error "verify $tf-1 with mirror ${mirror_array[0]} and" \
1694 "${mirror_array[1]} should succeed"
1696 # set stale components in $tf-1
1697 for i in 0x40002 0x40003; do
1698 $LFS setstripe --comp-set -I$i --comp-flags=stale $tf-1 ||
1699 error "set stale flag on component $i failed"
1702 # verify the mirrored file
1703 echo "Verify $tf-1 with stale components:"
1704 $mirror_cmd -vvv $tf-1 ||
1705 error "verify $tf-1 with stale components should succeed"
1707 echo "Verify $tf-1 with stale components and --only option:"
1708 $mirror_cmd -vvv --only ${mirror_array[1]},${mirror_array[-1]} $tf-1 ||
1709 error "verify $tf-1 with mirror ${mirror_array[1]} and" \
1710 "${mirror_array[-1]} should succeed"
1712 run_test 42 "lfs mirror verify"
1714 # inactivate one OST && write && restore the OST
1718 local PARAM="osp.${FSNAME}-OST000${ost}-osc-M*.active"
1721 wait=$(do_facet $SINGLEMDS \
1722 "$LCTL get_param -n lod.*MDT0000-*.qos_maxage")
1723 wait=${wait%%[^0-9]*}
1725 echo " **deactivate OST$ost, waiting for $((wait*2+2)) seconds"
1726 $(do_facet $SINGLEMDS "$LCTL set_param -n $PARAM 0")
1727 # lod_qos_statfs_update needs 2*$wait seconds to refresh targets statfs
1728 sleep $(($wait * 2 + 2))
1729 echo " **write $file"
1730 dd if=/dev/zero of=$file bs=1M count=1 || error "write $file failed"
1731 echo " **restore activating OST$ost, waiting for $((wait*2+2)) seconds"
1732 $(do_facet $SINGLEMDS "$LCTL set_param -n $PARAM 1")
1733 sleep $((wait * 2 + 2))
1735 local flags=$($LFS getstripe -v $file | awk '/lcm_flags:/ { print $2 }')
1736 [ $flags = wp ] || error "file mirror state $flags != wp"
1740 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
1742 local tf=$DIR/$tfile
1746 ## mirror 0 ost (0, 1)
1747 ## mirror 1 ost (1, 2)
1748 ## mirror 2 ost (2, 0)
1749 $LFS mirror create -N -Eeof -c2 -o0,1 -N -Eeof -c2 -o1,2 \
1750 -N -Eeof -c2 -o2,0 $tf ||
1751 error "create 3 mirrors file $tf failed"
1753 ################## OST0 ###########################################
1755 echo " **verify components"
1756 verify_comp_attr lcme_flags $tf 0x10001 init,stale
1757 verify_comp_attr lcme_flags $tf 0x20002 init
1758 verify_comp_attr lcme_flags $tf 0x30003 init,stale
1761 echo " **resync $tf"
1762 $LFS mirror resync $tf
1763 flags=$($LFS getstripe -v $tf | awk '/lcm_flags:/ { print $2 }')
1764 [ $flags = ro ] || error "file mirror state $flags != ro"
1766 ################## OST1 ###########################################
1768 echo " **verify components"
1769 verify_comp_attr lcme_flags $tf 0x10001 init,stale
1770 verify_comp_attr lcme_flags $tf 0x20002 init,stale
1771 verify_comp_attr lcme_flags $tf 0x30003 init
1774 echo " **resync $tf"
1775 $LFS mirror resync $tf
1776 flags=$($LFS getstripe -v $tf | awk '/lcm_flags:/ { print $2 }')
1777 [ $flags = ro ] || error "file mirror state $flags != ro"
1779 ################## OST2 ###########################################
1781 echo " **verify components"
1782 verify_comp_attr lcme_flags $tf 0x10001 init
1783 verify_comp_attr lcme_flags $tf 0x20002 init,stale
1784 verify_comp_attr lcme_flags $tf 0x30003 init,stale
1786 run_test 43 "mirror pick on write"
1789 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1792 local tf=$DIR/$tdir/$tfile
1793 local tf1=$DIR/$tdir-1/$tfile-1
1795 $LFS setdirstripe -i 0 -c 1 $DIR/$tdir ||
1796 error "create directory failed"
1797 $LFS setdirstripe -i 1 -c 1 $DIR/$tdir-1 ||
1798 error "create remote directory failed"
1799 rm -f $tf $tf1 $tf.mirror~2
1800 # create file with 4 mirrors
1801 $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 \
1802 -N -E 1M -E 2M -E 3M -E -1 -N2 $tf ||
1803 error "create PFLR file $tf failed"
1805 # file should be in ro status
1806 verify_flr_state $tf "ro"
1808 # write data in [0, 3M)
1809 dd if=/dev/urandom of=$tf bs=1M count=3 conv=notrunc ||
1810 error "writing $tf failed"
1812 verify_flr_state $tf "wp"
1814 # disallow destroying the last non-stale mirror
1815 ! $LFS mirror split --mirror-id 1 -d $tf > /dev/null 2>&1 ||
1816 error "destroying mirror 1 should fail"
1818 # synchronize all mirrors of the file
1819 $LFS mirror resync $tf || error "mirror resync $tf failed"
1821 verify_flr_state $tf "ro"
1824 $LFS mirror split --mirror-id 1 -f $tf1 $tf ||
1825 error "split to $tf1 failed"
1827 local idx0=$($LFS getstripe -m $tf)
1828 local idx1=$($LFS getstripe -m $tf1)
1830 [[ x$idx0 == x0 ]] || error "$tf is not on MDT0"
1831 [[ x$idx1 == x1 ]] || error "$tf1 is not on MDT1"
1833 # verify mirror count
1834 verify_mirror_count $tf 3
1835 verify_mirror_count $tf1 1
1837 $LFS mirror split --mirror-id 2 $tf ||
1838 error "split mirror 2 failed"
1840 verify_mirror_count $tf 2
1841 verify_mirror_count $tf.mirror~2 1
1843 $LFS setstripe --comp-set -I 0x30008 --comp-flags=stale $tf ||
1844 error "setting stale flag on component 0x30008 failed"
1846 # disallow destroying the last non-stale mirror
1847 ! $LFS mirror split --mirror-id 4 -d $tf > /dev/null 2>&1 ||
1848 error "destroying mirror 4 should fail"
1850 $LFS mirror resync $tf || error "resynchronizing $tf failed"
1852 $LFS mirror split --mirror-id 3 -d $tf ||
1853 error "destroying mirror 3 failed"
1854 verify_mirror_count $tf 1
1856 # verify splitted file contains the same content as the orig file does
1857 diff $tf $tf1 || error "splited file $tf1 diffs from $tf"
1858 diff $tf $tf.mirror~2 ||
1859 error "splited file $tf.mirror~2 diffs from $tf"
1861 run_test 44 "lfs mirror split check"
1864 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
1866 local file=$DIR/$tdir/$tfile
1867 local dir=$DIR/$tdir/$dir
1868 local temp=$DIR/$tdir/template
1870 test_mkdir $DIR/$tdir
1872 $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
1873 -N -E3m -S1m -Eeof -N -E8m -Eeof $file ||
1874 error "Create $file failed"
1876 verify_yaml_layout $file $file.copy $temp "1. FLR file"
1877 rm -f $file $file.copy
1879 $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
1880 -N -E3m -S1m -Eeof -N -E8m --flags=prefer -Eeof $file ||
1881 error "Create $file failed"
1883 verify_yaml_layout $file $file.copy $temp "2. FLR file with flags"
1885 run_test 45 "Verify setstripe/getstripe with YAML with FLR file"
1892 $LFS setstripe --copy=$src $dst || error "setstripe $dst failed"
1894 local layout1=$(get_layout_param $src)
1895 local layout2=$(get_layout_param $dst)
1896 # compare their layout info
1897 [ "$layout1" == "$layout2" ] ||
1898 error "$msg_prefix $src <=> $dst layouts are not equal"
1902 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1904 local file=$DIR/$tdir/$tfile
1905 test_mkdir $DIR/$tdir
1907 ########################### 1. PFL file #############################
1908 echo " ** 1. PFL file"
1910 $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
1911 $file || error "1. Create PFL $file failed"
1914 verify_46 $file $file.copy "1. PFL file"
1916 ########################### 2. plain file ###########################
1917 echo " ** 2. plain file"
1919 $LFS setstripe -c2 -o0,1 -i1 $file ||
1920 error "2. Create plain $file failed"
1923 verify_46 $file $file.copy "2. plain file"
1925 ########################### 3. FLR file #############################
1926 echo " ** 3. FLR file"
1927 $LFS setstripe -N -E1m -S 1M -c2 -o0,1 -E4m -c1 -Eeof -N -E16m -Eeof \
1928 $file || error "3. Create FLR $file failed"
1931 verify_46 $file $file.copy "3. FLR file"
1933 local dir=$DIR/$tdir/dir
1934 ########################### 4. PFL dir ##############################
1935 echo " ** 4. PFL dir"
1937 $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
1938 error "4. setstripe PFL $dir failed"
1940 test_mkdir $dir.copy
1941 verify_46 $dir $dir.copy "4. PFL dir"
1943 ########################### 5. plain dir ############################
1944 echo " ** 5. plain dir"
1945 $LFS setstripe -c2 -i-1 $dir || error "5. setstripe plain $dir failed"
1947 verify_46 $dir $dir.copy "5. plain dir"
1949 ########################### 6. FLR dir ##############################
1950 echo " ** 6. FLR dir"
1951 $LFS setstripe -N -E1m -S 1M -c2 -E2m -c1 -Eeof -N -E4m -Eeof $dir ||
1952 error "6. setstripe FLR $dir failed"
1954 verify_46 $dir $dir.copy "6. FLR dir"
1956 run_test 46 "Verify setstripe --copy option"
1959 [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
1961 local file=$DIR/$tdir/$tfile
1966 test_mkdir $DIR/$tdir
1970 # mirror1: [comp0]ost0, [comp1]ost1 and ost2
1971 # mirror2: [comp2] , [comp3] should not use ost1 or ost2
1972 $LFS mirror create -N -E2m -c1 -o0 --flags=prefer -Eeof -c2 -o1,2 \
1973 -N -E2m -c1 -Eeof -c1 $file || error "create FLR $file failed"
1974 ids=($($LFS getstripe $file | awk '/lcme_id/{print $2}' | tr '\n' ' '))
1976 dd if=/dev/zero of=$file bs=1M count=3 || error "dd $file failed"
1977 $LFS mirror resync $file || error "resync $file failed"
1979 ost=$($LFS getstripe -I${ids[2]} $file | awk '/l_ost_idx/{print $5}')
1980 if [[ x$ost == "x0," ]]; then
1981 $LFS getstripe $file
1982 error "component ${ids[2]} objects allocated on $ost " \
1986 ost=$($LFS getstripe -I${ids[3]} $file | awk '/l_ost_idx/{print $5}')
1987 if [[ x$ost == "x1," || x$ost == "x2," ]]; then
1988 $LFS getstripe $file
1989 error "component ${ids[3]} objects allocated on $ost " \
1990 "shouldn't on OST1 or on OST2"
1995 # mirror1: [comp0] [comp1]
1996 # mirror2: [comp2] [comp3]
1997 # mirror3: [comp4] [comp5]
1998 # mirror4: [comp6] [comp7]
1999 $LFS mirror create -N4 -E1m -c1 -Eeof -c1 $file ||
2000 error "create FLR $file failed"
2001 ids=($($LFS getstripe $file | awk '/lcme_id/{print $2}' | tr '\n' ' '))
2003 dd if=/dev/zero of=$file bs=1M count=3 || error "dd $file failed"
2004 $LFS mirror resync $file || error "resync $file failed"
2006 for ((i = 0; i < 6; i++)); do
2007 osts[$i]=$($LFS getstripe -I${ids[$i]} $file |
2008 awk '/l_ost_idx/{print $5}')
2010 # comp[0],comp[2],comp[4] should use different osts
2011 if [[ ${osts[0]} == ${osts[2]} || ${osts[0]} == ${osts[4]} ||
2012 ${osts[2]} == ${osts[4]} ]]; then
2013 $LFS getstripe $file
2014 error "component ${ids[0]}, ${ids[2]}, ${ids[4]} have objects "\
2015 "allocated on duplicated OSTs"
2017 # comp[1],comp[3],comp[5] should use different osts
2018 if [[ ${osts[1]} == ${osts[3]} || ${osts[1]} == ${osts[5]} ||
2019 ${osts[3]} == ${osts[5]} ]]; then
2020 $LFS getstripe $file
2021 error "component ${ids[1]}, ${ids[3]}, ${ids[5]} have objects "\
2022 "allocated on duplicated OSTs"
2027 run_test 47 "Verify mirror obj alloc"
2030 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
2031 skip "Need MDS version at least 2.11.55"
2033 local tf=$DIR/$tfile
2036 echo " ** create 2 mirrors FLR file $tf"
2037 $LFS mirror create -N -E2M -Eeof --flags prefer \
2038 -N -E1M -Eeof $tf ||
2039 error "create FLR file $tf failed"
2042 dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed"
2043 verify_flr_state $tf "wp"
2045 local sum0=$(md5sum < $tf)
2047 echo " ** resync the file"
2048 $LFS mirror resync $tf
2050 echo " ** snapshot mirror 2"
2051 $LFS setstripe --comp-set -I 0x20003 --comp-flags=nosync $tf
2053 echo " ** write it again"
2054 dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed"
2055 echo " ** resync it again"
2056 $LFS mirror resync $tf
2058 verify_flr_state $tf "wp"
2059 verify_comp_attr lcme_flags $tf 0x20003 nosync,stale
2061 local sum1=$($LFS mirror read -N1 $tf | md5sum)
2062 local sum2=$($LFS mirror read -N2 $tf | md5sum)
2064 echo " ** verify mirror 2 doesn't change"
2065 echo "original checksum: $sum0"
2066 echo "mirror 1 checksum: $sum1"
2067 echo "mirror 2 checksum: $sum2"
2068 [[ $sum0 = $sum2 ]] ||
2069 error "original checksum: $sum0, mirror 2 checksum: $sum2"
2070 echo " ** mirror 2 stripe info"
2071 $LFS getstripe -v --mirror-index=2 $tf
2073 echo " ** resync mirror 2"
2074 $LFS mirror resync --only 2 $tf
2076 verify_flr_state $tf "ro"
2077 verify_comp_attr lcme_flags $tf 0x20003 nosync,^stale
2079 sum1=$($LFS mirror read -N1 $tf | md5sum)
2080 sum2=$($LFS mirror read -N2 $tf | md5sum)
2082 echo " ** verify mirror 2 resync-ed"
2083 echo "original checksum: $sum0"
2084 echo "mirror 1 checksum: $sum1"
2085 echo "mirror 2 checksum: $sum2"
2086 [[ $sum1 = $sum2 ]] ||
2087 error "mirror 1 checksum: $sum1, mirror 2 checksum: $sum2"
2088 echo " ** mirror 2 stripe info"
2089 $LFS getstripe -v --mirror-index=2 $tf
2091 run_test 48 "Verify snapshot mirror"
2093 ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
2094 lock_file=$(mktemp /var/lock/FLR.XXXXXX)
2099 local fsize=$(stat --printf=%s $tf)
2101 while [ -f $ctrl_file ]; do
2102 local off=$((RANDOM << 8))
2103 local len=$((RANDOM << 5 + 131072))
2105 [ $((off + len)) -gt $fsize ] && {
2106 fsize=$((off + len))
2107 echo "Extending file size to $fsize .."
2110 flock -s $lock_file -c \
2111 "$MULTIOP $tf oO_WRONLY:z${off}w${len}c" ||
2113 error "failed writing to $off:$len"; }
2114 sleep 0.$((RANDOM % 2 + 1))
2121 while [ -f $ctrl_file ]; do
2122 flock -s $lock_file -c "cat $tf &> /dev/null" ||
2123 { rm -f $ctrl_file; error "read failed"; }
2124 sleep 0.$((RANDOM % 2 + 1))
2131 options=("" "-e resync_start" "-e delay_before_copy -d 1" "" "")
2133 exec 200<>$lock_file
2134 while [ -f $ctrl_file ]; do
2135 local lock_taken=false
2136 local index=$((RANDOM % ${#options[@]}))
2137 local cmd="mirror_io resync ${options[$index]}"
2139 [ "${options[$index]}" = "" ] && cmd="$LFS mirror resync"
2141 [ $((RANDOM % 4)) -eq 0 ] && {
2147 echo -n "resync file $tf with '$cmd' .."
2149 if [[ $lock_taken = "true" ]]; then
2150 flock -x 200 -c "$cmd $tf &> /dev/null" &&
2151 echo "done" || echo "failed"
2154 $cmd $tf &> /dev/null && echo "done" || echo "failed"
2157 sleep 0.$((RANDOM % 8 + 1))
2162 local tf=$DIR/$tfile
2163 local tf2=$DIR2/$tfile
2164 local tf3=$DIR3/$tfile
2166 $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E 4M -E 16M -E eof $tf
2167 $LFS setstripe -E 2M -S 1M -E 6M -c 2 -E 8M -E 32M -E eof $tf-2
2168 $LFS setstripe -E 4M -c 2 -E 8M -E 64M -E eof $tf-3
2170 $LFS mirror extend -N -f $tf-2 $tf ||
2171 error "merging $tf-2 into $tf failed"
2172 $LFS mirror extend -N -f $tf-3 $tf ||
2173 error "merging $tf-3 into $tf failed"
2175 mkdir -p $MOUNT2 && mount_client $MOUNT2
2177 mkdir -p $MOUNT3 && mount_client $MOUNT3
2179 verify_flr_state $tf3 "ro"
2181 #define OBD_FAIL_FLR_RANDOM_PICK_MIRROR 0x1A03
2182 $LCTL set_param fail_loc=0x1A03
2184 local mds_idx=mds$(($($LFS getstripe -m $tf) + 1))
2185 do_facet $mds_idx $LCTL set_param fail_loc=0x1A03
2189 write_file_200 $tf &
2195 write_file_200 $tf2 &
2198 read_file_200 $tf2 &
2201 resync_file_200 $tf3 &
2205 [ "$SLOW" = "yes" ] && sleep_time=360
2206 while [ $sleep_time -gt 0 -a -f $ctrl_file ]; do
2213 echo "Waiting ${pids[@]}"
2216 umount_client $MOUNT2
2217 umount_client $MOUNT3
2221 # resync and verify mirrors
2222 mirror_io resync $tf
2225 local csum=$($LFS mirror read -N ${mirror_array[0]} $tf | md5sum)
2226 for id in ${mirror_array[@]:1}; do
2227 [ "$($LFS mirror read -N $id $tf | md5sum)" = "$csum" ] ||
2228 error "checksum error for mirror $id"
2233 run_test 200 "stress test"
2235 cleanup_test_201() {
2237 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
2239 umount_client $MOUNT2
2243 local delay=${RESYNC_DELAY:-5}
2245 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
2246 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
2248 trap cleanup_test_201 EXIT
2250 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
2251 changelog_register -n)
2253 mkdir -p $MOUNT2 && mount_client $MOUNT2
2257 local log=$($LFS changelog $MDT0 $index | grep FLRW)
2258 [ -z "$log" ] && { sleep 1; continue; }
2260 index=$(echo $log | awk '{print $1}')
2261 local ts=$(date -d "$(echo $log | awk '{print $3}')" "+%s" -u)
2262 local fid=$(echo $log | awk '{print $6}' | sed -e 's/t=//')
2263 local file=$($LFS fid2path $MOUNT2 $fid 2> /dev/null)
2266 [ -z "$file" ] && continue
2268 local now=$(date +%s)
2270 echo "file: $file $fid was modified at $ts, now: $now, " \
2271 "will be resynced at $((ts+delay))"
2273 [ $now -lt $((ts + delay)) ] && sleep $((ts + delay - now))
2275 mirror_io resync $file
2276 echo "$file resync done"
2281 run_test 201 "FLR data mover"
2284 [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
2286 local tf=$DIR/$tfile
2289 $LFS setstripe -E 1M -S 1M -c 1 $tf
2290 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
2291 verify_comp_attr stripe-count $tf ${ids[0]} 1
2293 $LFS setstripe --component-add -E 2M -c -1 $tf
2294 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
2295 verify_comp_attr stripe-count $tf ${ids[0]} 1
2296 verify_comp_attr stripe-count $tf ${ids[1]} -1
2298 dd if=/dev/zero of=$tf bs=1M count=2
2299 ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
2300 verify_comp_attr stripe-count $tf ${ids[0]} 1
2301 verify_comp_attr stripe-count $tf ${ids[1]} $OSTCOUNT
2303 run_test 202 "lfs setstripe --add-component wide striping"
2306 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
2307 skip "Need MDS version at least 2.11.55"
2308 [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs"
2310 local tf=$DIR/$tfile
2313 $LFS mirror create -N2 -c1 $tf || error "create FLR file $tf"
2314 #delete first mirror
2315 $LFS mirror split --mirror-id=1 -d $tf || error "delete first mirror"
2318 local old_id=$($LFS getstripe --mirror-id=2 -I $tf)
2319 local count=$($LFS getstripe --mirror-id=2 -c $tf) ||
2320 error "getstripe count of mirror 2"
2321 [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
2323 #extend a mirror with 2 OSTs
2324 $LFS mirror extend -N -c2 $tf || error "extend mirror"
2327 local new_id=$($LFS getstripe --mirror-id=2 -I $tf)
2328 count=$($LFS getstripe --mirror-id=2 -c $tf) ||
2329 error "getstripe count of mirror 2"
2330 [[ x$oldid = x$newid ]] ||
2331 error "mirror 2 changed ID from $old_id to $new_id"
2332 [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
2334 count=$($LFS getstripe --mirror-id=3 -c $tf) ||
2335 error "getstripe count of mirror 3"
2336 [[ x$count = x2 ]] || error "mirror 3 stripe count $count is not 2"
2338 run_test 203 "mirror file preserve mirror ID"
2340 # Simple test of FLR + self-extending layout, SEL in non-primary mirror
2342 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2343 skip "skipped for lustre < $SEL_VER"
2345 local comp_file=$DIR/$tdir/$tfile
2349 test_mkdir $DIR/$tdir
2351 # first mirror is 0-10M, then 10M-(-1), second mirror is 1M followed
2352 # by extension space to -1
2353 $LFS setstripe -N -E 10M -E-1 -N -E 1M -E-1 -z64M $comp_file ||
2354 error "Create $comp_file failed"
2356 # Write to first component, extending & staling second mirror
2357 dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc ||
2358 error "dd to extend + stale failed"
2360 $LFS getstripe $comp_file
2362 flg_opts="--component-flags init,stale"
2363 found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2364 [ $found -eq 1 ] || error "write: Second comp end incorrect"
2366 flg_opts="--component-flags extension"
2367 found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2368 [ $found -eq 1 ] || error "write: Third comp start incorrect"
2370 # mirror resync should not change the extents
2371 $LFS mirror resync $comp_file
2373 flg_opts="--component-flags init"
2374 found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2375 [ $found -eq 1 ] || error "resync: Second comp end incorrect"
2377 flg_opts="--component-flags extension"
2378 found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2379 [ $found -eq 1 ] || error "resync: Third comp start incorrect"
2381 sel_layout_sanity $comp_file 5
2385 run_test 204a "FLR write/stale/resync tests with self-extending mirror"
2387 # Simple test of FLR + self-extending layout, SEL in primary mirror
2389 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2390 skip "skipped for lustre < $SEL_VER"
2392 local comp_file=$DIR/$tdir/$tfile
2396 test_mkdir $DIR/$tdir
2398 # first mirror is 1M followed by extension space to -1, second mirror
2399 # is 0-10M, then 10M-(-1),
2400 $LFS setstripe -N -E 1M -E-1 -z64M -N -E 10M -E-1 $comp_file ||
2401 error "Create $comp_file failed"
2403 # Write to first component, extending first component & staling
2405 dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc ||
2406 error "dd to extend + stale failed"
2408 $LFS getstripe $comp_file
2410 flg_opts="--component-flags init"
2411 found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2412 [ $found -eq 1 ] || error "write: First comp end incorrect"
2414 flg_opts="--component-flags extension"
2415 found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2416 [ $found -eq 1 ] || error "write: Second comp start incorrect"
2418 flg_opts="--component-flags init,stale"
2419 found=$($LFS find --component-end 10M $flg_opts $comp_file | wc -l)
2420 [ $found -eq 1 ] || error "write: First mirror comp flags incorrect"
2422 # This component is staled because it overlaps the extended first
2423 # component of the primary mirror, even though it doesn't overlap
2424 # the actual write - thus not inited.
2425 flg_opts="--component-flags stale"
2426 found=$($LFS find --component-start 10M $flg_opts $comp_file | wc -l)
2427 [ $found -eq 1 ] || error "write: Second mirror comp flags incorrect"
2429 # mirror resync should not change the extents
2430 $LFS mirror resync $comp_file
2432 $LFS getstripe $comp_file
2434 flg_opts="--component-flags init"
2435 found=$($LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2436 [ $found -eq 1 ] || error "resync: First comp end incorrect"
2438 flg_opts="--component-flags extension"
2439 found=$($LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2440 [ $found -eq 1 ] || error "resync: Second comp start incorrect"
2442 flg_opts="--component-flags init"
2443 found=$($LFS find --component-end 10M $flg_opts $comp_file | wc -l)
2444 [ $found -eq 1 ] || error "resync: First mirror comp flags incorrect"
2446 flg_opts="--component-flags init"
2447 found=$($LFS find --component-start 10M $flg_opts $comp_file | wc -l)
2448 [ $found -eq 1 ] || error "resync: Second mirror comp flags incorrect"
2450 sel_layout_sanity $comp_file 5
2454 run_test 204b "FLR write/stale/resync tests with self-extending primary"
2456 # FLR + SEL failed extension & component removal
2457 # extension space in second mirror
2459 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2460 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2461 skip "skipped for lustre < $SEL_VER"
2463 local comp_file=$DIR/$tdir/$tfile
2466 local ost_name=$(ostname_from_index $ost_idx1)
2468 test_mkdir $DIR/$tdir
2470 # first mirror is is 0-10M, then 10M-(-1), second mirror is 0-1M, then
2471 # extension space from 1M to 1G, then normal space to -1
2472 $LFS setstripe -N -E 10M -E-1 -N -E 1M -E 1G -i $ost_idx1 -z 64M \
2473 -E -1 $comp_file || error "Create $comp_file failed"
2475 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
2478 # write to first comp (0 - 10M) of mirror 1, extending + staling
2479 # first + second comp of mirror 2
2480 dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
2483 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
2486 [ $RC -eq 0 ] || error "dd to extend + stale failed"
2488 $LFS getstripe $comp_file
2490 found=$($LFS find --component-start 0m --component-end 1m \
2491 --comp-flags init,stale $comp_file | wc -l)
2492 [ $found -eq 1 ] || error "write: First mirror comp incorrect"
2494 found=$($LFS find --component-start 1m --component-end EOF \
2495 --comp-flags stale,^init $comp_file | wc -l)
2496 [ $found -eq 1 ] || error "write: Second mirror comp incorrect"
2498 local mirror_id=$($LFS getstripe --component-start=1m \
2499 --component-end=EOF $comp_file | \
2500 grep lcme_mirror_id | awk '{ print $2 }')
2502 [[ $mirror_id -eq 2 ]] ||
2503 error "component not in correct mirror? $mirror_id"
2505 $LFS mirror resync $comp_file
2507 $LFS getstripe $comp_file
2509 # component dimensions should not change from resync
2510 found=$($LFS find --component-start 1m --component-end EOF \
2511 --component-flags init $comp_file | wc -l)
2512 [ $found -eq 1 ] || error "resync: Second mirror comp incorrect"
2514 sel_layout_sanity $comp_file 4
2518 run_test 204c "FLR write/stale/resync test with component removal"
2520 # Successful repeated component in primary mirror
2522 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2523 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2524 skip "skipped for lustre < $SEL_VERSION"
2526 local comp_file=$DIR/$tdir/$tfile
2529 wait_delete_completed
2531 test_mkdir $DIR/$tdir
2533 # first mirror is 64M followed by extension space to -1, second mirror
2534 # is 0-10M, then 10M-(-1)
2535 $LFS setstripe -N -E-1 -z64M -N -E 10M -E-1 $comp_file ||
2536 error "Create $comp_file failed"
2538 local ost_idx1=$($LFS getstripe -I65537 -i $comp_file)
2539 local ost_name=$(ostname_from_index $ost_idx1)
2540 # degrade OST for first comp so we won't extend there
2541 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2542 obdfilter.$ost_name.degraded=1
2545 # Write beyond first component, causing repeat & stale second mirror
2546 dd if=/dev/zero bs=1M count=1 seek=66 of=$comp_file conv=notrunc
2549 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2550 obdfilter.$ost_name.degraded=0
2553 [ $RC -eq 0 ] || error "dd to repeat & stale failed"
2555 $LFS getstripe $comp_file
2557 found=$($LFS find --component-start 64m --component-end 128m \
2558 --component-flags init $comp_file | wc -l)
2559 [ $found -eq 1 ] || error "write: Repeat comp incorrect"
2561 local ost_idx2=$($LFS getstripe --component-start=64m \
2562 --component-end=128m --component-flags=init \
2564 [[ $ost_idx1 -eq $ost_idx2 ]] && error "$ost_idx1 == $ost_idx2"
2565 local mirror_id=$($LFS getstripe --component-start=64m \
2566 --component-end=128m --component-flags=init \
2567 $comp_file | grep lcme_mirror_id | awk '{ print $2 }')
2568 [[ $mirror_id -eq 1 ]] ||
2569 error "component not in correct mirror: $mirror_id, not 1"
2571 $LFS mirror resync $comp_file
2573 $LFS getstripe $comp_file
2575 # component dimensions should not change from resync
2576 found=$($LFS find --component-start 0m --component-end 64m \
2577 --component-flags init $comp_file | wc -l)
2578 [ $found -eq 1 ] || error "resync: first comp incorrect"
2579 found=$($LFS find --component-start 64m --component-end 128m \
2580 --component-flags init $comp_file | wc -l)
2581 [ $found -eq 1 ] || error "resync: repeat comp incorrect"
2583 sel_layout_sanity $comp_file 5
2587 run_test 204d "FLR write/stale/resync sel test with repeated comp"
2589 # Successful repeated component, SEL in non-primary mirror
2591 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2592 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2593 skip "skipped for lustre < $SEL_VERSION"
2595 local comp_file=$DIR/$tdir/$tfile
2598 wait_delete_completed
2601 test_mkdir $DIR/$tdir
2603 # first mirror is is 0-100M, then 100M-(-1), second mirror is extension
2604 # space to -1 (-z 64M, so first comp is 0-64M)
2605 # Note: we have to place both 1st components on OST0, otherwise 2 OSTs
2606 # will be not enough - one will be degraded, the other is used on
2607 # an overlapping mirror.
2608 $LFS setstripe -N -E 100M -i 0 -E-1 -N -E-1 -i 0 -z 64M $comp_file ||
2609 error "Create $comp_file failed"
2611 local ost_idx1=$($LFS getstripe --component-start=0 \
2612 --component-end=64m -i $comp_file)
2613 local ost_name=$(ostname_from_index $ost_idx1)
2614 # degrade OST for first comp of 2nd mirror so we won't extend there
2615 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2616 obdfilter.$ost_name.degraded=1
2619 $LFS getstripe $comp_file
2621 # Write to first component, stale & instantiate second mirror components
2622 # overlapping with the written component (0-100M);
2623 dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
2626 do_facet ost$((ost_idx1+1)) $LCTL set_param -n \
2627 obdfilter.$ost_name.degraded=0
2629 $LFS getstripe $comp_file
2631 [ $RC -eq 0 ] || error "dd to repeat & stale failed"
2633 found=$($LFS find --component-start 0m --component-end 64m \
2634 --component-flags init,stale $comp_file | wc -l)
2635 [ $found -eq 1 ] || error "write: first comp incorrect"
2637 # was repeated due to degraded ost
2638 found=$($LFS find --component-start 64m --component-end 128m \
2639 --component-flags init,stale $comp_file | wc -l)
2640 [ $found -eq 1 ] || error "write: repeated comp incorrect"
2642 local ost_idx2=$($LFS getstripe --component-start=64m \
2643 --component-end=128m --component-flags=init \
2645 [[ $ost_idx1 -eq $ost_idx2 ]] && error "$ost_idx1 == $ost_idx2"
2646 local mirror_id=$($LFS getstripe --component-start=0m \
2647 --component-end=64m --component-flags=init \
2648 $comp_file | grep lcme_mirror_id | awk '{ print $2 }')
2649 [[ $mirror_id -eq 2 ]] ||
2650 error "component not in correct mirror? $mirror_id"
2652 $LFS mirror resync $comp_file
2654 $LFS getstripe $comp_file
2656 # component dimensions should not change from resync
2657 found=$($LFS find --component-start 0m --component-end 64m \
2658 --component-flags init,^stale $comp_file | wc -l)
2659 [ $found -eq 1 ] || error "resync: first comp incorrect"
2660 found=$($LFS find --component-start 64m --component-end 128m \
2661 --component-flags init,^stale $comp_file | wc -l)
2662 [ $found -eq 1 ] || error "resync: repeated comp incorrect"
2664 sel_layout_sanity $comp_file 5
2668 run_test 204e "FLR write/stale/resync sel test with repeated comp"
2670 # FLR + SEL: failed repeated component, SEL in non-primary mirror
2672 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
2673 [ "$MDS1_VERSION" -lt $(version_code $SEL_VER) ] &&
2674 skip "skipped for lustre < $SEL_VERSION"
2676 local comp_file=$DIR/$tdir/$tfile
2679 wait_delete_completed
2681 test_mkdir $DIR/$tdir
2683 pool_add $TESTNAME || error "Pool creation failed"
2684 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2686 # first mirror is is 0-100M, then 100M-(-1), second mirror is extension
2687 # space to -1 (-z 64M, so first comp is 0-64M)
2688 $LFS setstripe -N -E 100M -E-1 -N --pool="$TESTNAME" \
2689 -E-1 -c 1 -z 64M $comp_file || error "Create $comp_file failed"
2691 local ost_name0=$(ostname_from_index 0)
2692 local ost_name1=$(ostname_from_index 1)
2694 # degrade both OSTs in pool, so we'll try to repeat, then fail and
2695 # extend original comp
2696 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name0.degraded=1
2697 do_facet ost2 $LCTL set_param -n obdfilter.$ost_name1.degraded=1
2700 # a write to the 1st component, 100M length, which will try to stale
2701 # the first 100M of mirror 2, attempting to extend its 0-64M component
2702 dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
2705 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name0.degraded=0
2706 do_facet ost2 $LCTL set_param -n obdfilter.$ost_name1.degraded=0
2709 [ $RC -eq 0 ] || error "dd to extend mirror comp failed"
2711 $LFS getstripe $comp_file
2713 found=$($LFS find --component-start 0m --component-end 128m \
2714 --component-flags init,stale $comp_file | wc -l)
2715 [ $found -eq 1 ] || error "write: First mirror comp incorrect"
2717 local mirror_id=$($LFS getstripe --component-start=0m \
2718 --component-end=128m --component-flags=init \
2719 $comp_file | grep lcme_mirror_id | awk '{ print $2 }')
2721 [[ $mirror_id -eq 2 ]] ||
2722 error "component not in correct mirror? $mirror_id, not 2"
2724 $LFS mirror resync $comp_file
2726 $LFS getstripe $comp_file
2728 # component dimensions should not change from resync
2729 found=$($LFS find --component-start 0m --component-end 128m \
2730 --component-flags init,^stale $comp_file | wc -l)
2731 [ $found -eq 1 ] || error "resync: First mirror comp incorrect"
2733 sel_layout_sanity $comp_file 4
2737 run_test 204f "FLR write/stale/resync sel w/forced extension"
2740 check_and_cleanup_lustre