提交 57dab0bd 编写于 作者: N NeilBrown

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: NNeilBrown <neilb@suse.de>
上级 4b532c9b
...@@ -1101,7 +1101,7 @@ static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc) ...@@ -1101,7 +1101,7 @@ static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc)
bitmap_checkfree(bitmap, page); bitmap_checkfree(bitmap, page);
} }
static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
sector_t offset, int *blocks, sector_t offset, sector_t *blocks,
int create); int create);
/* /*
...@@ -1115,7 +1115,7 @@ void bitmap_daemon_work(mddev_t *mddev) ...@@ -1115,7 +1115,7 @@ void bitmap_daemon_work(mddev_t *mddev)
unsigned long j; unsigned long j;
unsigned long flags; unsigned long flags;
struct page *page = NULL, *lastpage = NULL; struct page *page = NULL, *lastpage = NULL;
int blocks; sector_t blocks;
void *paddr; void *paddr;
struct dm_dirty_log *log = mddev->bitmap_info.log; struct dm_dirty_log *log = mddev->bitmap_info.log;
...@@ -1258,7 +1258,7 @@ void bitmap_daemon_work(mddev_t *mddev) ...@@ -1258,7 +1258,7 @@ void bitmap_daemon_work(mddev_t *mddev)
} }
static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
sector_t offset, int *blocks, sector_t offset, sector_t *blocks,
int create) int create)
__releases(bitmap->lock) __releases(bitmap->lock)
__acquires(bitmap->lock) __acquires(bitmap->lock)
...@@ -1316,7 +1316,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect ...@@ -1316,7 +1316,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
} }
while (sectors) { while (sectors) {
int blocks; sector_t blocks;
bitmap_counter_t *bmc; bitmap_counter_t *bmc;
spin_lock_irq(&bitmap->lock); spin_lock_irq(&bitmap->lock);
...@@ -1381,7 +1381,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto ...@@ -1381,7 +1381,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
success = 0; success = 0;
while (sectors) { while (sectors) {
int blocks; sector_t blocks;
unsigned long flags; unsigned long flags;
bitmap_counter_t *bmc; bitmap_counter_t *bmc;
...@@ -1423,7 +1423,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto ...@@ -1423,7 +1423,7 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
} }
EXPORT_SYMBOL(bitmap_endwrite); EXPORT_SYMBOL(bitmap_endwrite);
static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
int degraded) int degraded)
{ {
bitmap_counter_t *bmc; bitmap_counter_t *bmc;
...@@ -1452,7 +1452,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *bloc ...@@ -1452,7 +1452,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *bloc
return rv; return rv;
} }
int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
int degraded) int degraded)
{ {
/* bitmap_start_sync must always report on multiples of whole /* 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,7 +1463,7 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
* Return the 'or' of the result. * Return the 'or' of the result.
*/ */
int rv = 0; int rv = 0;
int blocks1; sector_t blocks1;
*blocks = 0; *blocks = 0;
while (*blocks < (PAGE_SIZE>>9)) { while (*blocks < (PAGE_SIZE>>9)) {
...@@ -1476,7 +1476,7 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, ...@@ -1476,7 +1476,7 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
} }
EXPORT_SYMBOL(bitmap_start_sync); EXPORT_SYMBOL(bitmap_start_sync);
void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted) void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted)
{ {
bitmap_counter_t *bmc; bitmap_counter_t *bmc;
unsigned long flags; unsigned long flags;
...@@ -1515,7 +1515,7 @@ void bitmap_close_sync(struct bitmap *bitmap) ...@@ -1515,7 +1515,7 @@ void bitmap_close_sync(struct bitmap *bitmap)
* RESYNC bit wherever it is still on * RESYNC bit wherever it is still on
*/ */
sector_t sector = 0; sector_t sector = 0;
int blocks; sector_t blocks;
if (!bitmap) if (!bitmap)
return; return;
while (sector < bitmap->mddev->resync_max_sectors) { while (sector < bitmap->mddev->resync_max_sectors) {
...@@ -1528,7 +1528,7 @@ EXPORT_SYMBOL(bitmap_close_sync); ...@@ -1528,7 +1528,7 @@ EXPORT_SYMBOL(bitmap_close_sync);
void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector) void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
{ {
sector_t s = 0; sector_t s = 0;
int blocks; sector_t blocks;
if (!bitmap) if (!bitmap)
return; return;
...@@ -1562,7 +1562,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n ...@@ -1562,7 +1562,7 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
* be 0 at this point * be 0 at this point
*/ */
int secs; sector_t secs;
bitmap_counter_t *bmc; bitmap_counter_t *bmc;
spin_lock_irq(&bitmap->lock); spin_lock_irq(&bitmap->lock);
bmc = bitmap_get_counter(bitmap, offset, &secs, 1); bmc = bitmap_get_counter(bitmap, offset, &secs, 1);
...@@ -1790,7 +1790,7 @@ int bitmap_load(mddev_t *mddev) ...@@ -1790,7 +1790,7 @@ int bitmap_load(mddev_t *mddev)
* All chunks should be clean, but some might need_sync. * All chunks should be clean, but some might need_sync.
*/ */
while (sector < mddev->resync_max_sectors) { while (sector < mddev->resync_max_sectors) {
int blocks; sector_t blocks;
bitmap_start_sync(bitmap, sector, &blocks, 0); bitmap_start_sync(bitmap, sector, &blocks, 0);
sector += blocks; sector += blocks;
} }
......
...@@ -271,8 +271,8 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, ...@@ -271,8 +271,8 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
unsigned long sectors, int behind); unsigned long sectors, int behind);
void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, void bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
unsigned long sectors, int success, int behind); unsigned long sectors, int success, int behind);
int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded); int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded);
void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted);
void bitmap_close_sync(struct bitmap *bitmap); void bitmap_close_sync(struct bitmap *bitmap);
void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector); void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector);
......
...@@ -1245,7 +1245,7 @@ static void end_sync_write(struct bio *bio, int error) ...@@ -1245,7 +1245,7 @@ static void end_sync_write(struct bio *bio, int error)
break; break;
} }
if (!uptodate) { if (!uptodate) {
int sync_blocks = 0; sector_t sync_blocks = 0;
sector_t s = r1_bio->sector; sector_t s = r1_bio->sector;
long sectors_to_go = r1_bio->sectors; long sectors_to_go = r1_bio->sectors;
/* make sure these bits doesn't get cleared. */ /* 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,7 +1705,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
int i; int i;
int wonly = -1; int wonly = -1;
int write_targets = 0, read_targets = 0; int write_targets = 0, read_targets = 0;
int sync_blocks; sector_t sync_blocks;
int still_degraded = 0; int still_degraded = 0;
if (!conf->r1buf_pool) if (!conf->r1buf_pool)
......
...@@ -1820,7 +1820,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1820,7 +1820,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
int disk; int disk;
int i; int i;
int max_sync; int max_sync;
int sync_blocks; sector_t sync_blocks;
sector_t sectors_skipped = 0; sector_t sectors_skipped = 0;
int chunks_skipped = 0; int chunks_skipped = 0;
......
...@@ -4360,7 +4360,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski ...@@ -4360,7 +4360,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
raid5_conf_t *conf = mddev->private; raid5_conf_t *conf = mddev->private;
struct stripe_head *sh; struct stripe_head *sh;
sector_t max_sector = mddev->dev_sectors; sector_t max_sector = mddev->dev_sectors;
int sync_blocks; sector_t sync_blocks;
int still_degraded = 0; int still_degraded = 0;
int i; int i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册