diff options
author | NeilBrown <neilb@suse.de> | 2010-10-18 19:03:39 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-10-28 02:32:26 -0400 |
commit | 57dab0bdf689d42972975ec646d862b0900a4bf3 (patch) | |
tree | d136f69b8a68850e40844397ebaffde31787c988 | |
parent | 4b532c9b8c87eb8e51605c4d08dfb5139c758dc5 (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>
-rw-r--r-- | drivers/md/bitmap.c | 26 | ||||
-rw-r--r-- | drivers/md/bitmap.h | 4 | ||||
-rw-r--r-- | drivers/md/raid1.c | 4 | ||||
-rw-r--r-- | drivers/md/raid10.c | 2 | ||||
-rw-r--r-- | drivers/md/raid5.c | 2 |
5 files changed, 19 insertions, 19 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 | } |
1103 | static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, | 1103 | static 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 | ||
1260 | static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, | 1260 | static 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 | } |
1424 | EXPORT_SYMBOL(bitmap_endwrite); | 1424 | EXPORT_SYMBOL(bitmap_endwrite); |
1425 | 1425 | ||
1426 | static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, | 1426 | static 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 | ||
1455 | int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, | 1455 | int 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 | } |
1477 | EXPORT_SYMBOL(bitmap_start_sync); | 1477 | EXPORT_SYMBOL(bitmap_start_sync); |
1478 | 1478 | ||
1479 | void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted) | 1479 | void 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); | |||
1528 | void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector) | 1528 | void 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 | } |
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h index e872a7bad6b8..931a7a7c3796 100644 --- a/drivers/md/bitmap.h +++ b/drivers/md/bitmap.h | |||
@@ -271,8 +271,8 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, | |||
271 | unsigned long sectors, int behind); | 271 | unsigned long sectors, int behind); |
272 | void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, | 272 | void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, |
273 | unsigned long sectors, int success, int behind); | 273 | unsigned long sectors, int success, int behind); |
274 | int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded); | 274 | int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded); |
275 | void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); | 275 | void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted); |
276 | void bitmap_close_sync(struct bitmap *bitmap); | 276 | void bitmap_close_sync(struct bitmap *bitmap); |
277 | void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector); | 277 | void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector); |
278 | 278 | ||
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 378a25894c57..a4b85a947532 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1245,7 +1245,7 @@ static void end_sync_write(struct bio *bio, int error) | |||
1245 | break; | 1245 | break; |
1246 | } | 1246 | } |
1247 | if (!uptodate) { | 1247 | if (!uptodate) { |
1248 | int sync_blocks = 0; | 1248 | sector_t sync_blocks = 0; |
1249 | sector_t s = r1_bio->sector; | 1249 | sector_t s = r1_bio->sector; |
1250 | long sectors_to_go = r1_bio->sectors; | 1250 | long sectors_to_go = r1_bio->sectors; |
1251 | /* make sure these bits doesn't get cleared. */ | 1251 | /* make sure these bits doesn't get cleared. */ |
@@ -1705,7 +1705,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1705 | int i; | 1705 | int i; |
1706 | int wonly = -1; | 1706 | int wonly = -1; |
1707 | int write_targets = 0, read_targets = 0; | 1707 | int write_targets = 0, read_targets = 0; |
1708 | int sync_blocks; | 1708 | sector_t sync_blocks; |
1709 | int still_degraded = 0; | 1709 | int still_degraded = 0; |
1710 | 1710 | ||
1711 | if (!conf->r1buf_pool) | 1711 | if (!conf->r1buf_pool) |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index f0d082f749be..387fe4b4fab7 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1820,7 +1820,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1820 | int disk; | 1820 | int disk; |
1821 | int i; | 1821 | int i; |
1822 | int max_sync; | 1822 | int max_sync; |
1823 | int sync_blocks; | 1823 | sector_t sync_blocks; |
1824 | 1824 | ||
1825 | sector_t sectors_skipped = 0; | 1825 | sector_t sectors_skipped = 0; |
1826 | int chunks_skipped = 0; | 1826 | int chunks_skipped = 0; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 31140d1259dc..8abc159b377a 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -4360,7 +4360,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski | |||
4360 | raid5_conf_t *conf = mddev->private; | 4360 | raid5_conf_t *conf = mddev->private; |
4361 | struct stripe_head *sh; | 4361 | struct stripe_head *sh; |
4362 | sector_t max_sector = mddev->dev_sectors; | 4362 | sector_t max_sector = mddev->dev_sectors; |
4363 | int sync_blocks; | 4363 | sector_t sync_blocks; |
4364 | int still_degraded = 0; | 4364 | int still_degraded = 0; |
4365 | int i; | 4365 | int i; |
4366 | 4366 | ||