aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-06-21 20:17:13 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 22:07:43 -0400
commit57afd89f98a990747445f01c458ecae64263b2f8 (patch)
treecab9f5941f32299bc97936e111f6552ebcee9cf6 /drivers/md/raid10.c
parent06d91a5fe0b50c9060e70bdf7786f8a3c66249db (diff)
[PATCH] md: improve the interface to sync_request
1/ change the return value (which is number-of-sectors synced) from 'int' to 'sector_t'. The number of sectors is usually easily small enough to fit in an int, but if resync needs to abort, it may want to return the total number of remaining sectors, which could be large. Also errors cannot be returned as negative numbers now, so use 0 instead 2/ Add a 'skipped' return parameter to allow the array to report that it skipped the sectors. This allows md to take this into account in the speed calculations. Currently there is no important skipping, but the bitmap-based-resync that is coming will use this. Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index bfc9f52f0ecf..8476515bfdc7 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1321,7 +1321,7 @@ static int init_resync(conf_t *conf)
1321 * 1321 *
1322 */ 1322 */
1323 1323
1324static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) 1324static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
1325{ 1325{
1326 conf_t *conf = mddev_to_conf(mddev); 1326 conf_t *conf = mddev_to_conf(mddev);
1327 r10bio_t *r10_bio; 1327 r10bio_t *r10_bio;
@@ -1335,7 +1335,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1335 1335
1336 if (!conf->r10buf_pool) 1336 if (!conf->r10buf_pool)
1337 if (init_resync(conf)) 1337 if (init_resync(conf))
1338 return -ENOMEM; 1338 return 0;
1339 1339
1340 skipped: 1340 skipped:
1341 max_sector = mddev->size << 1; 1341 max_sector = mddev->size << 1;
@@ -1343,15 +1343,15 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1343 max_sector = mddev->resync_max_sectors; 1343 max_sector = mddev->resync_max_sectors;
1344 if (sector_nr >= max_sector) { 1344 if (sector_nr >= max_sector) {
1345 close_sync(conf); 1345 close_sync(conf);
1346 *skipped = 1;
1346 return sectors_skipped; 1347 return sectors_skipped;
1347 } 1348 }
1348 if (chunks_skipped >= conf->raid_disks) { 1349 if (chunks_skipped >= conf->raid_disks) {
1349 /* if there has been nothing to do on any drive, 1350 /* if there has been nothing to do on any drive,
1350 * then there is nothing to do at all.. 1351 * then there is nothing to do at all..
1351 */ 1352 */
1352 sector_t sec = max_sector - sector_nr; 1353 *skipped = 1;
1353 md_done_sync(mddev, sec, 1); 1354 return (max_sector - sector_nr) + sectors_skipped;
1354 return sec + sectors_skipped;
1355 } 1355 }
1356 1356
1357 /* make sure whole request will fit in a chunk - if chunks 1357 /* make sure whole request will fit in a chunk - if chunks
@@ -1565,17 +1565,22 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1565 } 1565 }
1566 } 1566 }
1567 1567
1568 if (sectors_skipped)
1569 /* pretend they weren't skipped, it makes
1570 * no important difference in this case
1571 */
1572 md_done_sync(mddev, sectors_skipped, 1);
1573
1568 return sectors_skipped + nr_sectors; 1574 return sectors_skipped + nr_sectors;
1569 giveup: 1575 giveup:
1570 /* There is nowhere to write, so all non-sync 1576 /* There is nowhere to write, so all non-sync
1571 * drives must be failed, so try the next chunk... 1577 * drives must be failed, so try the next chunk...
1572 */ 1578 */
1573 { 1579 {
1574 int sec = max_sector - sector_nr; 1580 sector_t sec = max_sector - sector_nr;
1575 sectors_skipped += sec; 1581 sectors_skipped += sec;
1576 chunks_skipped ++; 1582 chunks_skipped ++;
1577 sector_nr = max_sector; 1583 sector_nr = max_sector;
1578 md_done_sync(mddev, sec, 1);
1579 goto skipped; 1584 goto skipped;
1580 } 1585 }
1581} 1586}