layout+="--copy $olddir"
OPT_COPY=true
elif ! $OPT_COMP; then
+ # this formatting is no longer consistent LU-15565
# avoid multiple getstripe calls
# lcm_mirror_count: 1
# lcm_entry_count: 0
# lmm_stripe_count: 1
# lmm_stripe_size: 1048576
# lmm_pool: pool_abc
- local l_mirror_count=0
- local l_comp_count=1
- local l_stripe_count=2
- local l_stripe_size=3
- local l_stripe_pool=4
+ local l_mirror_count
+ local l_comp_count
+ local l_stripe_count
+ local l_stripe_size
+ local l_stripe_pool
local layout_info
layout_info=($($LFS getstripe $getstripe_opts $OLDNAME \
- 2>/dev/null | awk '{ print $2 }'))
+ 2>/dev/null | awk '{ print }'))
+
+ for ((i = 0; i < ${#layout_info[*]}; i++)); do
+ case "${layout_info[$i]}" in
+ *mirror_count*) l_mirror_count=$((i + 1));;
+ *entry_count*) l_comp_count=$((i + 1));;
+ *stripe_count*) l_stripe_count=$((i + 1));;
+ *stripe_size*) l_stripe_size=$((i + 1));;
+ *stripe_pool*) l_stripe_pool=$((i + 1));;
+ esac
+ done
+
# If rsync copies Lustre xattrs properly in the future
# (i.e. before the file data, so that it preserves
# striping) then we don't need this getstripe stuff.
}
run_test 205i "check job_xattr parameter accepts and rejects values correctly"
+# LU-15565
+test_205j() {
+ local new=$DIR/$tdir/$tfile-layout-new
+ local old=$DIR/$tdir/$tfile-layout-old
+
+ test_mkdir $DIR/$tdir
+
+ cat << PFL_LAYOUT_NEW > $new
+lcm_layout_gen: 3
+lcm_mirror_count: 1
+lcm_entry_count: 3
+components:
+ - lcme_id: 1
+ lcme_mirror_id: 0
+ lcme_flags: init
+ lcme_extent.e_start: 0
+ lcme_extent.e_end: 1073741824
+ sub_layout:
+ lmm_stripe_count: 1
+ lmm_stripe_size: 4194304
+ lmm_pattern: raid0
+ lmm_layout_gen: 0
+ lmm_stripe_offset: 0
+ lmm_objects:
+ - l_ost_idx: 0
+ l_fid: 0x280000400:0x2:0x0
+ - lcme_id: 2
+ lcme_mirror_id: 0
+ lcme_flags: 0
+ lcme_extent.e_start: 1073741824
+ lcme_extent.e_end: 4294967296
+ sub_layout:
+ lmm_stripe_count: 4
+ lmm_stripe_size: 4194304
+ lmm_pattern: raid0
+ lmm_layout_gen: 0
+ lmm_stripe_offset: -1
+ - lcme_id: 3
+ lcme_mirror_id: 0
+ lcme_flags: 0
+ lcme_extent.e_start: 4294967296
+ lcme_extent.e_end: EOF
+ sub_layout:
+ lmm_stripe_count: 4
+ lmm_stripe_size: 4194304
+ lmm_pattern: raid0
+ lmm_layout_gen: 0
+ lmm_stripe_offset: -1
+PFL_LAYOUT_NEW
+
+# Layout changed in 2.16.0
+ cat << PFL_LAYOUT_OLD > $old
+ lcm_layout_gen: 3
+ lcm_mirror_count: 1
+ lcm_entry_count: 3
+ component0:
+ lcme_id: 1
+ lcme_mirror_id: 0
+ lcme_flags: init
+ lcme_extent.e_start: 0
+ lcme_extent.e_end: 1073741824
+ sub_layout:
+ lmm_stripe_count: 1
+ lmm_stripe_size: 4194304
+ lmm_pattern: raid0
+ lmm_layout_gen: 0
+ lmm_stripe_offset: 0
+ lmm_objects:
+ - l_ost_idx: 0
+ l_fid: 0x280000400:0x2:0x0
+ component1:
+ lcme_id: 2
+ lcme_mirror_id: 0
+ lcme_flags: 0
+ lcme_extent.e_start: 1073741824
+ lcme_extent.e_end: 4294967296
+ sub_layout:
+ lmm_stripe_count: 4
+ lmm_stripe_size: 4194304
+ lmm_pattern: raid0
+ lmm_layout_gen: 0
+ lmm_stripe_offset: -1
+ component2:
+ lcme_id: 3
+ lcme_mirror_id: 0
+ lcme_flags: 0
+ lcme_extent.e_start: 4294967296
+ lcme_extent.e_end: EOF
+ sub_layout:
+ lmm_stripe_count: 4
+ lmm_stripe_size: 4194304
+ lmm_pattern: raid0
+ lmm_layout_gen: 0
+ lmm_stripe_offset: -1
+PFL_LAYOUT_OLD
+
+ local yaml_file=$DIR/$tdir/layout.yaml
+ local dir=$DIR/$tdir
+ local test=$dir/$tfile.test
+
+ $LFS setstripe -E 4M -c 2 -E EOF -c 4 $test ||
+ error "failed to setstripe"
+ $LFS getstripe --yaml $test > $yaml_file ||
+ error "failed to getstripe --yaml"
+
+ $LFS setstripe --yaml $old $dir/$tfile.new ||
+ error "failed to setstripe from new YAML format"
+ # test that the old format can still be used
+ $LFS setstripe --yaml $old $dir/$tfile.old ||
+ error "failed to setstripe from old YAML format"
+
+ local orig=$(get_layout_param $test)
+ local rest=$(cat $yaml_file | parse_layout_param)
+ [[ "$orig" == "$rest" ]] ||
+ error "failed to parse current YAML layout"
+
+ orig=$(get_layout_param $dir/$tfile.old)
+ rest=$(cat $old | parse_layout_param)
+ [[ "$orig" == "$rest" ]] ||
+ error "failed to parse old YAML layout"
+
+ orig=$(get_layout_param $dir/$tfile.new)
+ rest=$(cat $new | parse_layout_param)
+ [[ "$orig" == "$rest" ]] ||
+ error "failed to parse new YAML layout"
+
+}
+run_test 205j "verify new YAML format is valid and back-compatible"
+
# LU-1480, LU-1773 and LU-1657
test_206() {
mkdir -p $DIR/$tdir
static int build_prev_component(struct llapi_layout **layout,
struct lfs_setstripe_args *prev,
- struct lfs_setstripe_args *lsa,
- bool set_extent)
+ struct lfs_setstripe_args *lsa)
{
int extension = lsa->lsa_comp_flags & LCME_FL_EXTENSION;
int rc;
while (node) {
string = node->cy_string;
- if (node->cy_type == CYAML_TYPE_OBJECT) {
+ if (node->cy_type == CYAML_TYPE_OBJECT ||
+ node->cy_type == CYAML_TYPE_ARRAY) {
/* go deep to sub blocks */
- if (string && !strncmp(string, "component", 9) &&
- strncmp(string, "component0", 10) &&
- strncmp(string, "components", 10)) {
- rc = build_prev_component(layout, prevp, lsa,
- true);
- if (rc)
- return rc;
-
- /* initialize lsa. */
- setstripe_args_init(lsa);
- lsa->lsa_first_comp = false;
- lsa->lsa_tgts = osts;
- }
-
rc = build_layout_from_yaml_node(node->cy_child, layout,
lsa, prevp);
if (rc)
if (!node->cy_string)
return -EINVAL;
+ if (strcmp(string, "lcme_id") == 0 &&
+ lsa->lsa_stripe_count != LLAPI_LAYOUT_DEFAULT) {
+ rc = build_prev_component(layout, prevp, lsa);
+ if (rc)
+ return rc;
+
+ /* initialize lsa. */
+ setstripe_args_init(lsa);
+ lsa->lsa_first_comp = false;
+ lsa->lsa_tgts = osts;
+ }
/* skip leading lmm_ if present, to simplify parsing */
if (strncmp(string, "lmm_", 4) == 0)
string += 4;
}
if (prevp == &prev) {
- rc = build_prev_component(layout, prevp, lsa, true);
+ rc = build_prev_component(layout, prevp, lsa);
if (rc)
return rc;
}
}
}
- llapi_printf(LLAPI_MSG_NORMAL, "\n");
+ if (!yaml)
+ llapi_printf(LLAPI_MSG_NORMAL, "\n");
}
static void hsm_flags2str(__u32 hsm_flags)
if (verbose & VERBOSE_GENERATION) {
if (verbose & ~VERBOSE_GENERATION)
- llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_layout_gen: ",
- " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%slcm_layout_gen: ",
+ yaml ? "" : " ");
llapi_printf(LLAPI_MSG_NORMAL, "%u\n", comp_v1->lcm_layout_gen);
}
if (verbose & VERBOSE_MIRROR_COUNT) {
if (verbose & ~VERBOSE_MIRROR_COUNT)
- llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_mirror_count: ",
- " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%slcm_mirror_count: ",
+ yaml ? "" : " ");
llapi_printf(LLAPI_MSG_NORMAL, "%u\n",
comp_v1->lcm_magic == LOV_USER_MAGIC_COMP_V1 ?
comp_v1->lcm_mirror_count + 1 : 1);
if (verbose & VERBOSE_COMP_COUNT) {
if (verbose & ~VERBOSE_COMP_COUNT)
- llapi_printf(LLAPI_MSG_NORMAL, "%2slcm_entry_count: ",
- " ");
+ llapi_printf(LLAPI_MSG_NORMAL, "%slcm_entry_count: ",
+ yaml ? "" : " ");
llapi_printf(LLAPI_MSG_NORMAL, "%u\n",
comp_v1->lcm_magic == LOV_USER_MAGIC_COMP_V1 ?
comp_v1->lcm_entry_count : 0);
}
- if (verbose & VERBOSE_DETAIL && !yaml)
+ if (verbose & VERBOSE_DETAIL || yaml)
llapi_printf(LLAPI_MSG_NORMAL, "components:\n");
}
entry = &comp_v1->lcm_entries[index];
- if (yaml)
- llapi_printf(LLAPI_MSG_NORMAL, "%2scomponent%d:\n", " ", index);
-
- if (verbose & VERBOSE_COMP_ID) {
- if (verbose & VERBOSE_DETAIL && !yaml)
+ if (verbose & VERBOSE_COMP_ID || yaml) {
+ if (verbose & VERBOSE_DETAIL || yaml)
llapi_printf(LLAPI_MSG_NORMAL,
"%slcme_id: ", " - ");
else if (verbose & ~VERBOSE_COMP_ID)