summaryrefslogtreecommitdiffstats
path: root/Manage.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 /Manage.c
parent33414a0182ae193150f65f7bca97a7e4d818a49e (diff)
downloadmdadm-aa534678baad80689a642ba1bd602a00a267ac03.tar.gz
mdadm-aa534678baad80689a642ba1bd602a00a267ac03.tar.xz
mdadm-aa534678baad80689a642ba1bd602a00a267ac03.zip
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 'Manage.c')
-rw-r--r--Manage.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/Manage.c b/Manage.c
index f6fb3ef..cca1503 100644
--- a/Manage.c
+++ b/Manage.c
@@ -869,4 +869,57 @@ int autodetect(void)
}
return rv;
}
+
+int Update_subarray(char *dev, char *subarray, char *update, mddev_ident_t ident, int quiet)
+{
+ struct supertype supertype, *st = &supertype;
+ int fd, rv = 2;
+
+ memset(st, 0, sizeof(*st));
+ if (snprintf(st->subarray, sizeof(st->subarray), "%s", subarray) >=
+ sizeof(st->subarray)) {
+ if (!quiet)
+ fprintf(stderr,
+ Name ": Input overflow for subarray '%s' > %zu bytes\n",
+ subarray, sizeof(st->subarray) - 1);
+ return 2;
+ }
+
+ fd = open_subarray(dev, st, quiet);
+ if (fd < 0)
+ return 2;
+
+ if (!st->ss->update_subarray) {
+ if (!quiet)
+ fprintf(stderr,
+ Name ": Operation not supported for %s metadata\n",
+ st->ss->name);
+ goto free_super;
+ }
+
+ if (mdmon_running(st->devnum))
+ st->update_tail = &st->updates;
+
+ rv = st->ss->update_subarray(st, update, ident);
+
+ if (rv) {
+ if (!quiet)
+ fprintf(stderr, Name ": Failed to update %s of subarray-%s in %s\n",
+ update, subarray, dev);
+ } else if (st->update_tail)
+ flush_metadata_updates(st);
+ else
+ st->ss->sync_metadata(st);
+
+ if (rv == 0 && strcmp(update, "name") == 0 && !quiet)
+ fprintf(stderr,
+ Name ": Updated subarray-%s name from %s, UUIDs may have changed\n",
+ subarray, dev);
+
+ free_super:
+ st->ss->free_super(st);
+ close(fd);
+
+ return rv;
+}
#endif