diff options
author | Vitaly Mayatskikh <vmayatskikh@digitalocean.com> | 2020-03-03 13:14:40 -0500 |
---|---|---|
committer | Song Liu <songliubraving@fb.com> | 2020-07-22 11:44:54 -0700 |
commit | fe630de009d0729584d79c78f43121e07c745fdc (patch) | |
tree | b309aa7ea7f89b1aecdb44844cb1d3a75daecbcf /drivers/md/raid10.c | |
parent | c333f9495c451d958c6f4a41e5de2d8f80f79496 (diff) | |
download | linux-stable-fe630de009d0729584d79c78f43121e07c745fdc.tar.gz linux-stable-fe630de009d0729584d79c78f43121e07c745fdc.tar.bz2 linux-stable-fe630de009d0729584d79c78f43121e07c745fdc.zip |
md/raid10: avoid deadlock on recovery.
When disk failure happens and the array has a spare drive, resync thread
kicks in and starts to refill the spare. However it may get blocked by
a retry thread that resubmits failed IO to a mirror and itself can get
blocked on a barrier raised by the resync thread.
Acked-by: Nigel Croxon <ncroxon@redhat.com>
Signed-off-by: Vitaly Mayatskikh <vmayatskikh@digitalocean.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r-- | drivers/md/raid10.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 14b1ba732cd7..cefda2abd34f 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -980,6 +980,7 @@ static void wait_barrier(struct r10conf *conf) { spin_lock_irq(&conf->resync_lock); if (conf->barrier) { + struct bio_list *bio_list = current->bio_list; conf->nr_waiting++; /* Wait for the barrier to drop. * However if there are already pending @@ -994,9 +995,16 @@ static void wait_barrier(struct r10conf *conf) wait_event_lock_irq(conf->wait_barrier, !conf->barrier || (atomic_read(&conf->nr_pending) && - current->bio_list && - (!bio_list_empty(¤t->bio_list[0]) || - !bio_list_empty(¤t->bio_list[1]))), + bio_list && + (!bio_list_empty(&bio_list[0]) || + !bio_list_empty(&bio_list[1]))) || + /* move on if recovery thread is + * blocked by us + */ + (conf->mddev->thread->tsk == current && + test_bit(MD_RECOVERY_RUNNING, + &conf->mddev->recovery) && + conf->nr_queued > 0), conf->resync_lock); conf->nr_waiting--; if (!conf->nr_waiting) |