diff options
author | NeilBrown <neilb@suse.de> | 2009-02-24 21:18:47 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-02-24 21:18:47 -0500 |
commit | 73d5c38a9536142e062c35997b044e89166e063b (patch) | |
tree | 68fd385cbdee1fa75269974ef210d53a0ae5e311 /drivers/md/raid1.c | |
parent | 78200d45cde2a79c0d0ae0407883bb264caa3c18 (diff) |
md: avoid races when stopping resync.
There has been a race in raid10 and raid1 for a long time
which has only recently started showing up due to a scheduler changed.
When a sync_read request finishes, as soon as reschedule_retry
is called, another thread can mark the resync request as having
completed, so md_do_sync can finish, ->stop can be called, and
->conf can be freed. So using conf after reschedule_retry is not
safe.
Similarly, when finishing a sync_write, calling md_done_sync must be
the last thing we do, as it allows a chain of events which will free
conf and other data structures.
The first of these requires action in raid10.c
The second requires action in raid1.c and raid10.c
Cc: stable@kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 01e3cffd03b8..e2466425d9ca 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1237,8 +1237,9 @@ static void end_sync_write(struct bio *bio, int error) | |||
1237 | update_head_pos(mirror, r1_bio); | 1237 | update_head_pos(mirror, r1_bio); |
1238 | 1238 | ||
1239 | if (atomic_dec_and_test(&r1_bio->remaining)) { | 1239 | if (atomic_dec_and_test(&r1_bio->remaining)) { |
1240 | md_done_sync(mddev, r1_bio->sectors, uptodate); | 1240 | sector_t s = r1_bio->sectors; |
1241 | put_buf(r1_bio); | 1241 | put_buf(r1_bio); |
1242 | md_done_sync(mddev, s, uptodate); | ||
1242 | } | 1243 | } |
1243 | } | 1244 | } |
1244 | 1245 | ||