Skip to content

Commit 58e94ae

Browse files
committed
md/raid1: close some possible races on write errors during resync
commit 4367af5 md/raid1: clear bad-block record when write succeeds. Added a 'reschedule_retry' call possibility at the end of end_sync_write, but didn't add matching code at the end of sync_request_write. So if the writes complete very quickly, or scheduling makes it seem that way, then we can miss rescheduling the request and the resync could hang. Also commit 73d5c38 md: avoid races when stopping resync. Fix a race condition in this same code in end_sync_write but didn't make the change in sync_request_write. This patch updates sync_request_write to fix both of those. Patch is suitable for 3.1 and later kernels. Reported-by: Alexander Lyakas <alex.bolshoy@gmail.com> Original-version-by: Alexander Lyakas <alex.bolshoy@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: NeilBrown <neilb@suse.de>
1 parent a05b7ea commit 58e94ae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/md/raid1.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,8 +1818,14 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
18181818

18191819
if (atomic_dec_and_test(&r1_bio->remaining)) {
18201820
/* if we're here, all write(s) have completed, so clean up */
1821-
md_done_sync(mddev, r1_bio->sectors, 1);
1822-
put_buf(r1_bio);
1821+
int s = r1_bio->sectors;
1822+
if (test_bit(R1BIO_MadeGood, &r1_bio->state) ||
1823+
test_bit(R1BIO_WriteError, &r1_bio->state))
1824+
reschedule_retry(r1_bio);
1825+
else {
1826+
put_buf(r1_bio);
1827+
md_done_sync(mddev, s, 1);
1828+
}
18231829
}
18241830
}
18251831

0 commit comments

Comments
 (0)