summaryrefslogtreecommitdiffstats
path: root/mdadm.c
diff options
context:
space:
mode:
authorGuoqing Jiang <gqjiang@suse.com>2015-06-10 07:42:06 +0200
committerNeilBrown <neilb@suse.de>2015-06-17 01:06:30 +0200
commit7716570e6d906e7326f83d466f6ba73009649d03 (patch)
tree7107f4dec7c84e6a7f49c64e679ea0dd885a310b /mdadm.c
parentAdd nodes option while creating md (diff)
downloadmdadm-7716570e6d906e7326f83d466f6ba73009649d03.tar.xz
mdadm-7716570e6d906e7326f83d466f6ba73009649d03.zip
Set home-cluster while creating an array
The home-cluster is stored in the bitmap super block of the array. The device can be assembled on a cluster with the cluster name same as the one recorded in the bitmap. If home-cluster is not specified, this is auto-detected using dlopen corosync cmap library. neilb: allow code to compile when corosync-devel is not installed. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/mdadm.c b/mdadm.c
index 2ab006ab..1a32328e 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -596,6 +596,13 @@ int main(int argc, char *argv[])
exit(2);
}
continue;
+ case O(CREATE, ClusterName):
+ c.homecluster = optarg;
+ if (strlen(c.homecluster) > 64) {
+ pr_err("Cluster name too big.\n");
+ exit(ERANGE);
+ }
+ continue;
case O(CREATE,'x'): /* number of spare (eXtra) disks */
if (s.sparedisks) {
pr_err("spare-devices set twice: %d and %s\n",
@@ -1276,6 +1283,16 @@ int main(int argc, char *argv[])
c.require_homehost = 0;
}
+ if (c.homecluster == NULL && (c.nodes > 0)) {
+ c.homecluster = conf_get_homecluster();
+ if (c.homecluster == NULL)
+ rv = get_cluster_name(&c.homecluster);
+ if (rv != 0) {
+ pr_err("The md can't get cluster name\n");
+ exit(1);
+ }
+ }
+
if (c.backup_file && data_offset != INVALID_SECTORS) {
pr_err("--backup-file and --data-offset are incompatible\n");
exit(2);