char *ptr;
struct ll_ioc_lease *data;
uint16_t mirror_count;
+ __u32 mirror_id;
int mdt_index;
int fd, fdv;
int rc;
rc = llapi_layout_comp_iterate(layout, find_comp_id_by_pool,
&data);
- id = data.id;
+ mirror_id = data.id;
} else if (mflags & MF_COMP_ID) {
rc = llapi_layout_comp_iterate(layout, find_comp_id, &id);
- id = mirror_id_of(id);
+ mirror_id = mirror_id_of(id);
} else {
rc = llapi_layout_comp_iterate(layout, find_mirror_id, &id);
+ mirror_id = id;
}
if (rc < 0) {
fprintf(stderr, "error %s: failed to iterate layout of '%s'\n",
progname, fname);
goto free_layout;
} else if (rc == LLAPI_LAYOUT_ITER_CONT) {
- fprintf(stderr,
- "error %s: file '%s' does not contain mirror with id %u\n",
- progname, fname, id);
- goto free_layout;
+ if (mflags & MF_COMP_POOL) {
+ fprintf(stderr,
+ "error %s: file '%s' does not contain mirror with pool '%s'\n",
+ progname, fname, pool);
+ goto free_layout;
+ } else if (mflags & MF_COMP_ID) {
+ fprintf(stderr,
+ "error %s: file '%s' does not contain mirror with comp-id %u\n",
+ progname, fname, id);
+ goto free_layout;
+ } else {
+ fprintf(stderr,
+ "error %s: file '%s' does not contain mirror with id %u\n",
+ progname, fname, id);
+ goto free_layout;
+ }
}
fd = open(fname, O_RDWR);
if (victim_file == NULL) {
/* use a temp file to store the splitted layout */
if (mflags & MF_DESTROY) {
- if (last_non_stale_mirror(id, layout)) {
+ if (last_non_stale_mirror(mirror_id, layout)) {
rc = -EUCLEAN;
fprintf(stderr,
"%s: cannot destroy the last non-stale mirror of file '%s'\n",
O_LOV_DELAY_CREATE);
} else {
snprintf(victim, sizeof(victim), "%s.mirror~%u",
- fname, id);
+ fname, mirror_id);
fdv = open(victim, flags, S_IRUSR | S_IWUSR);
}
} else {
data->lil_flags = LL_LEASE_LAYOUT_SPLIT;
data->lil_count = 2;
data->lil_ids[0] = fdv;
- data->lil_ids[1] = id;
+ data->lil_ids[1] = mirror_id;
rc = llapi_lease_set(fd, data);
if (rc <= 0) {
if (rc == 0) /* lost lease lock */
return rc;
}
+static int build_prev_component(struct llapi_layout **layout,
+ struct lfs_setstripe_args *prev,
+ struct lfs_setstripe_args *lsa,
+ bool set_extent)
+{
+ int extension = lsa->lsa_comp_flags & LCME_FL_EXTENSION;
+ int rc;
+
+ if (prev->lsa_stripe_size) {
+ if (extension) {
+ prev->lsa_comp_end = lsa->lsa_comp_end;
+ prev->lsa_extension_size = lsa->lsa_extension_size;
+ prev->lsa_extension_comp = true;
+ }
+
+ rc = build_component(layout, prev, true);
+ if (rc)
+ return rc;
+ }
+
+ /* Copy lsa to previous lsa;
+ * if this is an extension component, make the previous invalid; */
+ if (extension)
+ prev->lsa_stripe_size = 0;
+ else
+ *prev = *lsa;
+
+ return 0;
+}
+
static int build_layout_from_yaml_node(struct cYAML *node,
struct llapi_layout **layout,
struct lfs_setstripe_args *lsa,
- __u32 *osts)
+ struct lfs_setstripe_args *prevp)
{
+ struct lfs_setstripe_args prev = { 0 };
+ __u32 *osts = lsa->lsa_tgts;
char *string;
int rc = 0;
+ if (prevp == NULL)
+ prevp = &prev;
+
while (node) {
+ string = node->cy_string;
+
if (node->cy_type == CYAML_TYPE_OBJECT) {
/* 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, osts);
+ lsa, prevp);
if (rc)
return rc;
} else {
if (node->cy_string == NULL)
return -EINVAL;
- string = node->cy_string;
/* skip leading lmm_ if present, to simplify parsing */
if (strncmp(string, "lmm_", 4) == 0)
string += 4;
if (!strcmp(string, "lcm_mirror_count")) {
lsa->lsa_mirror_count = node->cy_valueint;
} else if (!strcmp(string, "lcme_extent.e_start")) {
- if (node->cy_valueint != 0 || *layout != NULL) {
- rc = build_component(layout, lsa, true);
- if (rc)
- return rc;
- }
-
if (node->cy_valueint == 0)
lsa->lsa_first_comp = true;
-
- /* initialize lsa */
- setstripe_args_init(lsa);
- lsa->lsa_tgts = osts;
} else if (!strcmp(string, "lcme_extent.e_end")) {
if (node->cy_valueint == -1)
lsa->lsa_comp_end = LUSTRE_EOF;
lsa->lsa_stripe_count = node->cy_valueint;
} else if (!strcmp(string, "stripe_size")) {
lsa->lsa_stripe_size = node->cy_valueint;
+ } else if (!strcmp(string, "extension_size")) {
+ lsa->lsa_extension_size = node->cy_valueint;
+ lsa->lsa_extension_comp = true;
} else if (!strcmp(string, "stripe_offset")) {
lsa->lsa_stripe_off = node->cy_valueint;
} else if (!strcmp(string, "l_ost_idx")) {
node = node->cy_next;
}
+ if (prevp == &prev) {
+ rc = build_prev_component(layout, prevp, lsa, true);
+ if (rc)
+ return rc;
+
+ if (!(lsa->lsa_comp_flags & LCME_FL_EXTENSION))
+ rc = build_component(layout, lsa, *layout != NULL);
+ }
+
return rc;
}
setstripe_args_init(lsa);
lsa->lsa_tgts = osts;
- rc = build_layout_from_yaml_node(tree, layout, lsa, osts);
+ rc = build_layout_from_yaml_node(tree, layout, lsa, NULL);
if (rc) {
fprintf(stderr, "%s: cannot build layout from YAML file %s.\n",
progname, template);
goto err;
- } else {
- rc = build_component(layout, lsa, *layout != NULL);
}
/* clean clean lsa */
setstripe_args_init(lsa);
uint64_t end;
int rc, ret = 0;
- if (layout == NULL)
+ if (layout == NULL || !(comp_add || llapi_layout_is_composite(layout)))
return 0;
errno = 0;
}
}
- if (layout != NULL || mirror_list != NULL) {
- if (mirror_list)
- result = mirror_adjust_first_extents(mirror_list);
- else
- result = layout_adjust_first_extent(fname, layout,
- comp_add);
- if (result == -ENODATA)
- comp_add = 0;
- else if (result != 0) {
- fprintf(stderr, "error: %s: invalid layout\n",
- progname);
- goto error;
- }
- }
-
if (from_yaml && from_copy) {
fprintf(stderr,
"%s: can't specify --yaml and --copy together\n",
}
}
+ if (layout != NULL || mirror_list != NULL) {
+ if (mirror_list)
+ result = mirror_adjust_first_extents(mirror_list);
+ else
+ result = layout_adjust_first_extent(fname, layout,
+ comp_add);
+ if (result == -ENODATA)
+ comp_add = 0;
+ else if (result != 0) {
+ fprintf(stderr, "error: %s: invalid layout\n",
+ progname);
+ goto error;
+ }
+ }
+
for (fname = argv[optind]; fname != NULL; fname = argv[++optind]) {
if (from_copy) {
layout = llapi_layout_get_by_path(template ?: fname, 0);
const char osn_name;
bool osn_err;
} oss_names[] = {
- { .osn_state = OS_STATE_DEGRADED, .osn_name = 'D', .osn_err = true },
- { .osn_state = OS_STATE_READONLY, .osn_name = 'R', .osn_err = true },
- { .osn_state = OS_STATE_NOPRECREATE, .osn_name = 'N', .osn_err = true },
- { .osn_state = OS_STATE_UNUSED1, .osn_name = '?', .osn_err = true },
- { .osn_state = OS_STATE_UNUSED2, .osn_name = '?', .osn_err = true },
- { .osn_state = OS_STATE_ENOSPC, .osn_name = 'S', .osn_err = true },
- { .osn_state = OS_STATE_ENOINO, .osn_name = 'I', .osn_err = true },
- { .osn_state = OS_STATE_SUM, .osn_name = 'a', /* aggregate */ },
- { .osn_state = OS_STATE_NONROT, .osn_name = 'f', /* flash */ },
+ { .osn_state = OS_STATFS_DEGRADED, .osn_name = 'D', .osn_err = true },
+ { .osn_state = OS_STATFS_READONLY, .osn_name = 'R', .osn_err = true },
+ { .osn_state = OS_STATFS_NOPRECREATE,.osn_name = 'N', .osn_err = true },
+ { .osn_state = OS_STATFS_UNUSED1, .osn_name = '?', .osn_err = true },
+ { .osn_state = OS_STATFS_UNUSED2, .osn_name = '?', .osn_err = true },
+ { .osn_state = OS_STATFS_ENOSPC, .osn_name = 'S', .osn_err = true },
+ { .osn_state = OS_STATFS_ENOINO, .osn_name = 'I', .osn_err = true },
+ { .osn_state = OS_STATFS_SUM, .osn_name = 'a', /* aggregate */ },
+ { .osn_state = OS_STATFS_NONROT, .osn_name = 'f', /* flash */ },
};
static int showdf(char *mntdir, struct obd_statfs *stat,