bdev: move error union to internal spdk_bdev_io struct

Change-Id: Iab755bb1473c404693f84f97c07bbb5c5fefbb49
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/416266
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Seth Howell 2018-06-20 16:38:35 -07:00 committed by Ben Walker
parent 07e736a395
commit 816c34cbce
5 changed files with 55 additions and 55 deletions

View File

@ -299,28 +299,6 @@ struct spdk_bdev_io {
/** The block device that this I/O belongs to. */
struct spdk_bdev *bdev;
/** Error information from a device */
union {
/** Only valid when status is SPDK_BDEV_IO_STATUS_NVME_ERROR */
struct {
/** NVMe status code type */
uint8_t sct;
/** NVMe status code */
uint8_t sc;
} nvme;
/** Only valid when status is SPDK_BDEV_IO_STATUS_SCSI_ERROR */
struct {
/** SCSI status code */
uint8_t sc;
/** SCSI sense key */
uint8_t sk;
/** SCSI additional sense code */
uint8_t asc;
/** SCSI additional sense code qualifier */
uint8_t ascq;
} scsi;
} error;
/** Enumerated value representing the I/O type. */
uint8_t type;
@ -379,6 +357,28 @@ struct spdk_bdev_io {
* must not read or write to these fields.
*/
struct __bdev_io_internal_fields {
/** Error information from a device */
union {
/** Only valid when status is SPDK_BDEV_IO_STATUS_NVME_ERROR */
struct {
/** NVMe status code type */
uint8_t sct;
/** NVMe status code */
uint8_t sc;
} nvme;
/** Only valid when status is SPDK_BDEV_IO_STATUS_SCSI_ERROR */
struct {
/** SCSI status code */
uint8_t sc;
/** SCSI sense key */
uint8_t sk;
/** SCSI additional sense code */
uint8_t asc;
/** SCSI additional sense code qualifier */
uint8_t ascq;
} scsi;
} error;
/** The bdev I/O channel that this was handled on. */
struct spdk_bdev_channel *ch;

View File

@ -2492,10 +2492,10 @@ spdk_bdev_io_complete_scsi_status(struct spdk_bdev_io *bdev_io, enum spdk_scsi_s
bdev_io->internal.status = SPDK_BDEV_IO_STATUS_SUCCESS;
} else {
bdev_io->internal.status = SPDK_BDEV_IO_STATUS_SCSI_ERROR;
bdev_io->error.scsi.sc = sc;
bdev_io->error.scsi.sk = sk;
bdev_io->error.scsi.asc = asc;
bdev_io->error.scsi.ascq = ascq;
bdev_io->internal.error.scsi.sc = sc;
bdev_io->internal.error.scsi.sk = sk;
bdev_io->internal.error.scsi.asc = asc;
bdev_io->internal.error.scsi.ascq = ascq;
}
spdk_bdev_io_complete(bdev_io, bdev_io->internal.status);
@ -2521,10 +2521,10 @@ spdk_bdev_io_get_scsi_status(const struct spdk_bdev_io *bdev_io,
spdk_scsi_nvme_translate(bdev_io, sc, sk, asc, ascq);
break;
case SPDK_BDEV_IO_STATUS_SCSI_ERROR:
*sc = bdev_io->error.scsi.sc;
*sk = bdev_io->error.scsi.sk;
*asc = bdev_io->error.scsi.asc;
*ascq = bdev_io->error.scsi.ascq;
*sc = bdev_io->internal.error.scsi.sc;
*sk = bdev_io->internal.error.scsi.sk;
*asc = bdev_io->internal.error.scsi.asc;
*ascq = bdev_io->internal.error.scsi.ascq;
break;
default:
*sc = SPDK_SCSI_STATUS_CHECK_CONDITION;
@ -2541,8 +2541,8 @@ spdk_bdev_io_complete_nvme_status(struct spdk_bdev_io *bdev_io, int sct, int sc)
if (sct == SPDK_NVME_SCT_GENERIC && sc == SPDK_NVME_SC_SUCCESS) {
bdev_io->internal.status = SPDK_BDEV_IO_STATUS_SUCCESS;
} else {
bdev_io->error.nvme.sct = sct;
bdev_io->error.nvme.sc = sc;
bdev_io->internal.error.nvme.sct = sct;
bdev_io->internal.error.nvme.sc = sc;
bdev_io->internal.status = SPDK_BDEV_IO_STATUS_NVME_ERROR;
}
@ -2556,8 +2556,8 @@ spdk_bdev_io_get_nvme_status(const struct spdk_bdev_io *bdev_io, int *sct, int *
assert(sc != NULL);
if (bdev_io->internal.status == SPDK_BDEV_IO_STATUS_NVME_ERROR) {
*sct = bdev_io->error.nvme.sct;
*sc = bdev_io->error.nvme.sc;
*sct = bdev_io->internal.error.nvme.sct;
*sc = bdev_io->internal.error.nvme.sc;
} else if (bdev_io->internal.status == SPDK_BDEV_IO_STATUS_SUCCESS) {
*sct = SPDK_NVME_SCT_GENERIC;
*sc = SPDK_NVME_SC_SUCCESS;

View File

@ -38,8 +38,8 @@ void
spdk_scsi_nvme_translate(const struct spdk_bdev_io *bdev_io, int *sc, int *sk,
int *asc, int *ascq)
{
int nvme_sct = bdev_io->error.nvme.sct;
int nvme_sc = bdev_io->error.nvme.sc;
int nvme_sct = bdev_io->internal.error.nvme.sct;
int nvme_sc = bdev_io->internal.error.nvme.sc;
switch (nvme_sct) {
case SPDK_NVME_SCT_GENERIC:

View File

@ -53,15 +53,15 @@ scsi_nvme_translate_test(void)
int sc, sk, asc, ascq;
/* SPDK_NVME_SCT_GENERIC */
bdev_io.error.nvme.sct = SPDK_NVME_SCT_GENERIC;
bdev_io.error.nvme.sc = SPDK_NVME_SC_ABORTED_POWER_LOSS;
bdev_io.internal.error.nvme.sct = SPDK_NVME_SCT_GENERIC;
bdev_io.internal.error.nvme.sc = SPDK_NVME_SC_ABORTED_POWER_LOSS;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_TASK_ABORTED);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_ABORTED_COMMAND);
CU_ASSERT_EQUAL(asc, SPDK_SCSI_ASC_WARNING);
CU_ASSERT_EQUAL(ascq, SPDK_SCSI_ASCQ_POWER_LOSS_EXPECTED);
bdev_io.error.nvme.sc = SPDK_NVME_SC_INVALID_NUM_SGL_DESCIRPTORS;
bdev_io.internal.error.nvme.sc = SPDK_NVME_SC_INVALID_NUM_SGL_DESCIRPTORS;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_ILLEGAL_REQUEST);
@ -69,15 +69,15 @@ scsi_nvme_translate_test(void)
CU_ASSERT_EQUAL(ascq, SPDK_SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
/* SPDK_NVME_SCT_COMMAND_SPECIFIC */
bdev_io.error.nvme.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
bdev_io.error.nvme.sc = SPDK_NVME_SC_INVALID_FORMAT;
bdev_io.internal.error.nvme.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
bdev_io.internal.error.nvme.sc = SPDK_NVME_SC_INVALID_FORMAT;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_ILLEGAL_REQUEST);
CU_ASSERT_EQUAL(asc, SPDK_SCSI_ASC_FORMAT_COMMAND_FAILED);
CU_ASSERT_EQUAL(ascq, SPDK_SCSI_ASCQ_FORMAT_COMMAND_FAILED);
bdev_io.error.nvme.sc = SPDK_NVME_SC_OVERLAPPING_RANGE;
bdev_io.internal.error.nvme.sc = SPDK_NVME_SC_OVERLAPPING_RANGE;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_ILLEGAL_REQUEST);
@ -85,15 +85,15 @@ scsi_nvme_translate_test(void)
CU_ASSERT_EQUAL(ascq, SPDK_SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
/* SPDK_NVME_SCT_MEDIA_ERROR */
bdev_io.error.nvme.sct = SPDK_NVME_SCT_MEDIA_ERROR;
bdev_io.error.nvme.sc = SPDK_NVME_SC_GUARD_CHECK_ERROR;
bdev_io.internal.error.nvme.sct = SPDK_NVME_SCT_MEDIA_ERROR;
bdev_io.internal.error.nvme.sc = SPDK_NVME_SC_GUARD_CHECK_ERROR;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_MEDIUM_ERROR);
CU_ASSERT_EQUAL(asc, SPDK_SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED);
CU_ASSERT_EQUAL(ascq, SPDK_SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED);
bdev_io.error.nvme.sc = SPDK_NVME_SC_DEALLOCATED_OR_UNWRITTEN_BLOCK;
bdev_io.internal.error.nvme.sc = SPDK_NVME_SC_DEALLOCATED_OR_UNWRITTEN_BLOCK;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_ILLEGAL_REQUEST);
@ -101,8 +101,8 @@ scsi_nvme_translate_test(void)
CU_ASSERT_EQUAL(ascq, SPDK_SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
/* SPDK_NVME_SCT_VENDOR_SPECIFIC */
bdev_io.error.nvme.sct = SPDK_NVME_SCT_VENDOR_SPECIFIC;
bdev_io.error.nvme.sc = 0xff;
bdev_io.internal.error.nvme.sct = SPDK_NVME_SCT_VENDOR_SPECIFIC;
bdev_io.internal.error.nvme.sc = 0xff;
spdk_scsi_nvme_translate(&bdev_io, &sc, &sk, &asc, &ascq);
CU_ASSERT_EQUAL(sc, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(sk, SPDK_SCSI_SENSE_ILLEGAL_REQUEST);

View File

@ -158,10 +158,10 @@ spdk_bdev_io_get_scsi_status(const struct spdk_bdev_io *bdev_io,
*ascq = SPDK_SCSI_ASCQ_CAUSE_NOT_REPORTABLE;
break;
case SPDK_BDEV_IO_STATUS_SCSI_ERROR:
*sc = bdev_io->error.scsi.sc;
*sk = bdev_io->error.scsi.sk;
*asc = bdev_io->error.scsi.asc;
*ascq = bdev_io->error.scsi.ascq;
*sc = bdev_io->internal.error.scsi.sc;
*sk = bdev_io->internal.error.scsi.sk;
*asc = bdev_io->internal.error.scsi.asc;
*ascq = bdev_io->internal.error.scsi.ascq;
break;
default:
*sc = SPDK_SCSI_STATUS_CHECK_CONDITION;
@ -596,10 +596,10 @@ task_complete_test(void)
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_GOOD);
bdev_io.internal.status = SPDK_BDEV_IO_STATUS_SCSI_ERROR;
bdev_io.error.scsi.sc = SPDK_SCSI_STATUS_CHECK_CONDITION;
bdev_io.error.scsi.sk = SPDK_SCSI_SENSE_HARDWARE_ERROR;
bdev_io.error.scsi.asc = SPDK_SCSI_ASC_WARNING;
bdev_io.error.scsi.ascq = SPDK_SCSI_ASCQ_POWER_LOSS_EXPECTED;
bdev_io.internal.error.scsi.sc = SPDK_SCSI_STATUS_CHECK_CONDITION;
bdev_io.internal.error.scsi.sk = SPDK_SCSI_SENSE_HARDWARE_ERROR;
bdev_io.internal.error.scsi.asc = SPDK_SCSI_ASC_WARNING;
bdev_io.internal.error.scsi.ascq = SPDK_SCSI_ASCQ_POWER_LOSS_EXPECTED;
spdk_bdev_scsi_task_complete_cmd(&bdev_io, bdev_io.internal.status, &task);
CU_ASSERT_EQUAL(task.status, SPDK_SCSI_STATUS_CHECK_CONDITION);
CU_ASSERT_EQUAL(task.sense_data[2] & 0xf, SPDK_SCSI_SENSE_HARDWARE_ERROR);