]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
disallow create or grow clustered bitmap with writemostly set
authorNigel Croxon <ncroxon@redhat.com>
Mon, 23 Aug 2021 12:48:35 +0000 (08:48 -0400)
committerJes Sorensen <jsorensen@fb.com>
Fri, 8 Oct 2021 15:47:55 +0000 (11:47 -0400)
Do not support creating an MD array on a clustered system
(--bitmap=clustered) and disks with the write mostly
(--write-mostly) flag set.

Or do not grow an MD array on a non-clustered bitmap to a
clustered bitmap with disks having the write mostly flag set.

The actual results is the MD array is created successfully.
But the expected results should be a failure with an
error message stating:
Can not set --write-mostly with a clustered bitmap.
and disks marked write-mostly are not supported with clustered bitmap.

V2:
Added the device name in the error message during creation:
mdadm -CR /dev/md0 -l1 --raid-devices=2 /dev/sda --write-mostly /dev/sdb --bitmap=clustered
mdadm: Can not set /dev/sdb --write-mostly with a clustered bitmap.

Added the array name in the error message when growing:
mdadm --grow /dev/md0 --bitmap=clustered
mdadm: /dev/md0 disks marked write-mostly are not supported with clustered bitmap

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Create.c
Grow.c

index 2c0b17e9e7824385b38b57f003f51439ad3b29bd..0ff1922ddc6ebdfa602fed274164e8ea9f103922 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -899,8 +899,13 @@ int Create(struct supertype *st, char *mddev,
                                else
                                        inf->disk.state = 0;
 
-                               if (dv->writemostly == FlagSet)
-                                       inf->disk.state |= (1<<MD_DISK_WRITEMOSTLY);
+                               if (dv->writemostly == FlagSet) {
+                                       if (major_num == BITMAP_MAJOR_CLUSTERED) {
+                                               pr_err("Can not set %s --write-mostly with a clustered bitmap\n",dv->devname);
+                                               goto abort_locked;
+                                       } else
+                                               inf->disk.state |= (1<<MD_DISK_WRITEMOSTLY);
+                               }
                                if (dv->failfast == FlagSet)
                                        inf->disk.state |= (1<<MD_DISK_FAILFAST);
 
diff --git a/Grow.c b/Grow.c
index 7506ab460b5aefa484fc858bace48c4aed1050f3..70f26c7e41145df252b990d0348d256b6ff7205a 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -430,6 +430,11 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)
                        dv = map_dev(disk.major, disk.minor, 1);
                        if (!dv)
                                continue;
+                       if (((disk.state & (1 << MD_DISK_WRITEMOSTLY)) == 0) &&
+                          (strcmp(s->bitmap_file, "clustered") == 0)) {
+                               pr_err("%s disks marked write-mostly are not supported with clustered bitmap\n",devname);
+                               return 1;
+                       }
                        fd2 = dev_open(dv, O_RDWR);
                        if (fd2 < 0)
                                continue;