diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-26 14:20:10 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-26 14:20:10 -0400 |
| commit | c271f5bc9a7a03fab037dbf5bdd5a730a6e26211 (patch) | |
| tree | 7e35b2bc59b5adea852d61b2f06eb5e694ef5582 | |
| parent | c7dad2343f494359f6e45f62ff97055749b99670 (diff) | |
| parent | f94c0b6658c7edea8bc19d13be321e3860a3fa54 (diff) | |
Merge tag 'md/3.11-fixes' of git://neil.brown.name/md
Pull md fixes from Neil Brown:
"Two more bugfixes for md in 3.11
Both marked for -stable, both since 3.3. I guess I should spend more
time testing..."
* tag 'md/3.11-fixes' of git://neil.brown.name/md:
md/raid5: fix interaction of 'replace' and 'recovery'.
md/raid10: remove use-after-free bug.
| -rw-r--r-- | drivers/md/raid10.c | 8 | ||||
| -rw-r--r-- | drivers/md/raid5.c | 15 | ||||
| -rw-r--r-- | drivers/md/raid5.h | 1 |
3 files changed, 18 insertions, 6 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 957a719e8c2f..df7b0a06b0ea 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
| @@ -2290,12 +2290,18 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
| 2290 | d = r10_bio->devs[1].devnum; | 2290 | d = r10_bio->devs[1].devnum; |
| 2291 | wbio = r10_bio->devs[1].bio; | 2291 | wbio = r10_bio->devs[1].bio; |
| 2292 | wbio2 = r10_bio->devs[1].repl_bio; | 2292 | wbio2 = r10_bio->devs[1].repl_bio; |
| 2293 | /* Need to test wbio2->bi_end_io before we call | ||
| 2294 | * generic_make_request as if the former is NULL, | ||
| 2295 | * the latter is free to free wbio2. | ||
| 2296 | */ | ||
| 2297 | if (wbio2 && !wbio2->bi_end_io) | ||
| 2298 | wbio2 = NULL; | ||
| 2293 | if (wbio->bi_end_io) { | 2299 | if (wbio->bi_end_io) { |
| 2294 | atomic_inc(&conf->mirrors[d].rdev->nr_pending); | 2300 | atomic_inc(&conf->mirrors[d].rdev->nr_pending); |
| 2295 | md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); | 2301 | md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); |
| 2296 | generic_make_request(wbio); | 2302 | generic_make_request(wbio); |
| 2297 | } | 2303 | } |
| 2298 | if (wbio2 && wbio2->bi_end_io) { | 2304 | if (wbio2) { |
| 2299 | atomic_inc(&conf->mirrors[d].replacement->nr_pending); | 2305 | atomic_inc(&conf->mirrors[d].replacement->nr_pending); |
| 2300 | md_sync_acct(conf->mirrors[d].replacement->bdev, | 2306 | md_sync_acct(conf->mirrors[d].replacement->bdev, |
| 2301 | bio_sectors(wbio2)); | 2307 | bio_sectors(wbio2)); |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 2bf094a587cb..78ea44336e75 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
| @@ -3462,6 +3462,7 @@ static void handle_stripe(struct stripe_head *sh) | |||
| 3462 | test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) { | 3462 | test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) { |
| 3463 | set_bit(STRIPE_SYNCING, &sh->state); | 3463 | set_bit(STRIPE_SYNCING, &sh->state); |
| 3464 | clear_bit(STRIPE_INSYNC, &sh->state); | 3464 | clear_bit(STRIPE_INSYNC, &sh->state); |
| 3465 | clear_bit(STRIPE_REPLACED, &sh->state); | ||
| 3465 | } | 3466 | } |
| 3466 | spin_unlock(&sh->stripe_lock); | 3467 | spin_unlock(&sh->stripe_lock); |
| 3467 | } | 3468 | } |
| @@ -3607,19 +3608,23 @@ static void handle_stripe(struct stripe_head *sh) | |||
| 3607 | handle_parity_checks5(conf, sh, &s, disks); | 3608 | handle_parity_checks5(conf, sh, &s, disks); |
| 3608 | } | 3609 | } |
| 3609 | 3610 | ||
| 3610 | if (s.replacing && s.locked == 0 | 3611 | if ((s.replacing || s.syncing) && s.locked == 0 |
| 3611 | && !test_bit(STRIPE_INSYNC, &sh->state)) { | 3612 | && !test_bit(STRIPE_COMPUTE_RUN, &sh->state) |
| 3613 | && !test_bit(STRIPE_REPLACED, &sh->state)) { | ||
| 3612 | /* Write out to replacement devices where possible */ | 3614 | /* Write out to replacement devices where possible */ |
| 3613 | for (i = 0; i < conf->raid_disks; i++) | 3615 | for (i = 0; i < conf->raid_disks; i++) |
| 3614 | if (test_bit(R5_UPTODATE, &sh->dev[i].flags) && | 3616 | if (test_bit(R5_NeedReplace, &sh->dev[i].flags)) { |
| 3615 | test_bit(R5_NeedReplace, &sh->dev[i].flags)) { | 3617 | WARN_ON(!test_bit(R5_UPTODATE, &sh->dev[i].flags)); |
| 3616 | set_bit(R5_WantReplace, &sh->dev[i].flags); | 3618 | set_bit(R5_WantReplace, &sh->dev[i].flags); |
| 3617 | set_bit(R5_LOCKED, &sh->dev[i].flags); | 3619 | set_bit(R5_LOCKED, &sh->dev[i].flags); |
| 3618 | s.locked++; | 3620 | s.locked++; |
| 3619 | } | 3621 | } |
| 3620 | set_bit(STRIPE_INSYNC, &sh->state); | 3622 | if (s.replacing) |
| 3623 | set_bit(STRIPE_INSYNC, &sh->state); | ||
| 3624 | set_bit(STRIPE_REPLACED, &sh->state); | ||
| 3621 | } | 3625 | } |
| 3622 | if ((s.syncing || s.replacing) && s.locked == 0 && | 3626 | if ((s.syncing || s.replacing) && s.locked == 0 && |
| 3627 | !test_bit(STRIPE_COMPUTE_RUN, &sh->state) && | ||
| 3623 | test_bit(STRIPE_INSYNC, &sh->state)) { | 3628 | test_bit(STRIPE_INSYNC, &sh->state)) { |
| 3624 | md_done_sync(conf->mddev, STRIPE_SECTORS, 1); | 3629 | md_done_sync(conf->mddev, STRIPE_SECTORS, 1); |
| 3625 | clear_bit(STRIPE_SYNCING, &sh->state); | 3630 | clear_bit(STRIPE_SYNCING, &sh->state); |
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index b0b663b119a8..70c49329ca9a 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h | |||
| @@ -306,6 +306,7 @@ enum { | |||
| 306 | STRIPE_SYNC_REQUESTED, | 306 | STRIPE_SYNC_REQUESTED, |
| 307 | STRIPE_SYNCING, | 307 | STRIPE_SYNCING, |
| 308 | STRIPE_INSYNC, | 308 | STRIPE_INSYNC, |
| 309 | STRIPE_REPLACED, | ||
| 309 | STRIPE_PREREAD_ACTIVE, | 310 | STRIPE_PREREAD_ACTIVE, |
| 310 | STRIPE_DELAYED, | 311 | STRIPE_DELAYED, |
| 311 | STRIPE_DEGRADED, | 312 | STRIPE_DEGRADED, |
