.SH SYNOPSIS
.B lfs mirror split
{\fB\-\-mirror\-id\fR <\fImirror_id\fR> | \fB\-\-component\-id\fR|\fB\-I\fR
-<\fIcomp_id\fR>}
+<\fIcomp_id\fR> |\fB\-\-pool\fR <\fIpool\fR>}
[\fB\-\-destroy\fR|\fB\-d\fR]
[\fB\-f\fR <\fInew_file\fR>]
<\fImirrored_file\fR>
.SH DESCRIPTION
This command splits a mirror with mirror ID <\fImirror_id\fR> or containing
-a component with <\fIcomp_id\fR> out of a mirrored
-file specified by the path name \fImirrored_file\fR. By default, the layout of
-the split mirror will be stored into a new file named
+a component with <\fIcomp_id\fR> or containing a component on <\fIpool\fR>
+out of a mirrored file specified by the path name \fImirrored_file\fR.
+By default, the layout of the split mirror will be stored into a new file named
<\fImirrored_file\fR>.mirror~<\fImirror_id\fR>. If \fB\-\-destroy\fR|\fB\-d\fR
option is specified, then the split mirror will be destroyed.
If \fB\-f\fR <\fInew_file\fR> option is specified, then the layout of the split
It can be fetched by \fBlfs getstripe\fR command (see \fBlfs(1)\fR).
.TP
.BR \-\-comp\-id\fR\ <\fIcomp_id\fR>
-The numerical unique identifier for a component contained withiin a mirror.
+The numerical unique identifier for a component contained within a mirror.
+.TP
+.BR \-\-pool\fR\ <\fIpool\fR>
+The pool storing a component contained within a mirror.
.TP
.BR \-\-destroy\fR|\fB\-d\fR
This option indicates the split mirror will be destroyed.
.B lfs mirror split --mirror-id 3 -f /mnt/lustre/file2 /mnt/lustre/file1
Split a mirror with ID 3 out of /mnt/lustre/file1 and store it into
/mnt/lustre/file2.
+.TP
+.B lfs mirror split --pool lustre-nvme -d /mnt/lustre/file1
+Split a mirror on pool lustre-nvme out of /mnt/lustre/file1 and destroy it.
.SH AUTHOR
The \fBlfs mirror split\fR command is part of the Lustre filesystem.
.SH SEE ALSO
MIRROR_EXTEND_HELP },
{ .pc_name = "split", .pc_func = lfs_mirror_split,
.pc_help = "Split a mirrored file.\n"
- "usage: lfs mirror split <--mirror-id <mirror_id> | \n"
- "\t <--component-id|-I <comp_id>> [--destroy|-d] \n"
+ "usage: lfs mirror split <--mirror-id <mirror_id> |\n"
+ "\t <--component-id|-I <comp_id>|-p <pool>> [--destroy|-d]\n"
"\t [-f <new_file>] <mirrored file>\n"
"\tmirror_id: The numerical unique identifier for a mirror. It\n"
"\t can be fetched by lfs getstripe command.\n"
"\tcomp_id: Unique component ID within a mirror.\n"
+ "\tpool: Components on specified pool.\n"
"\tnew_file: This option indicates the layout of the split\n"
"\t mirror will be stored into. If not specified,\n"
"\t a new file named <mirrored_file>.mirror~<mirror_id>\n"
MF_NO_VERIFY = 0x1,
MF_DESTROY = 0x2,
MF_COMP_ID = 0x4,
+ MF_COMP_POOL = 0x8,
};
/**
return LLAPI_LAYOUT_ITER_CONT;
}
-static int mirror_split(const char *fname, __u32 id,
+
+struct pool_to_id_cbdata {
+ const char *pool;
+ __u32 id;
+};
+static int find_comp_id_by_pool(struct llapi_layout *layout, void *cbdata)
+{
+ char buf[LOV_MAXPOOLNAME + 1];
+ struct pool_to_id_cbdata *d = (void *)cbdata;
+ uint32_t id;
+ int rc;
+
+ rc = llapi_layout_pool_name_get(layout, buf, sizeof(buf));
+ if (rc < 0)
+ return rc;
+ if (strcmp(d->pool, buf))
+ return LLAPI_LAYOUT_ITER_CONT;
+
+ rc = llapi_layout_mirror_id_get(layout, &id);
+ if (rc < 0)
+ return rc;
+ d->id = id;
+
+ return LLAPI_LAYOUT_ITER_STOP;
+}
+
+static int mirror_split(const char *fname, __u32 id, const char *pool,
enum mirror_flags mflags, const char *victim_file)
{
struct llapi_layout *layout;
goto free_layout;
}
- if (mflags & MF_COMP_ID) {
+ if (mflags & MF_COMP_POOL) {
+ struct pool_to_id_cbdata data = { .pool = pool };
+
+ rc = llapi_layout_comp_iterate(layout, find_comp_id_by_pool,
+ &data);
+ id = data.id;
+ } else if (mflags & MF_COMP_ID) {
rc = llapi_layout_comp_iterate(layout, find_comp_id, &id);
id = mirror_id_of(id);
} else {
lsa->lsa_stripe_count != LLAPI_LAYOUT_DEFAULT ||
lsa->lsa_stripe_off != LLAPI_LAYOUT_DEFAULT ||
lsa->lsa_pattern != LLAPI_LAYOUT_RAID0 ||
- lsa->lsa_pool_name != NULL ||
lsa->lsa_comp_end != 0);
}
result = mirror_extend(fname, mirror_list,
mirror_flags);
} else if (opc == SO_MIRROR_SPLIT) {
- if (mirror_id == 0 && comp_id == 0) {
+ if (!mirror_id && !comp_id && !lsa.lsa_pool_name) {
fprintf(stderr,
- "%s %s: no mirror id or component id is specified\n",
- progname, argv[0]);
+ "%s %s: no mirror id or component id or pool name"
+ " is specified\n", progname, argv[0]);
goto usage_error;
}
- if (mirror_id != 0)
+ if (lsa.lsa_pool_name)
+ mirror_flags |= MF_COMP_POOL;
+ else if (mirror_id != 0)
comp_id = mirror_id;
else
mirror_flags |= MF_COMP_ID;
- result = mirror_split(fname, comp_id, mirror_flags,
+ result = mirror_split(fname, comp_id, lsa.lsa_pool_name,
+ mirror_flags,
has_m_file ? mirror_list->m_file :
NULL);
} else if (layout != NULL) {