[PATCH] disallow create or grow clustered bitmap with writemostly set

Subsystems: the rest

STALE1817d

2 messages, 2 authors, 2021-08-19 · open the first message on its own page

[PATCH] disallow create or grow clustered bitmap with writemostly set

From: Nigel Croxon <hidden>
Date: 2021-08-19 15:10:16

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.

Signed-off-by: Nigel Croxon <redacted>
---
 Create.c | 9 +++++++--
 Grow.c   | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/Create.c b/Create.c
index f5d57f8c..789a6464 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 --write-mostly with a clustered bitmap\n");
+						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..f9cc091e 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("disks marked write-mostly are not supported with clustered bitmap\n");
+				return 1;
+			}
 			fd2 = dev_open(dv, O_RDWR);
 			if (fd2 < 0)
 				continue;
-- 
2.29.2

Re: [PATCH] disallow create or grow clustered bitmap with writemostly set

From: Peter Grandi <hidden>
Date: 2021-08-19 15:37:03

[...]
+				if (dv->writemostly == FlagSet) {
+					if (major_num == BITMAP_MAJOR_CLUSTERED) {
+						pr_err("Can not set --write-mostly with a clustered bitmap\n");
+						goto abort_locked;
[...]
+			if (((disk.state & (1 << MD_DISK_WRITEMOSTLY)) == 0) &&
+			   (strcmp(s->bitmap_file, "clustered") == 0)) {
+				pr_err("disks marked write-mostly are not supported with clustered bitmap\n");
+				return 1;
It would be more useful for those error messages to give some
information identifying the MD set and disk, as written they are
only slightly better variants of the classic "Cannot open file."
message.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help