Whamcloud - gitweb
LU-10350 tests: make parsing routines pattern aware 36/30636/2
authorJames Nunez <james.a.nunez@intel.com>
Thu, 21 Dec 2017 21:23:40 +0000 (14:23 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 14 Jan 2018 02:36:07 +0000 (02:36 +0000)
'lfs getstripe' now returns the pattern for each component
of a directory and files. The routines that parse
parameters, parse_layout_param() and parse_plain_param(),
need to look for the component pattern when parsing the output
of 'lfs getstripe'.

Test-Parameters: trivial testlist=sanity-pfl,ost-pools
Signed-off-by: James Nunez <james.a.nunez@intel.com>
Change-Id: Iab605f58e9c8f501fa0889806c511e3310cb6dd7
Reviewed-on: https://review.whamcloud.com/30636
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity-pfl.sh
lustre/tests/test-framework.sh

index 88c6c72..e9be736 100644 (file)
@@ -375,6 +375,7 @@ component_dump() {
 test_10() {
        local parent=$DIR/$tdir
        local root_layout=$(get_layout_param $MOUNT)
+       echo "$MOUNT layout: $root_layout"
 
        rm -rf $parent
        $LFS setstripe -d $MOUNT || error "clear root layout"
index 1ca4b45..06910a8 100755 (executable)
@@ -8362,6 +8362,30 @@ lss_gen_conf()
        do_facet mgs "cat $LSNAPSHOT_CONF"
 }
 
+# Parse 'lfs getstripe -d <path_with_dir_name>' for non-composite dir
+parse_plain_dir_param()
+{
+       local invalues=($1)
+       local param=""
+
+       if [[ ${invalues[0]} =~ "stripe_count:" ]]; then
+               param="-c ${invalues[1]}"
+       fi
+       if [[ ${invalues[2]} =~ "stripe_size:" ]]; then
+               param="$param -S ${invalues[3]}"
+       fi
+       if [[ ${invalues[4]} =~ "pattern:" ]]; then
+               if [[ ${invalues[5]} =~ "stripe_offset:" ]]; then
+                       param="$param -i ${invalues[6]}"
+               else
+                       param="$param -L ${invalues[5]} -i ${invalues[7]}"
+               fi
+       elif [[ ${invalues[4]} =~ "stripe_offset:" ]]; then
+               param="$param -i ${invalues[5]}"
+       fi
+       echo "$param"
+}
+
 parse_plain_param()
 {
        local line=$1
@@ -8373,6 +8397,8 @@ parse_plain_param()
                echo "-S $val"
        elif [[ $line =~ ^"lmm_stripe_offset:" ]]; then
                echo "-i $val"
+       elif [[ $line =~ ^"lmm_pattern:" ]]; then
+               echo "-L $val"
        fi
 }
 
@@ -8383,39 +8409,39 @@ parse_layout_param()
        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"
+               if [[ ! -z $line ]]; then
+                       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
-               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
+                       if [[ $mode = "plain_dir" ]]; then
+                               param=$(parse_plain_dir_param "$line")
+                       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=$(parse_plain_dir_param "$line")
+                                       param="$param $val"
+                               else
+                                       #pfl file
+                                       val=$(parse_plain_param "$line")
+                                       [[ ! -z $val ]] && param="$param $val"
+                               fi
                        fi
                fi
        done