Re: [PATCH v3] md/raid5: use dedicated llist for stripe plug

From: yu kuai

Date: Mon Nov 02 2026 - 21:20:27 EST


在 2026/10/21 9:40, Li Youhong 写道:

> From: Li Youhong<liyouhong@xxxxxxxxxx>
>
> release_stripe_plug() and do_release_stripe() share sh->lru.
> release_stripe_plug() sets STRIPE_ON_UNPLUG_LIST and
> list_add_tail()s sh->lru onto raid5_plug_cb.list without
> device_lock. do_release_stripe() holds device_lock and, when the
> last reference drops, list_add()s the same lru onto a handle or
> inactive list.
>
> Two list_add()s on one node corrupt it. sh->lru can be
> reinitialized into a self-loop while raid5_plug_cb.list still
> points at that stripe. raid5_unplug() then walks the list under
> device_lock with IRQs disabled and never finishes. Other CPUs
> waiting for the same lock hard-lockup.
>
> Add a dedicated llist_node, unplug_list, to stripe_head, as
> release_list is used for released_stripes.
>
> Fixes: 8811b5968f62 ("raid5: make_request use batch stripe release")
> Suggested-by: Yu Kuai<yukuai@xxxxxxx>
> Cc:stable@xxxxxxxxxxxxxxx
> Signed-off-by: Li Youhong<liyouhong@xxxxxxxxxx>
> ---
> v3:
> - Skip device_lock when llist_del_all() returns NULL. The plug
> callback can still run with an empty list, and the check avoids
> an unnecessary spin_lock.
> - v2: link:https://lore.kernel.org/linux-raid/20260922060928.3486799-1-dayou5941@xxxxxxx/
>
> v2:
> - Drop taking device_lock in release_stripe_plug(). Add a dedicated
> unplug_list.
> - v1: link:https://lore.kernel.org/linux-raid/20260902095307.358569-1-dayou5941@xxxxxxx/
>
> ---
> drivers/md/raid5.c | 20 +++++++++++---------
> drivers/md/raid5.h | 1 +
> 2 files changed, 12 insertions(+), 9 deletions(-)
Applied

--
Thanks,
Kuai