summaryrefslogtreecommitdiff
path: root/mdadm.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-12-09 13:06:29 +1100
committerNeilBrown <neilb@suse.de>2010-12-09 13:06:29 +1100
commit833bb0f8f61c576895a2ec90c344c148c08dadba (patch)
treea94afa659cd2d01366009d3b0df2c77d473f92f9 /mdadm.c
parent691a36b76f871a63a327641589f41e968b05afa9 (diff)
Allow --update=devicesize with --re-add
This is useful with 1.1 and 1.2 metadata to update the metadata if the device size has changed. The same functionality can be achieved by writing to the device size in sysfs after re-adding normally, but in some cases this might be easier. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/mdadm.c b/mdadm.c
index dd5311d5..2ffe94f7 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -666,12 +666,14 @@ int main(int argc, char *argv[])
case O(ASSEMBLE,'U'): /* update the superblock */
case O(MISC,'U'):
if (update) {
- fprintf(stderr, Name ": Can only update one aspect of superblock, both %s and %s given.\n",
+ fprintf(stderr, Name ": Can only update one aspect"
+ " of superblock, both %s and %s given.\n",
update, optarg);
exit(2);
}
if (mode == MISC && !subarray) {
- fprintf(stderr, Name ": Only subarrays can be updated in misc mode\n");
+ fprintf(stderr, Name ": Only subarrays can be"
+ " updated in misc mode\n");
exit(2);
}
update = optarg;
@@ -695,13 +697,17 @@ int main(int argc, char *argv[])
continue;
if (strcmp(update, "byteorder")==0) {
if (ss) {
- fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
+ fprintf(stderr,
+ Name ": must not set metadata"
+ " type with --update=byteorder.\n");
exit(2);
}
for(i=0; !ss && superlist[i]; i++)
- ss = superlist[i]->match_metadata_desc("0.swap");
+ ss = superlist[i]->match_metadata_desc(
+ "0.swap");
if (!ss) {
- fprintf(stderr, Name ": INTERNAL ERROR cannot find 0.swap\n");
+ fprintf(stderr, Name ": INTERNAL ERROR"
+ " cannot find 0.swap\n");
exit(2);
}
@@ -723,6 +729,27 @@ int main(int argc, char *argv[])
" 'no-bitmap'\n");
exit(outf == stdout ? 0 : 2);
+ case O(MANAGE,'U'):
+ /* update=devicesize is allowed with --re-add */
+ if (devmode != 'a' || re_add != 1) {
+ fprintf(stderr, Name "--update in Manage mode only"
+ " allowed with --re-add.\n");
+ exit(1);
+ }
+ if (update) {
+ fprintf(stderr, Name ": Can only update one aspect"
+ " of superblock, both %s and %s given.\n",
+ update, optarg);
+ exit(2);
+ }
+ update = optarg;
+ if (strcmp(update, "devicesize") != 0) {
+ fprintf(stderr, Name ": only 'devicesize' can be"
+ " updated with --re-add\n");
+ exit(2);
+ }
+ continue;
+
case O(INCREMENTAL,NoDegraded):
fprintf(stderr, Name ": --no-degraded is deprecated in Incremental mode\n");
case O(ASSEMBLE,NoDegraded): /* --no-degraded */
@@ -1153,7 +1180,8 @@ int main(int argc, char *argv[])
rv = Manage_ro(devlist->devname, mdfd, readonly);
if (!rv && devs_found>1)
rv = Manage_subdevs(devlist->devname, mdfd,
- devlist->next, verbose-quiet, test);
+ devlist->next, verbose-quiet, test,
+ update);
if (!rv && readonly < 0)
rv = Manage_ro(devlist->devname, mdfd, readonly);
if (!rv && runstop)