Whamcloud - gitweb
LU-7236 ptlrpc: idle connections can disconnect
[fs/lustre-release.git] / lustre / tests / sanity-flr.sh
index 3d87ba5..1ac707d 100644 (file)
@@ -32,6 +32,9 @@ assert_DIR
 
 build_test_filter
 
+assert_DIR
+rm -rf $DIR/[Rdfs][0-9]*
+
 # global array to store mirror IDs
 declare -a mirror_array
 get_mirror_ids() {
@@ -61,7 +64,7 @@ stop_osts() {
        done
 
        for idx in "$@"; do
-               wait_osc_import_state client ost$idx DISCONN
+               wait_osc_import_state client ost$idx "\(DISCONN\|IDLE\)"
        done
 }
 
@@ -632,8 +635,8 @@ run_test 0f "lfs mirror extend composite layout mirrors"
 test_0g() {
        local tf=$DIR/$tfile
 
-       $LFS mirror create -N -E 1M -o0 --flags=prefer -E eof -o1 -N -o1 $tf ||
-               error "create mirrored file $tf failed"
+       $LFS mirror create -N -E 1M -S 1M -o0 --flags=prefer -E eof -o1 \
+                          -N -o1 $tf || error "create mirrored file $tf failed"
 
        verify_comp_attr lcme_flags $tf 0x10001 prefer
        verify_comp_attr lcme_flags $tf 0x10002 prefer
@@ -660,7 +663,7 @@ run_test 0g "lfs mirror create flags support"
 test_0h() {
        local tf=$DIR/$tfile
 
-       $LFS mirror create -N -E 1M --flags=prefer -E eof -N2 $tf ||
+       $LFS mirror create -N -E 1M -S 1M --flags=prefer -E eof -N2 $tf ||
                error "create mirrored file $tf failed"
 
        verify_comp_attr lcme_flags $tf 0x10001 prefer
@@ -724,10 +727,8 @@ test_2() {
        local tf=$DIR/$tfile
        local tf2=$DIR/$tfile-2
 
-       $LFS setstripe -E 1M -E EOF -c 1 $tf
-       $LFS setstripe -E 2M -E EOF -c -1 $tf2
-
-       local layout=$($LFS getstripe $tf2 | grep -A 4 lmm_objects)
+       $LFS setstripe -E 1M -S 1M -E EOF -c 1 $tf
+       $LFS setstripe -E 2M -S 1M -E EOF -c -1 $tf2
 
        $LFS mirror extend -N -f $tf2 $tf ||
                error "merging $tf2 into $tf failed"
@@ -769,7 +770,7 @@ test_4() {
        test_mkdir $DIR/$tdir
 
        # set mirror with setstripe options to directory
-       $LFS mirror create -N2 -E 1M -E eof $DIR/$tdir ||
+       $LFS mirror create -N2 -E 1M -S 1M -E eof $DIR/$tdir ||
                error "set mirror to directory error"
 
        [ x$($LFS getstripe -v $DIR/$tdir | awk '/lcm_flags/{print $2}') = \
@@ -814,17 +815,17 @@ run_test 5 "Make sure init size work for mirrored layout"
 test_6() {
        local tf=$DIR/$tfile
 
-       $LFS mirror create -N -E 1M -L mdt -E eof -N -E eof $tf &&
+       $LFS mirror create -N -E 1M -S 1M -L mdt -E eof -N -E eof $tf &&
                error "expect failure to create mirrored file with DoM"
 
-       $LFS mirror create -N -E 1M -E eof -N -E 1M -L mdt -E eof $tf &&
+       $LFS mirror create -N -E 1M -S 1M -E eof -N -E 1M -L mdt -E eof $tf &&
                error "expect failure to create mirrored file with DoM"
 
-       $LFS setstripe -E 1M -L mdt -E eof $tf
+       $LFS setstripe -E 1M -S 1M -L mdt -E eof $tf
        $LFS mirror extend -N2 $tf &&
                error "expect failure to extend mirror with DoM"
 
-       $LFS mirror create -N2 -E 1M -E eof $tf-2
+       $LFS mirror create -N2 -E 1M -S 1M -E eof $tf-2
        $LFS mirror extend -N -f $tf $tf-2 &&
                error "expect failure to extend mirrored file with DoM extent"
 
@@ -1167,8 +1168,8 @@ create_file_36() {
        local tf
 
        for tf in "$@"; do
-               $LFS setstripe -E 1M -E 2M -E 4M -E eof -c -1 $tf
-               $LFS setstripe -E 3M -E 6M -E eof -c -1 $tf-tmp
+               $LFS setstripe -E 1M -S 1M -E 2M -E 4M -E eof -c -1 $tf
+               $LFS setstripe -E 3M -S 1M -E 6M -E eof -c -1 $tf-tmp
 
                $LFS mirror extend -N -f $tf-tmp $tf ||
                        error "merging $tf-tmp into $tf failed"
@@ -1196,7 +1197,7 @@ test_36() {
        verify_ost_layout_version $tf
 
        # test case 2
-       local mds_idx=mds$(($($LFS getstripe -M $tf-2) + 1))
+       local mds_idx=mds$(($($LFS getstripe -m $tf-2) + 1))
 
        local delay_sec=10
        do_facet $mds_idx $LCTL set_param fail_val=$delay_sec
@@ -1217,7 +1218,7 @@ test_36() {
        do_facet $mds_idx $LCTL set_param fail_loc=0
 
        # test case 3
-       mds_idx=mds$(($($LFS getstripe -M $tf-3) + 1))
+       mds_idx=mds$(($($LFS getstripe -m $tf-3) + 1))
 
        #define OBD_FAIL_FLR_LV_INC 0x1A02
        do_facet $mds_idx $LCTL set_param fail_loc=0x1A02
@@ -1238,7 +1239,7 @@ create_files_37() {
 
        shift
        for tf in "$@"; do
-               $LFS setstripe -E 1M -c 1 -E eof -c -1 $tf
+               $LFS setstripe -E 1M -S 1M -c 1 -E eof -c -1 $tf
 
                dd if=/dev/urandom of=$tf bs=1M count=16 &> /dev/null
                $TRUNCATE $tf $fsize
@@ -1320,9 +1321,12 @@ test_38() {
        local tf=$DIR/$tfile
        local ref=$DIR/${tfile}-ref
 
-       $LFS setstripe -E 1M -c 1 -E 4M -c 2 -E eof -c -1 $tf
-       $LFS setstripe -E 2M -c 1 -E 6M -c 2 -E 8M -c -1 -E eof -c -1 $tf-2
-       $LFS setstripe -E 4M -c 1 -E 8M -c 2 -E eof -c -1 $tf-3
+       $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 ||
@@ -1414,8 +1418,8 @@ test_40() {
        for ops in "conv=notrunc" ""; do
                rm -f $tf
 
-               $LFS mirror create -N -E2m -E4m -E-1  --flags=prefer \
-                               -N -E1m -E2m -E4m -E-1 $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"
@@ -1457,10 +1461,13 @@ test_41() {
 
        rm -f $tf $tf-1
        echo " **create two FLR files $tf $tf-1"
-       $LFS mirror create -N -E2m -E4m -E-1 -N -E1m -E2m -E3m -E-1 $tf ||
+       $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 -E2m -Eeof -N -E1m -Eeof --flags prefer \
-               -N -E4m -Eeof $tf-1 || error "create PFLR file $tf-1 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"
@@ -1547,13 +1554,13 @@ test_42() {
        $mirror_cmd $td &> /dev/null && error "$td is not a regular file"
 
        # create mirrored files
-       $LFS mirror create -N -E 4M -E 10M -E EOF $tf ||
+       $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 -E EOF \
+       $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 4M -c -1 $tf-2 ||
+       $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)
@@ -1715,7 +1722,8 @@ test_44() {
                error "create remote directory failed"
        rm -f $tf $tf1 $tf.mirror~2
        # create file with 4 mirrors
-       $LFS mirror create -N -E2m -E4m -E-1 -N -E1m -E2m -E3m -E-1 -N2 $tf ||
+       $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
@@ -1763,6 +1771,103 @@ test_44() {
 }
 run_test 44 "lfs mirror split check"
 
+test_45() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+
+       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"
+
+       echo "getstripe --yaml $file"
+       $LFS getstripe --yaml $file > $temp || error "getstripe $file failed"
+       echo "setstripe --yaml=$temp $file.2"
+       $LFS setstripe --yaml=$temp $file.2 || error "setstripe $file.2 failed"
+
+       echo "compare layout"
+       local layout1=$(get_layout_param $file)
+       local layout2=$(get_layout_param $file.2)
+       [ "$layout1" == "$layout2" ] ||
+               error "FLR file $file/$file.2 layouts are not equal"
+}
+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"
+       $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"
+}
+run_test 46 "Verify setstripe --copy option"
+
 ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
 lock_file=$(mktemp /var/lock/FLR.XXXXXX)
 
@@ -1832,8 +1937,8 @@ test_200() {
        local tf2=$DIR2/$tfile
        local tf3=$DIR3/$tfile
 
-       $LFS setstripe -E 1M -E 2M -c 2 -E 4M -E 16M -E eof $tf
-       $LFS setstripe -E 2M -E 6M -c 2 -E 8M -E 32M -E eof $tf-2
+       $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 ||
@@ -1850,7 +1955,7 @@ test_200() {
        #define OBD_FAIL_FLR_RANDOM_PICK_MIRROR 0x1A03
        $LCTL set_param fail_loc=0x1A03
 
-       local mds_idx=mds$(($($LFS getstripe -M $tf) + 1))
+       local mds_idx=mds$(($($LFS getstripe -m $tf) + 1))
        do_facet $mds_idx $LCTL set_param fail_loc=0x1A03
 
        declare -a pids
@@ -1955,7 +2060,7 @@ test_202() {
        local tf=$DIR/$tfile
        local ids
 
-       $LFS setstripe -E 1M -c 1 $tf
+       $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
 
@@ -1971,7 +2076,6 @@ test_202() {
 }
 run_test 202 "lfs setstripe --add-component wide striping"
 
-
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status