Thread (27 messages) 27 messages, 2 authors, 2012-04-18
STALE5216d

[md PATCH 19/24] md/bitmap: use DIV_ROUND_UP instead of open-code

From: NeilBrown <hidden>
Date: 2012-04-17 08:43:42
Subsystem: the rest · Maintainer: Linus Torvalds

Also take the opportunity to simplify CHUNK_BLOCK_RATIO.

Signed-off-by: NeilBrown <redacted>
---

 drivers/md/bitmap.c |    5 ++---
 drivers/md/bitmap.h |    2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index d2750a3..bcd5107 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -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);
 
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h
index 256a850..530be4d 100644
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -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
 

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help