Commit e90d1a81 authored by Jim Harris's avatar Jim Harris
Browse files

ublk: request proper sized buffers from iobuf



Previously ublk just always allocated 64KB buffers,
regardless of the actual IO size.  But now that we
are using the iobuf pools, we want to request the
properly sized buffers, since there are many more
small (8KB or less) buffers than the larger buffers.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ia30b2b391fd40fe303aeff6e8529eae560879fb1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17927


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent e12c82ed
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -862,10 +862,12 @@ static void
ublk_io_get_buffer(struct ublk_io *io, struct spdk_iobuf_channel *iobuf_ch,
		   ublk_get_buf_cb get_buf_cb)
{
	uint64_t io_size;
	void *buf;

	io_size = io->iod->nr_sectors * (1ULL << LINUX_SECTOR_SHIFT);
	io->get_buf_cb = get_buf_cb;
	buf = spdk_iobuf_get(iobuf_ch, UBLK_IO_MAX_BYTES, &io->iobuf, ublk_io_get_buffer_cb);
	buf = spdk_iobuf_get(iobuf_ch, io_size, &io->iobuf, ublk_io_get_buffer_cb);
	if (buf != NULL) {
		ublk_io_get_buffer_cb(&io->iobuf, buf);
	}
@@ -874,8 +876,11 @@ ublk_io_get_buffer(struct ublk_io *io, struct spdk_iobuf_channel *iobuf_ch,
static void
ublk_io_put_buffer(struct ublk_io *io, struct spdk_iobuf_channel *iobuf_ch)
{
	uint64_t io_size;

	if (io->payload) {
		spdk_iobuf_put(iobuf_ch, io->mpool_entry, UBLK_IO_MAX_BYTES);
		io_size = io->iod->nr_sectors * (1ULL << LINUX_SECTOR_SHIFT);
		spdk_iobuf_put(iobuf_ch, io->mpool_entry, io_size);
		io->mpool_entry = NULL;
		io->payload = NULL;
	}