From: NeilBrown Date: Wed, 24 Mar 2010 00:57:42 +0000 (+1100) Subject: Don't attempt to create or read bitmaps where the metadata doesn't support it. X-Git-Tag: mdadm-3.1.3~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebeb36638225e86826052400c1c538857bc7c461;p=thirdparty%2Fmdadm.git 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 --- diff --git a/Create.c b/Create.c index 909ac5da..8f6e6e70 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 6264996c..053a372a 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 088e37d0..beef2dcd 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 {