All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] disallow create or grow clustered bitmap with writemostly set
@ 2021-08-23 12:48 Nigel Croxon
  2021-10-08 15:48 ` Jes Sorensen
  0 siblings, 1 reply; 2+ messages in thread
From: Nigel Croxon @ 2021-08-23 12:48 UTC (permalink / raw)
  To: jes, xni, linux-raid, pg

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>
---
 Create.c | 9 +++++++--
 Grow.c   | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Create.c b/Create.c
index f5d57f8c..7e89a0e2 100644
--- 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 7506ab46..70f26c7e 100644
--- 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;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] disallow create or grow clustered bitmap with writemostly set
  2021-08-23 12:48 [PATCH V2] disallow create or grow clustered bitmap with writemostly set Nigel Croxon
@ 2021-10-08 15:48 ` Jes Sorensen
  0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2021-10-08 15:48 UTC (permalink / raw)
  To: Nigel Croxon, xni, linux-raid, pg

On 8/23/21 8:48 AM, Nigel Croxon wrote:
> 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>
> ---
>  Create.c | 9 +++++++--
>  Grow.c   | 5 +++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 

Applied!

Thanks
Jes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-08 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 12:48 [PATCH V2] disallow create or grow clustered bitmap with writemostly set Nigel Croxon
2021-10-08 15:48 ` Jes Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.