NeilBrown: Don't attempt to create or read bitmaps where the metadata doesn 't support it.

Martin F. Krafft madduck at alioth.debian.org
Sat Aug 28 18:46:06 UTC 2010


Module: mdadm
Branch: master
Commit: ebeb36638225e86826052400c1c538857bc7c461
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=ebeb36638225e86826052400c1c538857bc7c461

Author: NeilBrown <neilb at suse.de>
Date:   Wed Mar 24 11:57:42 2010 +1100

Don't attempt to create or read bitmaps where the metadata doesn't support it.

In particular, if the relevant bitmap method is NULL, don't try to
call it, print an error instead.

Signed-off-by: NeilBrown <neilb at suse.de>

---

 Create.c |    5 +++++
 Grow.c   |    5 +++++
 bitmap.c |    8 ++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Create.c b/Create.c
index 909ac5d..8f6e6e7 100644
--- a/Create.c
+++ b/Create.c
@@ -651,6 +651,11 @@ int Create(struct supertype *st, char *mddev,
 			fprintf(stderr, Name ": internal bitmaps not supported by this kernel.\n");
 			goto abort;
 		}
+		if (!st->ss->add_internal_bitmap) {
+			fprintf(stderr, Name ": internal bitmaps not supported with %s metadata\n",
+				st->ss->name);
+			goto abort;
+		}
 		if (!st->ss->add_internal_bitmap(st, &bitmap_chunk,
 						 delay, write_behind,
 						 bitmapsize, 1, major_num)) {
diff --git a/Grow.c b/Grow.c
index 6264996..053a372 100644
--- a/Grow.c
+++ b/Grow.c
@@ -288,6 +288,11 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int
 		return 1;
 	} else if (strcmp(file, "internal") == 0) {
 		int d;
+		if (st->ss->add_internal_bitmap == NULL) {
+			fprintf(stderr, Name ": Internal bitmaps not supported "
+				"with %s metadata\n", st->ss->name);
+			return 1;
+		}
 		for (d=0; d< st->max_devs; d++) {
 			mdu_disk_info_t disk;
 			char *dv;
diff --git a/bitmap.c b/bitmap.c
index 088e37d..beef2dc 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -227,9 +227,13 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
 		if (!st) {
 			/* just look at device... */
 			lseek(fd, 0, 0);
-		} else {
+		} else if (!st->ss->locate_bitmap) {
+			fprintf(stderr, Name ": No bitmap possible with %s metadata\n",
+				st->ss->name);
+			return NULL;
+		} else
 			st->ss->locate_bitmap(st, fd);
-		}
+
 		ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
 		*stp = st;
 	} else {




More information about the pkg-mdadm-commits mailing list