lfs_migrate.1 \
lfs-migrate.1 \
lfs-mirror-create.1 \
+ lfs-mirror-delete.1 \
lfs-mirror-extend.1 \
lfs-mirror-resync.1 \
lfs-mirror-split.1 \
.SH SEE ALSO
.BR lfs (1),
.BR lfs-setstripe (1),
+.BR lfs-mirror-delete (1),
.BR lfs-mirror-extend (1),
.BR lfs-mirror-split (1),
.BR lfs-mirror-resync (1),
--- /dev/null
+.TH LFS-MIRROR-DELETE 1 2019-09-15 "Lustre" "Lustre Utilities"
+.SH NAME
+lfs mirror delete \- delete a specified mirror from an existing mirrored file
+.SH SYNOPSIS
+.B lfs mirror delete
+{\fB\-\-mirror\-id\fR <\fImirror_id\fR> | \fB\-\-component\-id\fR|\fB\-I\fR
+<\fIcomp_id\fR> |\fB\-\-pool\fR <\fIpool\fR>}
+<\fImirrored_file\fR>
+.SH DESCRIPTION
+This command deletes a mirror with mirror ID <\fImirror_id\fR> or containing
+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.
+.br
+If \fImirrored_file\fR has only one mirror existing after split, it will be
+converted to a regular non-mirrored file.
+.br
+If the original \fImirrored_file\fR is not a mirrored file, then the command
+will return an error.
+.br
+If the specified mirror is the last non-stale mirror, then the command will
+return an error.
+.SH OPTIONS
+.TP
+.BR \-\-mirror\-id\fR\ <\fImirror_id\fR>
+The numerical unique identifier for a mirror. The mirror ID is unique within a
+mirrored file and is automatically assigned at file creation or extension time.
+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 within a mirror.
+.TP
+.BR \-\-pool\fR\ <\fIpool\fR>
+The pool storing a component contained within a mirror.
+.SH EXAMPLES
+.TP
+.B lfs mirror delete --mirror-id 2 /mnt/lustre/file1
+Delete the mirror with ID 2 of /mnt/lustre/file1.
+.TP
+.B lfs mirror delete --pool ssd /mnt/lustre/file1
+Split a mirror on pool ssd 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
+.BR lfs (1),
+.BR lfs-setstripe (1),
+.BR lfs-mirror-create (1),
+.BR lfs-mirror-extend (1),
+.BR lfs-mirror-resync (1),
+.BR lfs-mirror-split (1),
+.BR lfs-mirror-verify (1)
If \fIsetstripe_options\fR are not specified,
then the stripe options inherited from the previous component will be used.
If \fIvictim_file\fR exists, then the
-command will split the layout from that file and use it as a mirror added to the
-mirrored file. After the command is finished, the victim file will be removed.
-The \fIsetstripe_options\fR cannot be specified with
+command will merge the layout from that file as a mirror added to the
+mirrored file. After the command is finished, the victim file will be
+removed. The \fIsetstripe_options\fR cannot be specified with
\fB\-f\fR <\fIvictim_file\fR> option in one command line.
.br
If \fIvictim_file\fR is specified, the utility will verify that the file contents
\fB\-f\fR <\fIvictim_file\fR> option.
.TP
.BR \-f\fR\ <\fIvictim_file\fR>
-The layout of \fIvictim_file\fR will be split and used as a mirror added to the
+The layout of \fIvictim_file\fR will be merged as a mirror added to the
mirrored file. This option cannot be specified with \fIsetstripe_options\fR
option.
.TP
.B lfs mirror extend --no-verify -N -f /mnt/lustre/file2 -N -f /mnt/lustre/file3
.B /mnt/lustre/file1
.in
-Split the layouts from /mnt/lustre/file2 and /mnt/lustre/file3, which contain
+Merge the layouts from /mnt/lustre/file2 and /mnt/lustre/file3, which contain
the same data as /mnt/lustre/file1, use the layouts as mirrors and add them to
/mnt/lustre/file1 without verification.
.SH AUTHOR
.BR lfs (1),
.BR lfs-setstripe (1),
.BR lfs-mirror-create (1),
+.BR lfs-mirror-delete (1),
.BR lfs-mirror-split (1),
.BR lfs-mirror-resync (1),
.BR lfs-mirror-verify (1)
.BR lfs (1),
.BR lfs-setstripe (1),
.BR lfs-mirror-create (1),
+.BR lfs-mirror-delete (1),
.BR lfs-mirror-extend (1),
.BR lfs-mirror-resync (1),
.BR lfs-mirror-verify (1)
# LU-11022 - remove mirror by pool name
local=cnt cnt=$($LFS getstripe $tf | grep archive | wc -l)
[ "$cnt" != "1" ] && error "unexpected mirror count $cnt"
- $LFS mirror split --pool archive -d $tf || error "delete mirror"
+ $LFS mirror delete --pool archive $tf || error "delete mirror"
cnt=$($LFS getstripe $tf | grep archive | wc -l)
[ "$cnt" != "0" ] && error "mirror count after removal: $cnt"
fi
verify_flr_state $tf "wp"
# disallow destroying the last non-stale mirror
- ! $LFS mirror split --mirror-id 1 -d $tf > /dev/null 2>&1 ||
+ ! $LFS mirror delete --mirror-id 1 $tf > /dev/null 2>&1 ||
error "destroying mirror 1 should fail"
# synchronize all mirrors of the file
#create 2 mirrors
$LFS mirror create -N2 -c1 $tf || error "create FLR file $tf"
#delete first mirror
- $LFS mirror split --mirror-id=1 -d $tf || error "delete first mirror"
+ $LFS mirror delete --mirror-id=1 $tf || error "delete first mirror"
$LFS getstripe $tf
local old_id=$($LFS getstripe --mirror-id=2 -I $tf)
SO_MIRROR_CREATE,
SO_MIRROR_EXTEND,
SO_MIRROR_SPLIT,
+ SO_MIRROR_DELETE,
};
static int lfs_setstripe_internal(int argc, char **argv,
enum setstripe_origin opc);
{
return lfs_setstripe_internal(argc, argv, SO_MIRROR_SPLIT);
}
+static inline int lfs_mirror_delete(int argc, char **argv)
+{
+ return lfs_setstripe_internal(argc, argv, SO_MIRROR_DELETE);
+}
/* Setstripe and migrate share mostly the same parameters */
#define SSM_CMD_COMMON(cmd) \
.pc_help = "Create a mirrored file.\n"
"usage: lfs mirror create "
"<--mirror-count|-N[mirror_count]> "
- "[setstripe options] ... <filename|directory>\n"
+ "[setstripe options] ... <filename|directory> ...\n"
MIRROR_CREATE_HELP },
+ { .pc_name = "delete", .pc_func = lfs_mirror_delete,
+ .pc_help = "delete a mirror from a file.\n"
+ "usage: lfs mirror delete {--comp-id|-I <comp_id>|-p <pool>} <mirrored_file> ...\n"
+ },
{ .pc_name = "extend", .pc_func = lfs_mirror_extend,
.pc_help = "Extend a mirrored file.\n"
"usage: lfs mirror extend "
"<--mirror-count|-N[mirror_count]> [--no-verify] "
- "[setstripe options|-f <victim_file>] ... <filename>\n"
+ "[setstripe options|-f <victim_file>] ... <filename> ...\n"
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>|-p <pool>> [--destroy|-d]\n"
- "\t [-f <new_file>] <mirrored file>\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"
migrate_mode = (opc == SO_MIGRATE);
mirror_mode = (opc == SO_MIRROR_CREATE || opc == SO_MIRROR_EXTEND);
setstripe_mode = (opc == SO_SETSTRIPE);
+ if (opc == SO_MIRROR_DELETE) {
+ delete = 1;
+ mirror_flags = MF_DESTROY;
+ }
snprintf(cmd, sizeof(cmd), "%s %s", progname, argv[0]);
progname = cmd;
goto usage_error;
}
- if (!comp_del && !comp_set && (opc != SO_MIRROR_SPLIT) &&
- comp_id != 0) {
+ if (!comp_del && !comp_set && opc != SO_MIRROR_SPLIT &&
+ opc != SO_MIRROR_DELETE && comp_id != 0) {
fprintf(stderr,
- "%s %s: option -I can only be used with --component-del or --component-set or lfs mirror split\n",
- progname, argv[0]);
+ "%s: option -I can only be used with --component-del or --component-set or lfs mirror split\n",
+ progname);
goto usage_error;
}
} else if (opc == SO_MIRROR_EXTEND) {
result = mirror_extend(fname, mirror_list,
mirror_flags);
- } else if (opc == SO_MIRROR_SPLIT) {
+ } else if (opc == SO_MIRROR_SPLIT || opc == SO_MIRROR_DELETE) {
if (!mirror_id && !comp_id && !lsa.lsa_pool_name) {
fprintf(stderr,
- "%s %s: no mirror id or component id or pool name"
- " is specified\n", progname, argv[0]);
+ "%s: no mirror specified to delete from '%s'\n",
+ progname, fname);
goto usage_error;
}
if (lsa.lsa_pool_name)