Whamcloud - gitweb
LU-9324 test: get layout parameters 34/26634/4
authorBobi Jam <bobijam.xu@intel.com>
Thu, 13 Apr 2017 03:36:58 +0000 (11:36 +0800)
committerAndreas Dilger <andreas.dilger@intel.com>
Wed, 19 Apr 2017 21:48:19 +0000 (21:48 +0000)
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 <bobijam.xu@intel.com>
Change-Id: I4f43a5b4d23e353660114b7ff299a97afc405a07
Reviewed-on: https://review.whamcloud.com/26634
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/tests/sanity-pfl.sh
lustre/tests/test-framework.sh

index eb368a9..ceb6245 100644 (file)
@@ -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"
index 732587e..63d2575 100755 (executable)
@@ -7781,3 +7781,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"
+}