Commit 7f45a126 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

lib/ftl: use iovecs instead of single data pointer



Allow ftl_io initialization with a iovec array instead of a single data
pointer.  It'll make it possible to use the vector version of the IO
commands.

Change-Id: I34c1e398cea681f59321605e081366785aa29128
Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/894


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarMaciej Szczepaniak <maciej.szczepaniak@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a4b7f495
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -705,7 +705,13 @@ ftl_io_init_md_read(struct spdk_ftl_dev *dev, struct ftl_addr addr,
		.type		= FTL_IO_READ,
		.num_blocks	= num_blocks,
		.cb_fn		= fn,
		.data		= buf,
		.iovs		= {
			{
				.iov_base = buf,
				.iov_len = num_blocks * FTL_BLOCK_SIZE,
			}
		},
		.iovcnt		= 1,
	};

	io = (struct ftl_md_io *)ftl_io_init_internal(&opts);
@@ -735,7 +741,13 @@ ftl_io_init_md_write(struct spdk_ftl_dev *dev, struct ftl_band *band,
		.type		= FTL_IO_WRITE,
		.num_blocks	= num_blocks,
		.cb_fn		= cb,
		.data		= data,
		.iovs		= {
			{
				.iov_base = data,
				.iov_len = num_blocks * FTL_BLOCK_SIZE,
			}
		},
		.iovcnt		= 1,
		.md		= NULL,
	};

+14 −2
Original line number Diff line number Diff line
@@ -1183,7 +1183,13 @@ ftl_alloc_io_nv_cache(struct ftl_io *parent, size_t num_blocks)
	struct ftl_io_init_opts opts = {
		.dev		= parent->dev,
		.parent		= parent,
		.data		= ftl_io_iovec_addr(parent),
		.iovs		= {
			{
				.iov_base = ftl_io_iovec_addr(parent),
				.iov_len = num_blocks * FTL_BLOCK_SIZE,
			}
		},
		.iovcnt		= 1,
		.num_blocks	= num_blocks,
		.flags		= parent->flags | FTL_IO_CACHE,
	};
@@ -1530,7 +1536,13 @@ ftl_io_init_child_write(struct ftl_io *parent, struct ftl_addr addr,
		.type		= parent->type,
		.num_blocks	= dev->xfer_size,
		.cb_fn		= cb,
		.data		= data,
		.iovs		= {
			{
				.iov_base = data,
				.iov_len = dev->xfer_size * FTL_BLOCK_SIZE,
			}
		},
		.iovcnt		= 1,
		.md		= md,
	};

+9 −7
Original line number Diff line number Diff line
@@ -275,10 +275,6 @@ ftl_io_init_internal(const struct ftl_io_init_opts *opts)
	struct ftl_io *io = opts->io;
	struct ftl_io *parent = opts->parent;
	struct spdk_ftl_dev *dev = opts->dev;
	struct iovec iov = {
		.iov_base = opts->data,
		.iov_len  = opts->num_blocks * FTL_BLOCK_SIZE
	};

	if (!io) {
		if (parent) {
@@ -307,7 +303,7 @@ ftl_io_init_internal(const struct ftl_io_init_opts *opts)
		}
	}

	if (ftl_io_init_iovec(io, &iov, 1, opts->num_blocks)) {
	if (ftl_io_init_iovec(io, opts->iovs, opts->iovcnt, opts->num_blocks)) {
		if (!opts->io) {
			ftl_io_free(io);
		}
@@ -340,7 +336,13 @@ ftl_io_rwb_init(struct spdk_ftl_dev *dev, struct ftl_addr addr, struct ftl_band
		.type		= FTL_IO_WRITE,
		.num_blocks	= dev->xfer_size,
		.cb_fn		= cb,
		.data		= ftl_rwb_batch_get_data(batch),
		.iovs		= {
			{
				.iov_base = ftl_rwb_batch_get_data(batch),
				.iov_len = dev->xfer_size * FTL_BLOCK_SIZE,
			}
		},
		.iovcnt		= 1,
		.md		= ftl_rwb_batch_get_md(batch),
	};

@@ -368,7 +370,7 @@ ftl_io_erase_init(struct ftl_band *band, size_t num_blocks, ftl_io_fn cb)
		.type		= FTL_IO_ERASE,
		.num_blocks	= 1,
		.cb_fn		= cb,
		.data		= NULL,
		.iovcnt		= 0,
		.md		= NULL,
	};

+4 −2
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ enum ftl_io_type {
	FTL_IO_ERASE,
};

#define FTL_IO_MAX_IOVEC 64

struct ftl_io_init_opts {
	struct spdk_ftl_dev			*dev;

@@ -109,7 +111,8 @@ struct ftl_io_init_opts {
	size_t                                  num_blocks;

	/* Data */
	void                                    *data;
	struct iovec				iovs[FTL_IO_MAX_IOVEC];
	int					iovcnt;

	/* Metadata */
	void                                    *md;
@@ -164,7 +167,6 @@ struct ftl_io {
	/* Number of blocks */
	size_t					num_blocks;

#define FTL_IO_MAX_IOVEC 64
	struct iovec				iov[FTL_IO_MAX_IOVEC];

	/* Metadata */
+7 −1
Original line number Diff line number Diff line
@@ -433,7 +433,13 @@ ftl_reloc_io_init(struct ftl_band_reloc *breloc, struct ftl_reloc_move *move,
		.flags		= flags | FTL_IO_INTERNAL | FTL_IO_PHYSICAL_MODE,
		.type		= io_type,
		.num_blocks	= move->num_blocks,
		.data		= move->data,
		.iovs		= {
			{
				.iov_base = move->data,
				.iov_len = move->num_blocks * FTL_BLOCK_SIZE,
			}
		},
		.iovcnt		= 1,
		.cb_fn		= fn,
	};

Loading