bdev/nvme: Fix compare and write command completion

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: I16f6842703eead32318d2aca53cbf1e2b5b15bce

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/481976
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Szwed 2020-01-17 14:06:24 +01:00 committed by Tomasz Zawadzki
parent 058ec60eab
commit 34bac0bad6

View File

@ -2029,19 +2029,26 @@ bdev_nvme_comparev_and_writev_done(void *ref, const struct spdk_nvme_cpl *cpl)
struct nvme_bdev_io *bio = ref;
struct spdk_bdev_io *bdev_io = spdk_bdev_io_from_ctx(bio);
/* We need to check if compare operation failed to make sure that in such case
* write operation failed as well. We don't need to know if we are in compare
* or write callback because for compare callback below check will always result
* as false. */
if (spdk_nvme_cpl_is_error(&bio->cpl)) {
assert(spdk_nvme_cpl_is_error(cpl));
/* Compare operation completion */
if ((cpl->cdw0 & 0xFF) == SPDK_NVME_OPC_COMPARE) {
/* Save compare result for write callback */
bio->cpl = *cpl;
return;
}
/* Save compare result for write callback. In case this is write callback this
* line does not matter */
bio->cpl = *cpl;
/* Write operation completion */
if (spdk_nvme_cpl_is_error(&bio->cpl)) {
/* If bio->cpl is already an error, it means the compare operation failed. In that case,
* complete the IO with the compare operation's status.
*/
if (!spdk_nvme_cpl_is_error(cpl)) {
SPDK_ERRLOG("Unexpected write success after compare failure.\n");
}
spdk_bdev_io_complete_nvme_status(bdev_io, cpl->cdw0, cpl->status.sct, cpl->status.sc);
spdk_bdev_io_complete_nvme_status(bdev_io, bio->cpl.cdw0, bio->cpl.status.sct, bio->cpl.status.sc);
} else {
spdk_bdev_io_complete_nvme_status(bdev_io, cpl->cdw0, cpl->status.sct, cpl->status.sc);
}
}
static void