From: Bobi Jam Date: Thu, 13 Apr 2017 03:36:58 +0000 (+0800) Subject: LU-9324 test: get layout parameters X-Git-Tag: 2.9.57~61 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F26578%2F9;p=fs%2Flustre-release.git LU-9324 test: get layout parameters Add test framework functions get_layout_param()/parse_layout_param to get plain/PFL file/dir layout parameters, so that the layout parameters can be used later. Test-Parameters: trivial testlist=sanity-pfl Signed-off-by: Bobi Jam Change-Id: I4f43a5b4d23e353660114b7ff299a97afc405a07 Reviewed-on: https://review.whamcloud.com/26578 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: James Nunez Tested-by: Maloo --- diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index d8f56be..f1c7f8f 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -369,6 +369,7 @@ component_dump() { test_10() { local parent=$DIR/$tdir + local root_layout=$(get_layout_param $MOUNT) rm -rf $parent $LFS setstripe -d $MOUNT || error "clear root layout" @@ -406,6 +407,8 @@ test_10() { error "$parent/file1 does not inherite parent layout" [ x$f2_expect != x$f2_entry ] && error "$parent/file2 does not inherite root layout" + + $LFS setstripe $root_layout $MOUNT return 0 } run_test 10 "Inherit composite template from root" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 6d074c7..401a806 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -7854,3 +7854,69 @@ lss_gen_conf() do_facet mgs "cat $LSNAPSHOT_CONF" } + +parse_plain_param() +{ + local line=$1 + local val=$(awk '{print $2}' <<< $line) + + if [[ $line =~ ^"lmm_stripe_count:" ]]; then + echo "-c $val" + elif [[ $line =~ ^"lmm_stripe_size:" ]]; then + echo "-S $val" + elif [[ $line =~ ^"lmm_stripe_offset:" ]]; then + echo "-i $val" + fi +} + +parse_layout_param() +{ + local mode="" + local val="" + local param="" + + while read line; do + if [[ -z $mode ]]; then + if [[ $line =~ ^"stripe_count:" ]]; then + mode="plain_dir" + elif [[ $line =~ ^"lmm_stripe_count:" ]]; then + mode="plain_file" + elif [[ $line =~ ^"lcm_layout_gen:" ]]; then + mode="pfl" + fi + fi + + if [[ $mode = "plain_dir" ]]; then + param=$(echo $line | + awk '{printf("-c %d -S %d -i %d",$2,$4,$6)}') + elif [[ $mode = "plain_file" ]]; then + val=$(parse_plain_param "$line") + [[ ! -z $val ]] && param="$param $val" + elif [[ $mode = "pfl" ]]; then + val=$(echo $line | awk '{print $2}') + if [[ $line =~ ^"lcme_extent.e_end:" ]]; then + if [[ $val = "EOF" ]]; then + param="$param -E -1" + else + param="$param -E $val" + fi + elif [[ $line =~ ^"stripe_count:" ]]; then + # pfl dir + val=$(echo $line | + awk '{printf("-c %d -S %d -i %d",$2,$4,$6)}') + param="$param $val" + else + #pfl file + val=$(parse_plain_param "$line") + [[ ! -z $val ]] && param="$param $val" + fi + fi + done + echo "$param" +} + +get_layout_param() +{ + local param=$($LFS getstripe -d $1 | parse_layout_param) + echo "$param" +}