Whamcloud - gitweb
LU-14514 flr: mirror split should not make stale file
[fs/lustre-release.git] / lustre / tests / sanity-flr.sh
index d9f677e..fd811a2 100644 (file)
@@ -2000,7 +2000,7 @@ test_43b() {
 }
 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
@@ -2075,7 +2075,62 @@ test_44() {
        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
@@ -3754,9 +3809,10 @@ test_208a() {
 
        (( $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"
@@ -3767,12 +3823,12 @@ test_208a() {
        $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
@@ -3790,9 +3846,10 @@ test_208b() {
 
        (( $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"
@@ -3803,13 +3860,13 @@ test_208b() {
        $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