aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-10-18 19:03:39 -0400
committerNeilBrown <neilb@suse.de>2010-10-28 02:32:26 -0400
commit57dab0bdf689d42972975ec646d862b0900a4bf3 (patch)
treed136f69b8a68850e40844397ebaffde31787c988 /drivers/md/bitmap.c
parent4b532c9b8c87eb8e51605c4d08dfb5139c758dc5 (diff)
md: use sector_t in bitmap_get_counter
bitmap_get_counter returns the number of sectors covered by the counter in a pass-by-reference variable. In some cases this can be very large, so make it a sector_t for safety. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index e4fb58db5454..65d567373213 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1101,7 +1101,7 @@ static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc)
1101 bitmap_checkfree(bitmap, page); 1101 bitmap_checkfree(bitmap, page);
1102} 1102}
1103static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, 1103static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
1104 sector_t offset, int *blocks, 1104 sector_t offset, sector_t *blocks,
1105 int create); 1105 int create);
1106 1106
1107/* 1107/*
@@ -1115,7 +1115,7 @@ void bitmap_daemon_work(mddev_t *mddev)
1115 unsigned long j; 1115 unsigned long j;
1116 unsigned long flags; 1116 unsigned long flags;
1117 struct page *page = NULL, *lastpage = NULL; 1117 struct page *page = NULL, *lastpage = NULL;
1118 int blocks; 1118 sector_t blocks;
1119 void *paddr; 1119 void *paddr;
1120 struct dm_dirty_log *log = mddev->bitmap_info.log; 1120 struct dm_dirty_log *log = mddev->bitmap_info.log;
1121 1121
@@ -1258,7 +1258,7 @@ void bitmap_daemon_work(mddev_t *mddev)
1258} 1258}
1259 1259
1260static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, 1260static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
1261 sector_t offset, int *blocks, 1261 sector_t offset, sector_t *blocks,
1262 int create) 1262 int create)
1263__releases(bitmap->lock) 1263__releases(bitmap->lock)
1264__acquires(bitmap->lock) 1264__acquires(bitmap->lock)
@@ -1316,7 +1316,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
1316 } 1316 }
1317 1317
1318 while (sectors) { 1318 while (sectors) {
1319 int blocks; 1319 sector_t blocks;
1320 bitmap_counter_t *bmc; 1320 bitmap_counter_t *bmc;
1321 1321
1322 spin_lock_irq(&bitmap->lock); 1322 spin_lock_irq(&bitmap->lock);
@@ -1381,7 +1381,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1381 success = 0; 1381 success = 0;
1382 1382
1383 while (sectors) { 1383 while (sectors) {
1384 int blocks; 1384 sector_t blocks;
1385 unsigned long flags; 1385 unsigned long flags;
1386 bitmap_counter_t *bmc; 1386 bitmap_counter_t *bmc;
1387 1387
@@ -1423,7 +1423,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1423} 1423}
1424EXPORT_SYMBOL(bitmap_endwrite); 1424EXPORT_SYMBOL(bitmap_endwrite);
1425 1425
1426static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, 1426static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
1427 int degraded) 1427 int degraded)
1428{ 1428{
1429 bitmap_counter_t *bmc; 1429 bitmap_counter_t *bmc;
@@ -1452,7 +1452,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *bloc
1452 return rv; 1452 return rv;
1453} 1453}
1454 1454
1455int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, 1455int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
1456 int degraded) 1456 int degraded)
1457{ 1457{
1458 /* bitmap_start_sync must always report on multiples of whole 1458 /* bitmap_start_sync must always report on multiples of whole
@@ -1463,7 +1463,7 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
1463 * Return the 'or' of the result. 1463 * Return the 'or' of the result.
1464 */ 1464 */
1465 int rv = 0; 1465 int rv = 0;
1466 int blocks1; 1466 sector_t blocks1;
1467 1467
1468 *blocks = 0; 1468 *blocks = 0;
1469 while (*blocks < (PAGE_SIZE>>9)) { 1469 while (*blocks < (PAGE_SIZE>>9)) {
@@ -1476,7 +1476,7 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
1476} 1476}
1477EXPORT_SYMBOL(bitmap_start_sync); 1477EXPORT_SYMBOL(bitmap_start_sync);
1478 1478
1479void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted) 1479void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted)
1480{ 1480{
1481 bitmap_counter_t *bmc; 1481 bitmap_counter_t *bmc;
1482 unsigned long flags; 1482 unsigned long flags;
@@ -1515,7 +1515,7 @@ void bitmap_close_sync(struct bitmap *bitmap)
1515 * RESYNC bit wherever it is still on 1515 * RESYNC bit wherever it is still on
1516 */ 1516 */
1517 sector_t sector = 0; 1517 sector_t sector = 0;
1518 int blocks; 1518 sector_t blocks;
1519 if (!bitmap) 1519 if (!bitmap)
1520 return; 1520 return;
1521 while (sector < bitmap->mddev->resync_max_sectors) { 1521 while (sector < bitmap->mddev->resync_max_sectors) {
@@ -1528,7 +1528,7 @@ EXPORT_SYMBOL(bitmap_close_sync);
1528void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector) 1528void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
1529{ 1529{
1530 sector_t s = 0; 1530 sector_t s = 0;
1531 int blocks; 1531 sector_t blocks;
1532 1532
1533 if (!bitmap) 1533 if (!bitmap)
1534 return; 1534 return;
@@ -1562,7 +1562,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
1562 * be 0 at this point 1562 * be 0 at this point
1563 */ 1563 */
1564 1564
1565 int secs; 1565 sector_t secs;
1566 bitmap_counter_t *bmc; 1566 bitmap_counter_t *bmc;
1567 spin_lock_irq(&bitmap->lock); 1567 spin_lock_irq(&bitmap->lock);
1568 bmc = bitmap_get_counter(bitmap, offset, &secs, 1); 1568 bmc = bitmap_get_counter(bitmap, offset, &secs, 1);
@@ -1790,7 +1790,7 @@ int bitmap_load(mddev_t *mddev)
1790 * All chunks should be clean, but some might need_sync. 1790 * All chunks should be clean, but some might need_sync.
1791 */ 1791 */
1792 while (sector < mddev->resync_max_sectors) { 1792 while (sector < mddev->resync_max_sectors) {
1793 int blocks; 1793 sector_t blocks;
1794 bitmap_start_sync(bitmap, sector, &blocks, 0); 1794 bitmap_start_sync(bitmap, sector, &blocks, 0);
1795 sector += blocks; 1795 sector += blocks;
1796 } 1796 }