}
run_test 43b "allow writing to multiple preferred mirror file"
-test_44() {
+test_44a() {
[ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
rm -rf $DIR/$tdir
rm -rf $DIR/$tdir-1
diff $tf $tf.mirror~2 ||
error "splited file $tf.mirror~2 diffs from $tf"
}
-run_test 44 "lfs mirror split check"
+run_test 44a "lfs mirror split check"
+
+test_44b() {
+ rm -rf $DIR/$tdir
+ local tf=$DIR/$tdir/$tfile
+
+ mkdir -p $DIR/$tdir || error "create directory failed"
+
+ echo XXX > $tf
+
+ # create 2 mirrors file
+ $LFS mirror extend -N -c1 $tf
+
+ echo YYY > $tf
+
+ verify_flr_state $tf "wp"
+
+ local str=$(cat $tf)
+
+ [[ $str == "YYY" ]] || error "$tf content is not YYY"
+
+ # get the non-stale mirror id
+ local ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' |
+ tr '\n' ' '))
+ local mirror_ids=($($LFS getstripe $tf |
+ awk '/lcme_mirror_id/{print $2}' | tr '\n' ' '))
+ for ((i = 0; i < 2; i++)); do
+ $LFS getstripe -I${ids[$i]} --component-flags $tf |
+ grep stale > /dev/null || break
+ done
+
+ [[ $i -ge 2 ]] && ( $LFS getstripe $tf; error "no stale mirror" )
+
+ $LFS getstripe $tf
+
+ # split the updated mirror, should fail
+ echo "split mirror_id ${mirror_ids[$i]} id ${ids[$i]}, should fail"
+ $LFS mirror split --mirror-id=${mirror_ids[$i]} $tf &> /dev/null &&
+ error "split --mirror-id=${mirror_ids[$i]} $tf should fail"
+
+ i=$(( 1 - i ))
+ # split the stale mirror
+ echo "split mirror_id ${mirror_ids[$i]} id ${ids[$i]}"
+ $LFS mirror split --mirror-id=${mirror_ids[$i]} -d $tf ||
+ error "mirror split --mirror-id=${mirror_ids[$i]} $tf failed"
+
+ echo "make sure there's no stale comp in the file"
+ # make sure there's no stale comp in the file
+ $LFS getstripe $tf | awk '/lcme_flags/{print $2}' | grep stale &&
+ ( $LFS getstripe $tf; error "stale mirror file" )
+
+ str=$(cat $tf)
+ [[ $str == "YYY" ]] ||
+ ( cat $tf; error "$tf content is not YYY after split" )
+}
+run_test 44b "mirror split does not create stale file"
test_44c() {
local tf=$DIR/$tdir/$tfile
(( $OSTCOUNT >= 4 )) || skip_env "needs >= 4 OSTs"
- old=$(do_nodes $(comma_list $(osts_nodes)) \
- $LCTL get_param osd*.*OST*.nonrotational | tr '\n' ' ')
- stack_trap "do_nodes $osts $LCTL set_param $old"
+ local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+ save_lustre_params $(get_facets OST) osd*.*OST*.nonrotational > $p
+ stack_trap "restore_lustre_params < $p; rm -f $p"
stack_trap "rm -f $tf"
$LFS setstripe -i0 -c1 $tf || error "can't setstripe"
$LFS getstripe $tf
log "set OST0000 non-rotational"
- do_nodes $(comma_list $(osts_nodes)) \
+ do_nodes $osts \
$LCTL set_param osd*.*OST0000*.nonrotational=1
check_ost_used $tf read 0
log "set OST0002 and OST0003 non-rotational, two fast OSTs is better"
- do_nodes $(comma_list $(osts_nodes)) \
+ do_nodes $osts \
$LCTL set_param osd*.*OST0002*.nonrotational=1 \
osd*.*OST0003*.nonrotational=1
check_ost_used $tf read 2 3
(( $OSTCOUNT >= 4 )) || skip_env "needs >= 4 OSTs"
- old=$(do_nodes $(comma_list $(osts_nodes)) \
- $LCTL get_param osd*.*OST*.nonrotational | tr '\n' ' ')
- stack_trap "do_nodes $osts $LCTL set_param $old"
+ local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+ save_lustre_params $(get_facets OST) osd*.*OST*.nonrotational > $p
+ stack_trap "restore_lustre_params < $p; rm -f $p"
stack_trap "rm -f $tf"
$LFS setstripe -i0 -c1 $tf || error "can't setstripe"
$LFS getstripe $tf | grep -q flags.*stale && error "still stale"
log "set OST0000 non-rotational"
- do_nodes $(comma_list $(osts_nodes)) \
+ do_nodes $osts \
$LCTL set_param osd*.*OST0000*.nonrotational=1
check_ost_used $tf write 0
$LFS mirror resync $tf || error "can't resync"
log "set OST0002 and OST0003 non-rotational, two fast OSTs is better"
- do_nodes $(comma_list $(osts_nodes)) \
+ do_nodes $osts \
$LCTL set_param osd*.*OST0002*.nonrotational=1 \
osd*.*OST0003*.nonrotational=1
check_ost_used $tf write 2 3