]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Reuse calc_bitmap_size to reduce code size cluster
authorGuoqing Jiang <gqjiang@suse.com>
Wed, 10 Jun 2015 05:42:13 +0000 (13:42 +0800)
committerNeilBrown <neilb@suse.de>
Tue, 16 Jun 2015 23:44:38 +0000 (09:44 +1000)
We can use the new added calc_bitmap_size func to remove some
redundant lines.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.de>
super1.c

index ba74a33126631f0058b916dc68a1cb83e41f96cd..fda71e39339a8a90abd8d6f2ee2c5aa08b2e8fed 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -698,12 +698,8 @@ static int copy_metadata1(struct supertype *st, int from, int to)
                                /* have the header, can calculate
                                 * correct bitmap bytes */
                                bitmap_super_t *bms;
-                               int bits;
                                bms = (void*)buf;
-                               bits = __le64_to_cpu(bms->sync_size) / (__le32_to_cpu(bms->chunksize)>>9);
-                               bytes = (bits+7) >> 3;
-                               bytes += sizeof(bitmap_super_t);
-                               bytes = ROUND_UP(bytes, 512);
+                               bytes = calc_bitmap_size(bms, 512);
                                if (n > bytes)
                                        n =  bytes;
                        }
@@ -2258,11 +2254,7 @@ static int write_bitmap1(struct supertype *st, int fd, enum bitmap_update update
                        memset(buf, 0xff, 4096);
                memcpy(buf, (char *)bms, sizeof(bitmap_super_t));
 
-               towrite = __le64_to_cpu(bms->sync_size) / (__le32_to_cpu(bms->chunksize)>>9);
-               towrite = (towrite+7) >> 3; /* bits to bytes */
-               towrite += sizeof(bitmap_super_t);
-               /* we need the bitmaps to be at 4k boundary */
-               towrite = ROUND_UP(towrite, 4096);
+               towrite = calc_bitmap_size(bms, 4096);
                while (towrite > 0) {
                        n = towrite;
                        if (n > 4096)