From 8889f7b7f498cbbdb5734790f00ece2531cf659b Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 25 May 2020 07:38:07 +0900 Subject: [PATCH] lib/bdev: Add SPDK_BDEV_IO_STATUS_ABORTED to notify the upper layer correctly The I/O aborted by the abort command should be completed with SC = 07h, i.e., "Command Abort Requested". However, if the generic bdev layer or non-NVMe bdev module aborted the I/O, the aborted I/O would complete with SC = 06h, i.e., "Internal Error". To fix this unexpected behavior, add an new I/O status SPDK_BDEV_IO_STATUS_ABORTED and update spdk_bdev_io_get_nvme_status() to set SC to 07h if the I/O status is SPDK_BDEV_IO_STATUS_ABORTED. If the NVMe bdev module aborts the I/O, the I/O status is set to SPDK_BDEV_IO_STATUS_NVME_ERROR and SC is set as expected. Signed-off-by: Shuhei Matsumoto Change-Id: Ifc99a97248a8d54a8c8d2fab74a90c7ce99c2e6e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2582 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- include/spdk/bdev_module.h | 1 + lib/bdev/bdev.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index 2ca298aef..f83db5e10 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -222,6 +222,7 @@ struct spdk_bdev_fn_table { /** bdev I/O completion status */ enum spdk_bdev_io_status { + SPDK_BDEV_IO_STATUS_ABORTED = -7, SPDK_BDEV_IO_STATUS_FIRST_FUSED_FAILED = -6, SPDK_BDEV_IO_STATUS_MISCOMPARE = -5, /* diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index e68236811..01749c275 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -4949,6 +4949,9 @@ spdk_bdev_io_get_nvme_status(const struct spdk_bdev_io *bdev_io, uint32_t *cdw0, } else if (bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS) { *sct = SPDK_NVME_SCT_GENERIC; *sc = SPDK_NVME_SC_SUCCESS; + } else if (bdev_io->internal.status == SPDK_BDEV_IO_STATUS_ABORTED) { + *sct = SPDK_NVME_SCT_GENERIC; + *sc = SPDK_NVME_SC_ABORTED_BY_REQUEST; } else { *sct = SPDK_NVME_SCT_GENERIC; *sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;