summaryrefslogtreecommitdiff
path: root/mdadm.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2010-06-22 16:30:59 -0700
committerDan Williams <dan.j.williams@intel.com>2010-06-22 16:30:59 -0700
commitaa534678baad80689a642ba1bd602a00a267ac03 (patch)
treefc9283b2873a1f38060e76d375fce1cfa93f840d /mdadm.c
parent33414a0182ae193150f65f7bca97a7e4d818a49e (diff)
Rename subarray v2
Allow the name of the array stored in the metadata to be updated. In some cases the metadata format may not be able to support this rename without modifying the UUID. In these cases the request will be blocked. Otherwise we allow the rename to take place, even for active arrays. This assumes that the user understands the difference between the kernel node name, the device node symlink name, and the metadata specific name. Anticipating further need to modify subarrays in-place, introduce the ->update_subarray() superswitch method. A future potential use case is setting storage pool (spare-group) identifiers. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/mdadm.c b/mdadm.c
index 446fab82..e7435fd9 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -218,8 +218,14 @@ int main(int argc, char *argv[])
case Waitclean:
case DetailPlatform:
case KillSubarray:
- if (opt == KillSubarray)
+ case UpdateSubarray:
+ if (opt == KillSubarray || opt == UpdateSubarray) {
+ if (subarray) {
+ fprintf(stderr, Name ": subarray can only be specified once\n");
+ exit(2);
+ }
subarray = optarg;
+ }
case 'K': if (!mode) newmode = MISC; break;
}
if (mode && newmode == mode) {
@@ -593,11 +599,16 @@ int main(int argc, char *argv[])
case O(CREATE,'N'):
case O(ASSEMBLE,'N'):
+ case O(MISC,'N'):
if (ident.name[0]) {
fprintf(stderr, Name ": name cannot be set twice. "
"Second value %s.\n", optarg);
exit(2);
}
+ if (mode == MISC && !subarray) {
+ fprintf(stderr, Name ": -N/--name only valid with --update-subarray in misc mode\n");
+ exit(2);
+ }
if (strlen(optarg) > 32) {
fprintf(stderr, Name ": name '%s' is too long, 32 chars max.\n",
optarg);
@@ -624,11 +635,16 @@ int main(int argc, char *argv[])
continue;
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",
update, optarg);
exit(2);
}
+ if (mode == MISC && !subarray) {
+ fprintf(stderr, Name ": Only subarrays can be updated in misc mode\n");
+ exit(2);
+ }
update = optarg;
if (strcmp(update, "sparc2.2")==0)
continue;
@@ -812,10 +828,20 @@ int main(int argc, char *argv[])
case O(MISC, Waitclean):
case O(MISC, DetailPlatform):
case O(MISC, KillSubarray):
+ case O(MISC, UpdateSubarray):
if (devmode && devmode != opt &&
(devmode == 'E' || (opt == 'E' && devmode != 'Q'))) {
- fprintf(stderr, Name ": --examine/-E cannot be given with -%c\n",
- devmode =='E'?opt:devmode);
+ fprintf(stderr, Name ": --examine/-E cannot be given with ");
+ if (devmode == 'E') {
+ if (option_index >= 0)
+ fprintf(stderr, "--%s\n",
+ long_options[option_index].name);
+ else
+ fprintf(stderr, "-%c\n", opt);
+ } else if (isalpha(devmode))
+ fprintf(stderr, "-%c\n", devmode);
+ else
+ fprintf(stderr, "previous option\n");
exit(2);
}
devmode = opt;
@@ -1411,6 +1437,15 @@ int main(int argc, char *argv[])
case KillSubarray:
rv |= Kill_subarray(dv->devname, subarray, quiet);
continue;
+ case UpdateSubarray:
+ if (update == NULL) {
+ fprintf(stderr,
+ Name ": -U/--update must be specified with --update-subarray\n");
+ rv |= 1;
+ continue;
+ }
+ rv |= Update_subarray(dv->devname, subarray, update, &ident, quiet);
+ continue;
}
mdfd = open_mddev(dv->devname, 1);
if (mdfd>=0) {