.ad l
.B lfs mirror extend
[\fB\-\-no\-verify\fR]
-\fB\-\-mirror\-count\fR|\fB\-N\fR[\fIMIRROR_COUNT\fR]
+[\fB\-\-mirror\-count\fR|\fB\-N\fR[\fIMIRROR_COUNT\fR]]
[\fB\-\-bandwidth\-limit\fR|\fB\-W\fR \fIBANDWIDTH\fR]
[\fB\-\-stats\fR|\fB\-\-stats\-interval\fR=\fISTATS_INTERVAL\fR]
[\fISETSTRIPE_OPTIONS\fR|\fB\-f\fR \fIVICTIM_FILE\fR]
non-mirrored file. If it's a non-mirrored file, then the command will convert it
to a mirrored file.
.br
-The \fB\-\-mirror\-count\fR|\fB\-N\fR option is required and indicates how many
+The \fB\-\-mirror\-count\fR|\fB\-N\fR option is optional and indicates how many
mirrors that have the same layout will be added. It can be repeated multiple
times to separate mirrors that have different layouts. The \fIMIRROR_COUNT\fR
argument is optional and defaults to 1 if it's not specified; if specified, it
-must follow the option without a space.
+must follow the option without a space. If \fB\-\-mirror\-count\fR|\fB\-N\fR is
+not specified, the default value of 1 will be used.
.br
The \fISETSTRIPE_OPTIONS\fR specify the specific layout for the mirror. It can
be a plain layout with specific striping pattern or a composite layout like
# create parent directory
mkdir $td || error "mkdir $td failed"
- $mirror_cmd $tf &> /dev/null && error "miss -N option"
$mirror_cmd -N $tf &> /dev/null && error "$tf does not exist"
# create a non-mirrored file, convert it to a mirrored file and extend
touch $tf || error "touch $tf failed"
$mirror_cmd -N $tf || error "convert and extend $tf failed"
verify_mirror_count $tf 2
+ $mirror_cmd $tf || error "extend $tf without --mirror-count|-N failed"
+ verify_mirror_count $tf 3
ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
- for ((i = 0; i < 2; i++)); do
+ for ((i = 0; i < 3; i++)); do
verify_comp_attrs $tf ${ids[$i]}
verify_comp_extent $tf ${ids[$i]} 0 EOF
done
static inline int lfs_mirror_extend(int argc, char **argv)
{
+ int i;
+
+ for (i = 0; i < argc; i++)
+ if (strstr(argv[i], "-N") ||
+ strstr(argv[i], "--mirror-count"))
+ break;
+
+ /* add -N if not specified */
+ if (i == argc) {
+ char *tmp[argc + 1];
+
+ tmp[0] = argv[0]; /* extend */
+ tmp[1] = "-N";
+ memcpy(tmp + 2, argv + 1, (argc - 1) * sizeof(*argv));
+
+ return lfs_setstripe_internal(argc + 1, tmp, SO_MIRROR_EXTEND);
+ }
+
return lfs_setstripe_internal(argc, argv, SO_MIRROR_EXTEND);
}