nbd: handle unexpected replies better
authorJosef Bacik <josef@toxicpanda.com>
Mon, 16 Jul 2018 16:11:35 +0000 (12:11 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Sep 2018 07:26:25 +0000 (09:26 +0200)
commit05ee6166d702e8bea50322b31886a91fc8301672
tree4fdf047afc88c0c693bc2e1ce7a708a8074d0551
parentced413c5ef85cf2da775043a9480a86139eb6de7
nbd: handle unexpected replies better

[ Upstream commit 8f3ea35929a0806ad1397db99a89ffee0140822a ]

If the server or network is misbehaving and we get an unexpected reply
we can sometimes miss the request not being started and wait on a
request and never get a response, or even double complete the same
request.  Fix this by replacing the send_complete completion with just a
per command lock.  Add a per command cookie as well so that we can know
if we're getting a double completion for a previous event.  Also check
to make sure we dont have REQUEUED set as that means we raced with the
timeout handler and need to just let the retry occur.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/nbd.c