aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-03-18 21:46:41 -0400
committerNeilBrown <neilb@suse.de>2012-03-18 21:46:41 -0400
commit61a0d80ce4ab5b4fb9ecb38f1fb19654778b71ed (patch)
tree21631162d46575db6645636d1c18b8797247d0c9
parent792a1d4bbf960000f066358f0a8c6e769c8c72bc (diff)
md/bitmap: discard CHUNK_BLOCK_SHIFT macro
Be redefining ->chunkshift as the shift from sectors to chunks rather than bytes to chunks, we can just use "bitmap->chunkshift" which is shorter than the macro call, and less indirect. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/bitmap.c35
-rw-r--r--drivers/md/bitmap.h3
2 files changed, 19 insertions, 19 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 534e0077d21a..cf5863ca258d 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -838,7 +838,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
838 unsigned long bit; 838 unsigned long bit;
839 struct page *page; 839 struct page *page;
840 void *kaddr; 840 void *kaddr;
841 unsigned long chunk = block >> CHUNK_BLOCK_SHIFT(bitmap); 841 unsigned long chunk = block >> bitmap->chunkshift;
842 842
843 if (!bitmap->filemap) 843 if (!bitmap->filemap)
844 return; 844 return;
@@ -1037,10 +1037,10 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1037 kunmap_atomic(paddr, KM_USER0); 1037 kunmap_atomic(paddr, KM_USER0);
1038 if (b) { 1038 if (b) {
1039 /* if the disk bit is set, set the memory bit */ 1039 /* if the disk bit is set, set the memory bit */
1040 int needed = ((sector_t)(i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) 1040 int needed = ((sector_t)(i+1) << bitmap->chunkshift
1041 >= start); 1041 >= start);
1042 bitmap_set_memory_bits(bitmap, 1042 bitmap_set_memory_bits(bitmap,
1043 (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap), 1043 (sector_t)i << bitmap->chunkshift,
1044 needed); 1044 needed);
1045 bit_cnt++; 1045 bit_cnt++;
1046 } 1046 }
@@ -1084,7 +1084,7 @@ void bitmap_write_all(struct bitmap *bitmap)
1084 1084
1085static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc) 1085static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc)
1086{ 1086{
1087 sector_t chunk = offset >> CHUNK_BLOCK_SHIFT(bitmap); 1087 sector_t chunk = offset >> bitmap->chunkshift;
1088 unsigned long page = chunk >> PAGE_COUNTER_SHIFT; 1088 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1089 bitmap->bp[page].count += inc; 1089 bitmap->bp[page].count += inc;
1090 bitmap_checkfree(bitmap, page); 1090 bitmap_checkfree(bitmap, page);
@@ -1190,7 +1190,7 @@ void bitmap_daemon_work(struct mddev *mddev)
1190 bitmap->allclean = 0; 1190 bitmap->allclean = 0;
1191 } 1191 }
1192 bmc = bitmap_get_counter(bitmap, 1192 bmc = bitmap_get_counter(bitmap,
1193 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), 1193 (sector_t)j << bitmap->chunkshift,
1194 &blocks, 0); 1194 &blocks, 0);
1195 if (!bmc) 1195 if (!bmc)
1196 j |= PAGE_COUNTER_MASK; 1196 j |= PAGE_COUNTER_MASK;
@@ -1199,7 +1199,7 @@ void bitmap_daemon_work(struct mddev *mddev)
1199 /* we can clear the bit */ 1199 /* we can clear the bit */
1200 *bmc = 0; 1200 *bmc = 0;
1201 bitmap_count_page(bitmap, 1201 bitmap_count_page(bitmap,
1202 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), 1202 (sector_t)j << bitmap->chunkshift,
1203 -1); 1203 -1);
1204 1204
1205 /* clear the bit */ 1205 /* clear the bit */
@@ -1253,7 +1253,7 @@ __acquires(bitmap->lock)
1253 * The lock must have been taken with interrupts enabled. 1253 * The lock must have been taken with interrupts enabled.
1254 * If !create, we don't release the lock. 1254 * If !create, we don't release the lock.
1255 */ 1255 */
1256 sector_t chunk = offset >> CHUNK_BLOCK_SHIFT(bitmap); 1256 sector_t chunk = offset >> bitmap->chunkshift;
1257 unsigned long page = chunk >> PAGE_COUNTER_SHIFT; 1257 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1258 unsigned long pageoff = (chunk & PAGE_COUNTER_MASK) << COUNTER_BYTE_SHIFT; 1258 unsigned long pageoff = (chunk & PAGE_COUNTER_MASK) << COUNTER_BYTE_SHIFT;
1259 sector_t csize; 1259 sector_t csize;
@@ -1263,10 +1263,10 @@ __acquires(bitmap->lock)
1263 1263
1264 if (bitmap->bp[page].hijacked || 1264 if (bitmap->bp[page].hijacked ||
1265 bitmap->bp[page].map == NULL) 1265 bitmap->bp[page].map == NULL)
1266 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap) + 1266 csize = ((sector_t)1) << (bitmap->chunkshift +
1267 PAGE_COUNTER_SHIFT - 1); 1267 PAGE_COUNTER_SHIFT - 1);
1268 else 1268 else
1269 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap)); 1269 csize = ((sector_t)1) << bitmap->chunkshift;
1270 *blocks = csize - (offset & (csize - 1)); 1270 *blocks = csize - (offset & (csize - 1));
1271 1271
1272 if (err < 0) 1272 if (err < 0)
@@ -1392,7 +1392,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1392 set_page_attr(bitmap, 1392 set_page_attr(bitmap,
1393 filemap_get_page( 1393 filemap_get_page(
1394 bitmap, 1394 bitmap,
1395 offset >> CHUNK_BLOCK_SHIFT(bitmap)), 1395 offset >> bitmap->chunkshift),
1396 BITMAP_PAGE_PENDING); 1396 BITMAP_PAGE_PENDING);
1397 bitmap->allclean = 0; 1397 bitmap->allclean = 0;
1398 } 1398 }
@@ -1480,7 +1480,7 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
1480 else { 1480 else {
1481 if (*bmc <= 2) { 1481 if (*bmc <= 2) {
1482 set_page_attr(bitmap, 1482 set_page_attr(bitmap,
1483 filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)), 1483 filemap_get_page(bitmap, offset >> bitmap->chunkshift),
1484 BITMAP_PAGE_PENDING); 1484 BITMAP_PAGE_PENDING);
1485 bitmap->allclean = 0; 1485 bitmap->allclean = 0;
1486 } 1486 }
@@ -1527,7 +1527,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
1527 1527
1528 bitmap->mddev->curr_resync_completed = sector; 1528 bitmap->mddev->curr_resync_completed = sector;
1529 set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags); 1529 set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags);
1530 sector &= ~((1ULL << CHUNK_BLOCK_SHIFT(bitmap)) - 1); 1530 sector &= ~((1ULL << bitmap->chunkshift) - 1);
1531 s = 0; 1531 s = 0;
1532 while (s < sector && s < bitmap->mddev->resync_max_sectors) { 1532 while (s < sector && s < bitmap->mddev->resync_max_sectors) {
1533 bitmap_end_sync(bitmap, s, &blocks, 0); 1533 bitmap_end_sync(bitmap, s, &blocks, 0);
@@ -1557,7 +1557,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
1557 struct page *page; 1557 struct page *page;
1558 *bmc = 2 | (needed ? NEEDED_MASK : 0); 1558 *bmc = 2 | (needed ? NEEDED_MASK : 0);
1559 bitmap_count_page(bitmap, offset, 1); 1559 bitmap_count_page(bitmap, offset, 1);
1560 page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)); 1560 page = filemap_get_page(bitmap, offset >> bitmap->chunkshift);
1561 set_page_attr(bitmap, page, BITMAP_PAGE_PENDING); 1561 set_page_attr(bitmap, page, BITMAP_PAGE_PENDING);
1562 bitmap->allclean = 0; 1562 bitmap->allclean = 0;
1563 } 1563 }
@@ -1570,7 +1570,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1570 unsigned long chunk; 1570 unsigned long chunk;
1571 1571
1572 for (chunk = s; chunk <= e; chunk++) { 1572 for (chunk = s; chunk <= e; chunk++) {
1573 sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap); 1573 sector_t sec = (sector_t)chunk << bitmap->chunkshift;
1574 bitmap_set_memory_bits(bitmap, sec, 1); 1574 bitmap_set_memory_bits(bitmap, sec, 1);
1575 spin_lock_irq(&bitmap->lock); 1575 spin_lock_irq(&bitmap->lock);
1576 bitmap_file_set_bit(bitmap, sec); 1576 bitmap_file_set_bit(bitmap, sec);
@@ -1727,11 +1727,12 @@ int bitmap_create(struct mddev *mddev)
1727 goto error; 1727 goto error;
1728 1728
1729 bitmap->daemon_lastrun = jiffies; 1729 bitmap->daemon_lastrun = jiffies;
1730 bitmap->chunkshift = ffz(~mddev->bitmap_info.chunksize); 1730 bitmap->chunkshift = (ffz(~mddev->bitmap_info.chunksize)
1731 - BITMAP_BLOCK_SHIFT);
1731 1732
1732 /* now that chunksize and chunkshift are set, we can use these macros */ 1733 /* now that chunksize and chunkshift are set, we can use these macros */
1733 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >> 1734 chunks = (blocks + bitmap->chunkshift - 1) >>
1734 CHUNK_BLOCK_SHIFT(bitmap); 1735 bitmap->chunkshift;
1735 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO; 1736 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO;
1736 1737
1737 BUG_ON(!pages); 1738 BUG_ON(!pages);
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h
index e196e6a560e8..55ca5aec84e4 100644
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -103,7 +103,6 @@ typedef __u16 bitmap_counter_t;
103 103
104/* how many blocks per chunk? (this is variable) */ 104/* how many blocks per chunk? (this is variable) */
105#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT) 105#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT)
106#define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT)
107 106
108#endif 107#endif
109 108
@@ -178,7 +177,7 @@ struct bitmap {
178 struct mddev *mddev; /* the md device that the bitmap is for */ 177 struct mddev *mddev; /* the md device that the bitmap is for */
179 178
180 /* bitmap chunksize -- how much data does each bit represent? */ 179 /* bitmap chunksize -- how much data does each bit represent? */
181 unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ 180 unsigned long chunkshift; /* chunksize = 2^(chunkshift+9) (for bitops) */
182 unsigned long chunks; /* total number of data chunks for the array */ 181 unsigned long chunks; /* total number of data chunks for the array */
183 182
184 __u64 events_cleared; 183 __u64 events_cleared;