bdev/nvme: avoid spdk_bdev_io_get_buf call when possible

The bdev layer nicely handles the case where we call this
function with the buffers already present - it just
immediately calls the get_buf_cb.  But this adds extra
overhead in the case where the buffer is already present.
Since nvme has no alignment restrictions, we can just
check the iovs directly and avoid the extra call to
spdk_bdev_io_get_buf when possible.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I66df0fde574a35e995a3432999d75bdbf9b27212
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4317
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jim Harris 2020-09-18 17:38:27 +00:00 committed by Tomasz Zawadzki
parent c1bfc56488
commit acfb968aa8

View File

@ -574,8 +574,12 @@ _bdev_nvme_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_
switch (bdev_io->type) {
case SPDK_BDEV_IO_TYPE_READ:
spdk_bdev_io_get_buf(bdev_io, bdev_nvme_get_buf_cb,
bdev_io->u.bdev.num_blocks * bdev_io->bdev->blocklen);
if (bdev_io->u.bdev.iovs && bdev_io->u.bdev.iovs[0].iov_base) {
bdev_nvme_get_buf_cb(ch, bdev_io, true);
} else {
spdk_bdev_io_get_buf(bdev_io, bdev_nvme_get_buf_cb,
bdev_io->u.bdev.num_blocks * bdev_io->bdev->blocklen);
}
return 0;
case SPDK_BDEV_IO_TYPE_WRITE: