]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - bitmap.c
mdmon: fix wrong array state when disk fails during mdmon startup
[thirdparty/mdadm.git] / bitmap.c
index 6c1b8d86640e7bcf8ad6c15f0bf85309c1e4135f..e38cb9650390235d481aeba3b3fa38b724e37910 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -108,21 +108,6 @@ static int count_dirty_bits(char *buf, int num_bits)
        return num;
 }
 
-/* calculate the size of the bitmap given the array size and bitmap chunksize */
-static unsigned long long
-bitmap_bits(unsigned long long array_size, unsigned long chunksize)
-{
-       return (array_size * 512 + chunksize - 1) / chunksize;
-}
-
-unsigned long bitmap_sectors(struct bitmap_super_s *bsb)
-{
-       unsigned long long bits = bitmap_bits(__le64_to_cpu(bsb->sync_size),
-                                             __le32_to_cpu(bsb->chunksize));
-       int bits_per_sector = 8*512;
-       return (bits + bits_per_sector - 1) / bits_per_sector;
-}
-
 static bitmap_info_t *bitmap_fd_read(int fd, int brief)
 {
        /* Note: fd might be open O_DIRECT, so we must be
@@ -209,12 +194,10 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
        }
 
        if (fstat(fd, &stb) < 0) {
-               pr_err("failed to determine bitmap file/device type: %s\n",
-                       strerror(errno));
+               pr_err("fstat failed for %s: %s\n", filename, strerror(errno));
                close(fd);
                return -1;
        }
-
        if ((stb.st_mode & S_IFMT) == S_IFBLK) {
                /* block device, so we are probably after an internal bitmap */
                if (!st)
@@ -234,7 +217,6 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
                                fd = -1;
                        }
                }
-
                *stp = st;
        }
 
@@ -275,7 +257,7 @@ int ExamineBitmap(char *filename, int brief, struct supertype *st)
        if (!info)
                return rv;
        sb = &info->sb;
-       if (sb->magic != BITMAP_MAGIC && md_get_version(fd) > 0) {
+       if (sb->magic != BITMAP_MAGIC) {
                pr_err("This is an md array.  To view a bitmap you need to examine\n");
                pr_err("a member device, not the array.\n");
                pr_err("Reporting bitmap that would be used if this array were used\n");