[PATCHv3] nvme: use srcu for iterating namespace list
Sagi Grimberg
sagi at grimberg.me
Sun May 26 06:53:11 PDT 2024
On 24/05/2024 18:53, Keith Busch wrote:
> From: Keith Busch <kbusch at kernel.org>
>
> The nvme pci driver synchronizes with all the namespace queues during a
> reset to ensure that there's no pending timeout work.
>
> Meanwhile the timeout work potentially iterates those same namespaces to
> freeze their queues.
>
> Each of those namespace iterations use the same read lock. If a write
> lock should somehow get between the synchronize and freeze steps, then
> forward progress is deadlocked.
>
> We had been relying on the nvme controller state machine to ensure the
> reset work wouldn't conflict with timeout work. That guarantee may be a
> bit fragile to rely on, so iterate the namespace lists without taking
> potentially circular locks, as reported by lockdep.
>
> Link: https://lore.kernel.org/all/20220930001943.zdbvolc3gkekfmcv@shindev/
> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki at wdc.com>
> Tested-by: Shinichiro Kawasaki <shinichiro.kawasaki at wdc.com>
> Signed-off-by: Keith Busch <kbusch at kernel.org>
> ---
> v3:
> Use kref_get_unless_zero as needed (hch)
>
> Keep the original singular namespace check for nvme_dev_user_cmd (sagi)
Seems to pass blktests for me (outside of unrelated failures).
Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
More information about the Linux-nvme
mailing list