@@ -420,10 +420,8 @@ static void close_write(struct r1bio *r1_bio)
420420 r1_bio -> behind_master_bio = NULL ;
421421 }
422422
423- /* clear the bitmap if all writes complete successfully */
424- mddev -> bitmap_ops -> endwrite (mddev , r1_bio -> sector , r1_bio -> sectors ,
425- !test_bit (R1BIO_Degraded , & r1_bio -> state ),
426- test_bit (R1BIO_BehindIO , & r1_bio -> state ));
423+ if (test_bit (R1BIO_BehindIO , & r1_bio -> state ))
424+ mddev -> bitmap_ops -> end_behind_write (mddev );
427425 md_write_end (mddev );
428426}
429427
@@ -480,8 +478,6 @@ static void raid1_end_write_request(struct bio *bio)
480478 if (!test_bit (Faulty , & rdev -> flags ))
481479 set_bit (R1BIO_WriteError , & r1_bio -> state );
482480 else {
483- /* Fail the request */
484- set_bit (R1BIO_Degraded , & r1_bio -> state );
485481 /* Finished with this branch */
486482 r1_bio -> bios [mirror ] = NULL ;
487483 to_put = bio ;
@@ -1535,11 +1531,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
15351531 write_behind = true;
15361532
15371533 r1_bio -> bios [i ] = NULL ;
1538- if (!rdev || test_bit (Faulty , & rdev -> flags )) {
1539- if (i < conf -> raid_disks )
1540- set_bit (R1BIO_Degraded , & r1_bio -> state );
1534+ if (!rdev || test_bit (Faulty , & rdev -> flags ))
15411535 continue ;
1542- }
15431536
15441537 atomic_inc (& rdev -> nr_pending );
15451538 if (test_bit (WriteErrorSeen , & rdev -> flags )) {
@@ -1558,16 +1551,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
15581551 */
15591552 max_sectors = bad_sectors ;
15601553 rdev_dec_pending (rdev , mddev );
1561- /* We don't set R1BIO_Degraded as that
1562- * only applies if the disk is
1563- * missing, so it might be re-added,
1564- * and we want to know to recover this
1565- * chunk.
1566- * In this case the device is here,
1567- * and the fact that this chunk is not
1568- * in-sync is recorded in the bad
1569- * block log
1570- */
15711554 continue ;
15721555 }
15731556 if (is_bad ) {
@@ -1645,9 +1628,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
16451628 stats .behind_writes < max_write_behind )
16461629 alloc_behind_master_bio (r1_bio , bio );
16471630
1648- mddev -> bitmap_ops -> startwrite (
1649- mddev , r1_bio -> sector , r1_bio -> sectors ,
1650- test_bit (R1BIO_BehindIO , & r1_bio -> state ));
1631+ if (test_bit (R1BIO_BehindIO , & r1_bio -> state ))
1632+ mddev -> bitmap_ops -> start_behind_write (mddev );
16511633 first_clone = 0 ;
16521634 }
16531635
@@ -2614,12 +2596,10 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
26142596 * errors.
26152597 */
26162598 fail = true;
2617- if (!narrow_write_error (r1_bio , m )) {
2599+ if (!narrow_write_error (r1_bio , m ))
26182600 md_error (conf -> mddev ,
26192601 conf -> mirrors [m ].rdev );
26202602 /* an I/O failed, we can't clear the bitmap */
2621- set_bit (R1BIO_Degraded , & r1_bio -> state );
2622- }
26232603 rdev_dec_pending (conf -> mirrors [m ].rdev ,
26242604 conf -> mddev );
26252605 }
@@ -2710,8 +2690,6 @@ static void raid1d(struct md_thread *thread)
27102690 list_del (& r1_bio -> retry_list );
27112691 idx = sector_to_idx (r1_bio -> sector );
27122692 atomic_dec (& conf -> nr_queued [idx ]);
2713- if (mddev -> degraded )
2714- set_bit (R1BIO_Degraded , & r1_bio -> state );
27152693 if (test_bit (R1BIO_WriteError , & r1_bio -> state ))
27162694 close_write (r1_bio );
27172695 raid_end_bio_io (r1_bio );
0 commit comments