]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
md/bitmap: use DIV_ROUND_UP instead of open-code
authorNeilBrown <neilb@suse.de>
Tue, 24 Apr 2012 00:57:57 +0000 (10:57 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 24 Apr 2012 00:57:57 +0000 (10:57 +1000)
Also take the opportunity to simplify CHUNK_BLOCK_RATIO.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/bitmap.c
drivers/md/bitmap.h

index b9a1b39798ac1ec0fb3fe6f18b27ca6e0cf94859..4b897a58b748b41d140a4a25d3229926861a3036 100644 (file)
@@ -1695,9 +1695,8 @@ int bitmap_create(struct mddev *mddev)
                              - BITMAP_BLOCK_SHIFT);
 
        /* now that chunksize and chunkshift are set, we can use these macros */
-       chunks = (blocks + bitmap->counts.chunkshift - 1) >>
-                       bitmap->counts.chunkshift;
-       pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO;
+       chunks = DIV_ROUND_UP(blocks, CHUNK_BLOCK_RATIO(bitmap));
+       pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
 
        BUG_ON(!pages);
 
index 256a850398d5a2ddb36619a98a7512c6b7d719fc..530be4ddaecde0ec99d9bfb2d6e422b52c3872be 100644 (file)
@@ -102,7 +102,7 @@ typedef __u16 bitmap_counter_t;
 #define BITMAP_BLOCK_SHIFT 9
 
 /* how many blocks per chunk? (this is variable) */
-#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT)
+#define        CHUNK_BLOCK_RATIO(bitmap) (1 << (bitmap)->counts.chunkshift)
 
 #endif