@@ -1236,14 +1236,14 @@ static void end_sync_read(struct bio *bio, int error)
12361236 /* for reconstruct, we always reschedule after a read.
12371237 * for resync, only after all reads
12381238 */
1239+ rdev_dec_pending (conf -> mirrors [d ].rdev , conf -> mddev );
12391240 if (test_bit (R10BIO_IsRecover , & r10_bio -> state ) ||
12401241 atomic_dec_and_test (& r10_bio -> remaining )) {
12411242 /* we have read all the blocks,
12421243 * do the comparison in process context in raid10d
12431244 */
12441245 reschedule_retry (r10_bio );
12451246 }
1246- rdev_dec_pending (conf -> mirrors [d ].rdev , conf -> mddev );
12471247}
12481248
12491249static void end_sync_write (struct bio * bio , int error )
@@ -1264,19 +1264,20 @@ static void end_sync_write(struct bio *bio, int error)
12641264
12651265 update_head_pos (i , r10_bio );
12661266
1267+ rdev_dec_pending (conf -> mirrors [d ].rdev , mddev );
12671268 while (atomic_dec_and_test (& r10_bio -> remaining )) {
12681269 if (r10_bio -> master_bio == NULL ) {
12691270 /* the primary of several recovery bios */
1270- md_done_sync ( mddev , r10_bio -> sectors , 1 ) ;
1271+ sector_t s = r10_bio -> sectors ;
12711272 put_buf (r10_bio );
1273+ md_done_sync (mddev , s , 1 );
12721274 break ;
12731275 } else {
12741276 r10bio_t * r10_bio2 = (r10bio_t * )r10_bio -> master_bio ;
12751277 put_buf (r10_bio );
12761278 r10_bio = r10_bio2 ;
12771279 }
12781280 }
1279- rdev_dec_pending (conf -> mirrors [d ].rdev , mddev );
12801281}
12811282
12821283/*
@@ -1749,8 +1750,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
17491750 if (!go_faster && conf -> nr_waiting )
17501751 msleep_interruptible (1000 );
17511752
1752- bitmap_cond_end_sync (mddev -> bitmap , sector_nr );
1753-
17541753 /* Again, very different code for resync and recovery.
17551754 * Both must result in an r10bio with a list of bios that
17561755 * have bi_end_io, bi_sector, bi_bdev set,
@@ -1886,6 +1885,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
18861885 /* resync. Schedule a read for every block at this virt offset */
18871886 int count = 0 ;
18881887
1888+ bitmap_cond_end_sync (mddev -> bitmap , sector_nr );
1889+
18891890 if (!bitmap_start_sync (mddev -> bitmap , sector_nr ,
18901891 & sync_blocks , mddev -> degraded ) &&
18911892 !conf -> fullsync && !test_bit (MD_RECOVERY_REQUESTED , & mddev -> recovery )) {
@@ -2010,13 +2011,13 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
20102011 /* There is nowhere to write, so all non-sync
20112012 * drives must be failed, so try the next chunk...
20122013 */
2013- {
2014- sector_t sec = max_sector - sector_nr ;
2015- sectors_skipped += sec ;
2014+ if (sector_nr + max_sync < max_sector )
2015+ max_sector = sector_nr + max_sync ;
2016+
2017+ sectors_skipped += (max_sector - sector_nr );
20162018 chunks_skipped ++ ;
20172019 sector_nr = max_sector ;
20182020 goto skipped ;
2019- }
20202021}
20212022
20222023static int run (mddev_t * mddev )
0 commit comments