]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Don't attempt to create or read bitmaps where the metadata doesn't support it.
authorNeilBrown <neilb@suse.de>
Wed, 24 Mar 2010 00:57:42 +0000 (11:57 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 6 Apr 2010 23:18:01 +0000 (09:18 +1000)
In particular, if the relevant bitmap method is NULL, don't try to
call it, print an error instead.

Signed-off-by: NeilBrown <neilb@suse.de>
Create.c
Grow.c
bitmap.c

index 909ac5da5fcba1fad615e402a4d9da503edee9bd..8f6e6e7027ae2c9bae263290aa84df667994213d 100644 (file)
--- 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 6264996c2eb76b9978280047a325afced4451238..053a372ac3b526f7a5b5cccce6955f02735914ea 100644 (file)
--- 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;
index 088e37d0ad79f90bcf02c31684b2a2c9aeb6f8b4..beef2dcdbb3d558ad5c81da1d16ce6b6774006ca 100644 (file)
--- 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 {