Whamcloud - gitweb
LU-11773 utils: add PFL flags support to YAML API 52/33852/4
authorPatrick Farrell <paf@cray.com>
Thu, 13 Dec 2018 20:21:31 +0000 (14:21 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 Feb 2019 02:01:46 +0000 (02:01 +0000)
The setstripe YAML interface currently ignores the
lcme_flags field. This means it doesn't work correctly with
some FLR layouts.

Fixing this is a trivial matter of making the YAML layout
generator read & use the lcme_flags field.

Signed-off-by: Patrick Farrell <paf@cray.com>
Change-Id: If15999aa58ac3e31da677bd5d1ef8b063b46b1e5
Reviewed-on: https://review.whamcloud.com/33852
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
lustre/tests/sanity-flr.sh
lustre/tests/sanity-pfl.sh
lustre/tests/test-framework.sh
lustre/utils/lfs.c

index 9902cda..6a9dfc6 100644 (file)
@@ -1820,7 +1820,7 @@ test_44() {
 run_test 44 "lfs mirror split check"
 
 test_45() {
 run_test 44 "lfs mirror split check"
 
 test_45() {
-       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
 
        local file=$DIR/$tdir/$tfile
        local dir=$DIR/$tdir/$dir
 
        local file=$DIR/$tdir/$tfile
        local dir=$DIR/$tdir/$dir
@@ -1832,16 +1832,14 @@ test_45() {
                -N -E3m -S1m -Eeof -N -E8m -Eeof $file ||
                        error "Create $file failed"
 
                -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"
+       verify_yaml_layout $file $file.copy $temp "1. FLR file"
+       rm -f $file $file.copy
 
 
-       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"
+       $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
+               -N -E3m -S1m -Eeof -N -E8m --flags=prefer -Eeof $file ||
+                       error "Create $file failed"
+
+       verify_yaml_layout $file $file.copy $temp "2. FLR file with flags"
 }
 run_test 45 "Verify setstripe/getstripe with YAML with FLR file"
 
 }
 run_test 45 "Verify setstripe/getstripe with YAML with FLR file"
 
index 9524b9b..30f2492 100644 (file)
@@ -653,25 +653,6 @@ test_15() {
 }
 run_test 15 "Verify component options for lfs find"
 
 }
 run_test 15 "Verify component options for lfs find"
 
-verify_16() {
-       local src=$1
-       local dst=$2
-       local temp=$3
-       local msg_prefix=$4
-
-       echo "getstripe --yaml $src"
-       $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
-       echo "setstripe --yaml=$temp $dst"
-       $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
-
-       echo "compare"
-       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_16() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
 
 test_16() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
 
@@ -688,7 +669,7 @@ test_16() {
                $file || error "Create $file failed"
 
        echo "1. PFL file"
                $file || error "Create $file failed"
 
        echo "1. PFL file"
-       verify_16 $file $file.copy $temp "1. PFL file"
+       verify_yaml_layout $file $file.copy $temp "1. PFL file"
 
        #####################################################################
        #                           2. plain file
 
        #####################################################################
        #                           2. plain file
@@ -698,7 +679,7 @@ test_16() {
 
        rm -f $file.copy
        echo "2. plain file"
 
        rm -f $file.copy
        echo "2. plain file"
-       verify_16 $file $file.copy $temp "2. plain file"
+       verify_yaml_layout $file $file.copy $temp "2. plain file"
 
        #####################################################################
        #                           3. PFL dir
 
        #####################################################################
        #                           3. PFL dir
@@ -709,7 +690,7 @@ test_16() {
 
        test_mkdir $dir.copy
        echo "3. PFL dir"
 
        test_mkdir $dir.copy
        echo "3. PFL dir"
-       verify_16 $dir $dir.copy $temp.dir "3. PFL dir"
+       verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir"
 
        #####################################################################
        #                           4. plain dir
 
        #####################################################################
        #                           4. plain dir
@@ -717,7 +698,7 @@ test_16() {
        $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
 
        echo "4. plain dir"
        $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed"
 
        echo "4. plain dir"
-       verify_16 $dir $dir.copy $temp.dir "4. plain dir"
+       verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir"
 }
 run_test 16 "Verify setstripe/getstripe with YAML config file"
 
 }
 run_test 16 "Verify setstripe/getstripe with YAML config file"
 
index dc3649f..70b2aa4 100755 (executable)
@@ -9391,3 +9391,23 @@ save_layout_restore_at_exit() {
 
        stack_trap "restore_layout $dir $layout" EXIT
 }
 
        stack_trap "restore_layout $dir $layout" EXIT
 }
+
+verify_yaml_layout() {
+       local src=$1
+       local dst=$2
+       local temp=$3
+       local msg_prefix=$4
+
+       echo "getstripe --yaml $src"
+       $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
+       echo "setstripe --yaml=$temp $dst"
+       $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
+
+       echo "compare"
+       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"
+}
+
index 089284d..fd944b6 100644 (file)
@@ -2290,6 +2290,16 @@ static int build_layout_from_yaml_node(struct cYAML *node,
                                } else if (!strcmp(string, "pattern")) {
                                        if (!strcmp(node->cy_valuestring, "mdt"))
                                                lsa->lsa_pattern = LLAPI_LAYOUT_MDT;
                                } else if (!strcmp(string, "pattern")) {
                                        if (!strcmp(node->cy_valuestring, "mdt"))
                                                lsa->lsa_pattern = LLAPI_LAYOUT_MDT;
+                               } else if (!strcmp(string, "lcme_flags")) {
+                                       rc = comp_str2flags(node->cy_valuestring,
+                                                           &lsa->lsa_comp_flags,
+                                                           &lsa->lsa_comp_neg_flags);
+                                       if (rc)
+                                               return rc;
+                                       /* Only template flags have meaning in
+                                        * the layout for a new file
+                                        */
+                                       lsa->lsa_comp_flags &= LCME_TEMPLATE_FLAGS;
                                }
                        } else if (node->cy_type == CYAML_TYPE_NUMBER) {
                                if (!strcmp(string, "lcm_mirror_count")) {
                                }
                        } else if (node->cy_type == CYAML_TYPE_NUMBER) {
                                if (!strcmp(string, "lcm_mirror_count")) {