]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix problem with sector/KB size confuision for bitmap sizing.
authorNeil Brown <neilb@suse.de>
Mon, 15 May 2006 03:57:53 +0000 (03:57 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 15 May 2006 03:57:53 +0000 (03:57 +0000)
Signed-off-by: Neil Brown <neilb@suse.de>
Grow.c
super0.c
sysfs.c

diff --git a/Grow.c b/Grow.c
index 125606c6e3372f60b7fd65fa440cafe3d87a12cd..bc8a73f6502aa4c83f1d3879d230d3540bd294ec 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -272,7 +272,7 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int
        }
 
        if (array.level == 10) {
-               int ncopies = (array.layout&255)*(array.layout>>8);
+               int ncopies = (array.layout&255)*((array.layout>>8)&255);
                bitmapsize = bitmapsize * array.raid_disks / ncopies;
        }
 
index 8bded15c426abde1df701ca6ea4caded7e7b2610..9c313ca9847d5a397d2317dba658f48f576aba7a 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -739,7 +739,7 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int
         * The bitmap comes immediately after the superblock and must be 60K in size
         * at most.  The default size is between 30K and 60K
         *
-        * size is in K,  chunk is in bytes !!!
+        * size is in sectors,  chunk is in bytes !!!
         */
        unsigned long long bits;
        unsigned long long max_bits = 60*1024*8;
@@ -749,7 +749,7 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int
 
 
        min_chunk = 4096; /* sub-page chunks don't work yet.. */
-       bits = (size * 512)/ min_chunk +1;
+       bits = (size * 512) / min_chunk + 1;
        while (bits > max_bits) {
                min_chunk *= 2;
                bits = (bits+1)/2;
@@ -770,8 +770,6 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int
        bms->sync_size = __cpu_to_le64(size);
        bms->write_behind = __cpu_to_le32(write_behind);
 
-
-
        return 1;
 }
 
diff --git a/sysfs.c b/sysfs.c
index 8c1d45f082b3ccebf0b612f21a4d91966a97a935..35b8883614e2e7797f622aec07264588a6609b48 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -195,7 +195,7 @@ unsigned long long get_component_size(int fd)
         * size field is only 32bits.
         * So look in /sys/block/mdXXX/md/component_size
         *
-        * WARNING: this returns in units of Kilobytes.
+        * This returns in units of sectors.
         */
        struct stat stb;
        char fname[50];
@@ -215,7 +215,7 @@ unsigned long long get_component_size(int fd)
        if (n == sizeof(fname))
                return 0;
        fname[n] = 0;
-       return strtoull(fname, NULL, 10);
+       return strtoull(fname, NULL, 10) * 2;
 }
 
 int sysfs_set_str(struct sysarray *sra, struct sysdev *dev,