md/raid5: fix soft lockup in retry_aligned_read()
Subsystems (2)
PATCH 1/1 md/raid5: fix soft lockup in retry_aligned_read()
When retry_aligned_read() encounters an overlapped stripe, it releases the stripe via raid5_release_stripe() which puts it on the lockless released_stripes llist. In the next raid5d loop iteration, release_stripe_list() drains the stripe onto handle_list (since STRIPE_HANDLE is set by the original IO), but retry_aligned_read() runs before handle_active_stripes() and removes the stripe from handle_list via find_get_stripe() -> list_del_init(). This prevents handle_stripe() from ever processing the stripe to resolve the overlap, causing an infinite loop and soft lockup.
Fix this by using __release_stripe() with temp_inactive_list instead of raid5_release_stripe() in the failure path, so the stripe does not go through the released_stripes llist. This allows raid5d to break out of its loop, and the overlap will be resolved when the stripe is eventually processed by handle_stripe().
--- drivers/md/raid5.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/md/raid5.c +7 -1
@@ -6641,7 +6641,13 @@ static int retry_aligned_read(struct r5conf *conf, struct bio *raid_bio, }if (!add_stripe_bio (sh, raid_bio, dd_idx,0 ,0 )) { -raid5_release_stripe (sh); +int hash; + +spin_lock_irq (&conf->device_lock); + hash = sh->hash_lock_index; +__release_stripe (conf, sh, + &conf->temp_inactive_list[hash]); +spin_unlock_irq (&conf->device_lock); conf->retry_read_aligned = raid_bio; conf->retry_read_offset = scnt;return handled;
Signature · 4 lines
2.34.1 Disclaimer: The contents of this e-mail message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or phone and delete this message and its attachments, if any.
Yu Kuai
AppliedQuoted 16 lines · Chia-Ming Chang
When
retry_aligned_read()encounters an overlapped stripe, it releases the stripe viaraid5_release_stripe()which puts it on the locklessreleased_stripesllist. In the next raid5d loop iteration,release_stripe_list()drains the stripe ontohandle_list(sinceSTRIPE_HANDLEis set by the original IO), butretry_aligned_read()runs beforehandle_active_stripes()and removes the stripe fromhandle_listviafind_get_stripe()->list_del_init(). This preventshandle_stripe()from ever processing the stripe to resolve the overlap, causing an infinite loop and soft lockup.Fix this by using
__release_stripe()withtemp_inactive_listinstead ofraid5_release_stripe()in the failure path, so the stripe does not go through thereleased_stripesllist. This allows raid5d to break out of its loop, and the overlap will be resolved when the stripe is eventually processed byhandle_stripe().
Quoted 7 lines
Fixes 773ca82fa1ee ("raid5: make release_stripe lockless")Signed-off-by FengWei Shih<[email protected]>Signed-off-by Chia-Ming Chang<[email protected]>--- drivers/md/raid5.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Applied to md-7.1
Signature · 2 lines
Thansk, Kuai