[PATCH RFC] nvme: avoid deadlock warning in sync_io_queues() path

Sagi Grimberg sagi at grimberg.me
Wed Dec 13 05:02:11 PST 2023


> The commit c0feea594e05 ("workqueue: don't skip lockdep work dependency
> in cancel_work_sync()") restored a lockdep check and it triggered
> deadlock warning in sync_io_queues() path. This function locks
> namespaces_rwsem for read to traverse the namespace list and calls
> blk_sync_queue() for each namespace. blk_sync_queue() calls
> cancel_work_sync() to wait for nvme_timeout() completion which has paths
> to lock the namespaces_rwsem again for read. These two locks are both
> for read, but it can cause deadlock when another task has a lock for
> write. Hence, the deadlock warning was reported.
> 
> To avoid the deadlock warning, guard the namespace list by SRCU in place
> of the namespaces_rwsem. This avoids the deadlock by the two read locks
> since writes by other tasks do not stop the reads.

Based on the report this is triggered from the pci shutdown code path?
I think the problem is that there is a dev disable running together
with a reset (driven from the timeout handler). Perhaps this should
be addressed.

I don't think that making the namespaces lock an srcu helps us here.



More information about the Linux-nvme mailing list