nvme-rdma: serialize controller teardown sequences
authorSagi Grimberg <sagi@grimberg.me>
Thu, 6 Aug 2020 01:13:58 +0000 (18:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Sep 2020 11:55:35 +0000 (13:55 +0200)
commit3341cac774c144e61a69b59677628671e384d6fc
treecef55fbeb93faf59c3c10c34cd0c973e4b0ab864
parented67604770cd486482da46c8f5c7d5c613d4becb
nvme-rdma: serialize controller teardown sequences

[ Upstream commit 5110f40241d08334375eb0495f174b1d2c07657e ]

In the timeout handler we may need to complete a request because the
request that timed out may be an I/O that is a part of a serial sequence
of controller teardown or initialization. In order to complete the
request, we need to fence any other context that may compete with us
and complete the request that is timing out.

In this case, we could have a potential double completion in case
a hard-irq or a different competing context triggered error recovery
and is running inflight request cancellation concurrently with the
timeout handler.

Protect using a ctrl teardown_lock to serialize contexts that may
complete a cancelled request due to error recovery or a reset.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/rdma.c