fio_plugin: don't submit the IO if got DIF context error

Also set the errno for submitting and verification path.

Change-Id: I97e94eb3c63167eed2f0b14fa7b79c42add834a1
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447558
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Changpeng Liu 2019-03-10 20:17:33 -04:00 committed by Jim Harris
parent 3fc824c834
commit 5a051a6c1b

View File

@ -528,7 +528,7 @@ static void spdk_fio_io_u_free(struct thread_data *td, struct io_u *io_u)
} }
} }
static void static int
fio_extended_lba_setup_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u) fio_extended_lba_setup_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
{ {
struct spdk_nvme_ns *ns = fio_qpair->ns; struct spdk_nvme_ns *ns = fio_qpair->ns;
@ -549,11 +549,7 @@ fio_extended_lba_setup_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
fio_qpair->io_flags, lba, 0xFFFF, FIO_NVME_PI_APPTAG, 0); fio_qpair->io_flags, lba, 0xFFFF, FIO_NVME_PI_APPTAG, 0);
if (rc != 0) { if (rc != 0) {
fprintf(stderr, "Initialization of DIF context failed\n"); fprintf(stderr, "Initialization of DIF context failed\n");
return; return rc;
}
if (io_u->ddir != DDIR_WRITE) {
return;
} }
iov.iov_base = io_u->buf; iov.iov_base = io_u->buf;
@ -562,9 +558,11 @@ fio_extended_lba_setup_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
if (rc != 0) { if (rc != 0) {
fprintf(stderr, "Generation of DIF failed\n"); fprintf(stderr, "Generation of DIF failed\n");
} }
return rc;
} }
static void static int
fio_extended_lba_verify_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u) fio_extended_lba_verify_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
{ {
struct spdk_nvme_ns *ns = fio_qpair->ns; struct spdk_nvme_ns *ns = fio_qpair->ns;
@ -574,10 +572,6 @@ fio_extended_lba_verify_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
struct spdk_dif_error err_blk = {}; struct spdk_dif_error err_blk = {};
int rc; int rc;
if (io_u->ddir != DDIR_READ) {
return;
}
iov.iov_base = io_u->buf; iov.iov_base = io_u->buf;
iov.iov_len = io_u->xfer_buflen; iov.iov_len = io_u->xfer_buflen;
lba_count = io_u->xfer_buflen / spdk_nvme_ns_get_extended_sector_size(ns); lba_count = io_u->xfer_buflen / spdk_nvme_ns_get_extended_sector_size(ns);
@ -587,6 +581,8 @@ fio_extended_lba_verify_pi(struct spdk_fio_qpair *fio_qpair, struct io_u *io_u)
fprintf(stderr, "DIF error detected. type=%d, offset=%" PRIu32 "\n", fprintf(stderr, "DIF error detected. type=%d, offset=%" PRIu32 "\n",
err_blk.err_type, err_blk.err_offset); err_blk.err_type, err_blk.err_offset);
} }
return rc;
} }
static void spdk_fio_completion_cb(void *ctx, const struct spdk_nvme_cpl *cpl) static void spdk_fio_completion_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
@ -594,9 +590,13 @@ static void spdk_fio_completion_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
struct spdk_fio_request *fio_req = ctx; struct spdk_fio_request *fio_req = ctx;
struct spdk_fio_thread *fio_thread = fio_req->fio_thread; struct spdk_fio_thread *fio_thread = fio_req->fio_thread;
struct spdk_fio_qpair *fio_qpair = fio_req->fio_qpair; struct spdk_fio_qpair *fio_qpair = fio_req->fio_qpair;
int rc;
if (fio_qpair->do_nvme_pi) { if (fio_qpair->do_nvme_pi && fio_req->io->ddir == DDIR_READ) {
fio_extended_lba_verify_pi(fio_qpair, fio_req->io); rc = fio_extended_lba_verify_pi(fio_qpair, fio_req->io);
if (rc != 0) {
fio_req->io->error = abs(rc);
}
} }
assert(fio_thread->iocq_count < fio_thread->iocq_size); assert(fio_thread->iocq_count < fio_thread->iocq_size);
@ -668,8 +668,12 @@ spdk_fio_queue(struct thread_data *td, struct io_u *io_u)
lba_count = io_u->xfer_buflen / block_size; lba_count = io_u->xfer_buflen / block_size;
/* TODO: considering situations that fio will randomize and verify io_u */ /* TODO: considering situations that fio will randomize and verify io_u */
if (fio_qpair->do_nvme_pi) { if (fio_qpair->do_nvme_pi && io_u->ddir == DDIR_WRITE) {
fio_extended_lba_setup_pi(fio_qpair, io_u); rc = fio_extended_lba_setup_pi(fio_qpair, io_u);
if (rc < 0) {
io_u->error = -rc;
return FIO_Q_COMPLETED;
}
} }
switch (io_u->ddir) { switch (io_u->ddir) {
@ -708,7 +712,8 @@ spdk_fio_queue(struct thread_data *td, struct io_u *io_u)
} }
if (rc != 0) { if (rc != 0) {
return -abs(rc); io_u->error = abs(rc);
return FIO_Q_COMPLETED;
} }
return FIO_Q_QUEUED; return FIO_Q_QUEUED;