bdev/nvme: use non-ext IO functions if possible

Patch 55f947933 ("bdev: remove spdk_bdev_ext_io_opts from spdk_bdev_io")
changed the way bdev_nvme submits IO to the NVMe driver causing
performance degradation for requests with iovcnt = 1, as they also had
to go through the path that executes the reset_sgl/next_sge callbacks.

This patch reverts those changes back to the original code checking
iovcnt and using the non-SGL functions if possible.

Suggested-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I5e7c6620d38b7690ff862d8cd0075afacc578217
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16961
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Konrad Sztyber 2023-02-28 16:39:04 +01:00 committed by Tomasz Zawadzki
parent 584d295245
commit 07be7ca0ad
2 changed files with 47 additions and 19 deletions

View File

@ -6550,16 +6550,29 @@ bdev_nvme_readv(struct nvme_bdev_io *bio, struct iovec *iov, int iovcnt,
bio->iovpos = 0;
bio->iov_offset = 0;
bio->ext_opts.size = sizeof(struct spdk_nvme_ns_cmd_ext_io_opts);
bio->ext_opts.memory_domain = domain;
bio->ext_opts.memory_domain_ctx = domain_ctx;
bio->ext_opts.io_flags = flags;
bio->ext_opts.metadata = md;
if (domain != NULL) {
bio->ext_opts.size = sizeof(struct spdk_nvme_ns_cmd_ext_io_opts);
bio->ext_opts.memory_domain = domain;
bio->ext_opts.memory_domain_ctx = domain_ctx;
bio->ext_opts.io_flags = flags;
bio->ext_opts.metadata = md;
rc = spdk_nvme_ns_cmd_readv_ext(ns, qpair, lba, lba_count,
bdev_nvme_readv_done, bio,
bdev_nvme_queued_reset_sgl,
bdev_nvme_queued_next_sge,
&bio->ext_opts);
} else if (iovcnt == 1) {
rc = spdk_nvme_ns_cmd_read_with_md(ns, qpair, iov[0].iov_base,
md, lba, lba_count, bdev_nvme_readv_done,
bio, flags, 0, 0);
} else {
rc = spdk_nvme_ns_cmd_readv_with_md(ns, qpair, lba, lba_count,
bdev_nvme_readv_done, bio, flags,
bdev_nvme_queued_reset_sgl,
bdev_nvme_queued_next_sge, md, 0, 0);
}
rc = spdk_nvme_ns_cmd_readv_ext(ns, qpair, lba, lba_count,
bdev_nvme_readv_done, bio,
bdev_nvme_queued_reset_sgl, bdev_nvme_queued_next_sge,
&bio->ext_opts);
if (rc != 0 && rc != -ENOMEM) {
SPDK_ERRLOG("readv failed: rc = %d\n", rc);
}
@ -6583,16 +6596,29 @@ bdev_nvme_writev(struct nvme_bdev_io *bio, struct iovec *iov, int iovcnt,
bio->iovpos = 0;
bio->iov_offset = 0;
bio->ext_opts.size = sizeof(struct spdk_nvme_ns_cmd_ext_io_opts);
bio->ext_opts.memory_domain = domain;
bio->ext_opts.memory_domain_ctx = domain_ctx;
bio->ext_opts.io_flags = flags;
bio->ext_opts.metadata = md;
if (domain != NULL) {
bio->ext_opts.size = sizeof(struct spdk_nvme_ns_cmd_ext_io_opts);
bio->ext_opts.memory_domain = domain;
bio->ext_opts.memory_domain_ctx = domain_ctx;
bio->ext_opts.io_flags = flags;
bio->ext_opts.metadata = md;
rc = spdk_nvme_ns_cmd_writev_ext(ns, qpair, lba, lba_count,
bdev_nvme_writev_done, bio,
bdev_nvme_queued_reset_sgl,
bdev_nvme_queued_next_sge,
&bio->ext_opts);
} else if (iovcnt == 1) {
rc = spdk_nvme_ns_cmd_write_with_md(ns, qpair, iov[0].iov_base,
md, lba, lba_count, bdev_nvme_writev_done,
bio, flags, 0, 0);
} else {
rc = spdk_nvme_ns_cmd_writev_with_md(ns, qpair, lba, lba_count,
bdev_nvme_writev_done, bio, flags,
bdev_nvme_queued_reset_sgl,
bdev_nvme_queued_next_sge, md, 0, 0);
}
rc = spdk_nvme_ns_cmd_writev_ext(ns, qpair, lba, lba_count,
bdev_nvme_writev_done, bio,
bdev_nvme_queued_reset_sgl, bdev_nvme_queued_next_sge,
&bio->ext_opts);
if (rc != 0 && rc != -ENOMEM) {
SPDK_ERRLOG("writev failed: rc = %d\n", rc);
}

View File

@ -2363,11 +2363,13 @@ test_submit_nvme_cmd(void)
ut_test_submit_fused_nvme_cmd(ch, bdev_io);
/* Verify that ext NVME API is called */
/* Verify that ext NVME API is called when data is described by memory domain */
g_ut_readv_ext_called = false;
bdev_io->u.bdev.memory_domain = (void *)0xdeadbeef;
ut_test_submit_nvme_cmd(ch, bdev_io, SPDK_BDEV_IO_TYPE_READ);
CU_ASSERT(g_ut_readv_ext_called == true);
g_ut_readv_ext_called = false;
bdev_io->u.bdev.memory_domain = NULL;
ut_test_submit_admin_cmd(ch, bdev_io, ctrlr);