nvme: fix the deadlock in nvme_update_formats
authorJianchao Wang <jianchao.w.wang@oracle.com>
Mon, 12 Feb 2018 12:54:45 +0000 (20:54 +0800)
committerKeith Busch <keith.busch@intel.com>
Wed, 14 Feb 2018 00:09:50 +0000 (17:09 -0700)
commit3fd176b754e992e1cdf1693ea8184626d1ed7671
tree6922ddd6c61233e01bbbe4b5be27f7dd065cb1fe
parent0a34e4668c508cbbc2d5ef2d9710b145e4c0b27d
nvme: fix the deadlock in nvme_update_formats

nvme_update_formats will invoke nvme_ns_remove under namespaces_mutext.
The will cause deadlock because nvme_ns_remove will also require
the namespaces_mutext. Fix it by getting the ns entries which should
be removed under namespaces_mutext and invoke nvme_ns_remove out of
namespaces_mutext.

Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/host/core.c