From b71766311daa0faf3560a2435778f7b2de1e3ad6 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Thu, 13 Dec 2018 14:21:31 -0600 Subject: [PATCH] LU-11773 utils: add PFL flags support to YAML API 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 Change-Id: If15999aa58ac3e31da677bd5d1ef8b063b46b1e5 Reviewed-on: https://review.whamcloud.com/33852 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu --- lustre/tests/sanity-flr.sh | 18 ++++++++---------- lustre/tests/sanity-pfl.sh | 27 ++++----------------------- lustre/tests/test-framework.sh | 20 ++++++++++++++++++++ lustre/utils/lfs.c | 10 ++++++++++ 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 9902cda..6a9dfc6 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -1820,7 +1820,7 @@ test_44() { 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 @@ -1832,16 +1832,14 @@ test_45() { -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" diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index 9524b9b..30f2492 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -653,25 +653,6 @@ test_15() { } 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" @@ -688,7 +669,7 @@ test_16() { $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 @@ -698,7 +679,7 @@ test_16() { 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 @@ -709,7 +690,7 @@ test_16() { 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 @@ -717,7 +698,7 @@ test_16() { $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" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index dc3649f..70b2aa4 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -9391,3 +9391,23 @@ save_layout_restore_at_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" +} + diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 089284d..fd944b6 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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, "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")) { -- 1.8.3.1