]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: do not display bitmap info if it is cleared
authorGuoqing Jiang <gqjiang@suse.com>
Tue, 1 Dec 2015 16:30:12 +0000 (00:30 +0800)
committerNeilBrown <neilb@suse.com>
Wed, 16 Dec 2015 02:24:04 +0000 (13:24 +1100)
"mdadm -X DISK" is used to report information about a bitmap
file, it is better to not display all the related infos if
bitmap is cleared with "--bitmap=none" under grow mode.

To do that, the locate_bitmap is changed a little to have a
return value based on MD_FEATURE_BITMAP_OFFSET.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
bitmap.c
mdadm.h
super0.c
super1.c

index 803eda38a9c6ddfc9ce175a2b860cfb299433f27..dab674b4cdd0d347bb58b6a30f175ba82d519c43 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -221,8 +221,12 @@ int bitmap_file_open(char *filename, struct supertype **stp)
                        pr_err("No bitmap possible with %s metadata\n",
                                st->ss->name);
                        return -1;
-               } else
-                       st->ss->locate_bitmap(st, fd);
+               } else {
+                       if (st->ss->locate_bitmap(st, fd)) {
+                               pr_err("%s doesn't have bitmap\n", filename);
+                               fd = -1;
+                       }
+               }
 
                *stp = st;
        } else {
diff --git a/mdadm.h b/mdadm.h
index 477ef1831cee206023328e7d66fbc921521b82be..edb8f9db5c89056b7080176ce1c31d3a3c32517e 100755 (executable)
--- a/mdadm.h
+++ b/mdadm.h
@@ -903,7 +903,7 @@ extern struct superswitch {
        /* Seek 'fd' to start of write-intent-bitmap.  Must be an
         * md-native format bitmap
         */
-       void (*locate_bitmap)(struct supertype *st, int fd);
+       int (*locate_bitmap)(struct supertype *st, int fd);
        /* if add_internal_bitmap succeeded for existing array, this
         * writes it out.
         */
index 6ad9d39f1b5c0e1967f1e1ba0aa6c39564fa5daa..7f8001479edc0f58a32adaf128c132c6dfb69a77 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -1155,16 +1155,16 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
        return 1;
 }
 
-static void locate_bitmap0(struct supertype *st, int fd)
+static int locate_bitmap0(struct supertype *st, int fd)
 {
        unsigned long long dsize;
        unsigned long long offset;
 
        if (!get_dev_size(fd, NULL, &dsize))
-               return;
+               return -1;
 
        if (dsize < MD_RESERVED_SECTORS*512)
-               return;
+               return -1;
 
        offset = MD_NEW_SIZE_SECTORS(dsize>>9);
 
@@ -1173,6 +1173,7 @@ static void locate_bitmap0(struct supertype *st, int fd)
        offset += MD_SB_BYTES;
 
        lseek64(fd, offset, 0);
+       return 0;
 }
 
 static int write_bitmap0(struct supertype *st, int fd, enum bitmap_update update)
index 332d492eb05f3c7aaf4ebfc433aef7f5122e6d23..7b2bd86927ec59ecde6c27a07de6af540f291548 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -1520,7 +1520,7 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
 }
 #endif
 
-static void locate_bitmap1(struct supertype *st, int fd);
+static int locate_bitmap1(struct supertype *st, int fd);
 
 static int store_super1(struct supertype *st, int fd)
 {
@@ -2305,24 +2305,30 @@ add_internal_bitmap1(struct supertype *st,
        return 1;
 }
 
-static void locate_bitmap1(struct supertype *st, int fd)
+static int locate_bitmap1(struct supertype *st, int fd)
 {
        unsigned long long offset;
        struct mdp_superblock_1 *sb;
        int mustfree = 0;
+       int ret;
 
        if (!st->sb) {
                if (st->ss->load_super(st, fd, NULL))
-                       return; /* no error I hope... */
+                       return -1; /* no error I hope... */
                mustfree = 1;
        }
        sb = st->sb;
 
+       if ((__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
+               ret = 0;
+       else
+               ret = -1;
        offset = __le64_to_cpu(sb->super_offset);
        offset += (int32_t) __le32_to_cpu(sb->bitmap_offset);
        if (mustfree)
                free(sb);
        lseek64(fd, offset<<9, 0);
+       return ret;
 }
 
 static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update)