nvme_fc: correct abort race condition on resets
authorJames Smart <jsmart2021@gmail.com>
Tue, 6 Feb 2018 14:48:29 +0000 (06:48 -0800)
committerSagi Grimberg <sagi@grimberg.me>
Sun, 11 Feb 2018 08:45:34 +0000 (10:45 +0200)
commit3efd6e8ebe19f0774c82de582849539b60cc4d97
tree7b920c5ea26231bc3d1d00858cadee1e5674d253
parent8cb6af7b3a6d47f95ecb461a3f8d39cf6a64e4ae
nvme_fc: correct abort race condition on resets

During reset handling, there is live io completing while the reset
is taking place. The reset path attempts to abort all outstanding io,
counting the number of ios that were reset. It then waits for those
ios to be reclaimed from the lldd before continuing.

The transport's logic on io state and flag setting was poor, allowing
ios to complete simultaneous to the abort request. The completed ios
were counted, but as the completion had already occurred, the
completion never reduced the count. As the count never zeros, the
reset/delete never completes.

Tighten it up by unconditionally changing the op state to completed
when the io done handler is called.  The reset/abort path now changes
the op state to aborted, but the abort only continues if the op
state was live priviously. If complete, the abort is backed out.
Thus proper counting of io aborts and their completions is working
again.

Also removed the TERMIO state on the op as it's redundant with the
op's aborted state.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/host/fc.c