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: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/894 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Maciej Szczepaniak <maciej.szczepaniak@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
a4b7f495f2
commit
7f45a12636
@ -705,7 +705,13 @@ ftl_io_init_md_read(struct spdk_ftl_dev *dev, struct ftl_addr addr,
|
|||||||
.type = FTL_IO_READ,
|
.type = FTL_IO_READ,
|
||||||
.num_blocks = num_blocks,
|
.num_blocks = num_blocks,
|
||||||
.cb_fn = fn,
|
.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);
|
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,
|
.type = FTL_IO_WRITE,
|
||||||
.num_blocks = num_blocks,
|
.num_blocks = num_blocks,
|
||||||
.cb_fn = cb,
|
.cb_fn = cb,
|
||||||
.data = data,
|
.iovs = {
|
||||||
|
{
|
||||||
|
.iov_base = data,
|
||||||
|
.iov_len = num_blocks * FTL_BLOCK_SIZE,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.iovcnt = 1,
|
||||||
.md = NULL,
|
.md = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1183,7 +1183,13 @@ ftl_alloc_io_nv_cache(struct ftl_io *parent, size_t num_blocks)
|
|||||||
struct ftl_io_init_opts opts = {
|
struct ftl_io_init_opts opts = {
|
||||||
.dev = parent->dev,
|
.dev = parent->dev,
|
||||||
.parent = parent,
|
.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,
|
.num_blocks = num_blocks,
|
||||||
.flags = parent->flags | FTL_IO_CACHE,
|
.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,
|
.type = parent->type,
|
||||||
.num_blocks = dev->xfer_size,
|
.num_blocks = dev->xfer_size,
|
||||||
.cb_fn = cb,
|
.cb_fn = cb,
|
||||||
.data = data,
|
.iovs = {
|
||||||
|
{
|
||||||
|
.iov_base = data,
|
||||||
|
.iov_len = dev->xfer_size * FTL_BLOCK_SIZE,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.iovcnt = 1,
|
||||||
.md = md,
|
.md = md,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -275,10 +275,6 @@ ftl_io_init_internal(const struct ftl_io_init_opts *opts)
|
|||||||
struct ftl_io *io = opts->io;
|
struct ftl_io *io = opts->io;
|
||||||
struct ftl_io *parent = opts->parent;
|
struct ftl_io *parent = opts->parent;
|
||||||
struct spdk_ftl_dev *dev = opts->dev;
|
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 (!io) {
|
||||||
if (parent) {
|
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) {
|
if (!opts->io) {
|
||||||
ftl_io_free(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,
|
.type = FTL_IO_WRITE,
|
||||||
.num_blocks = dev->xfer_size,
|
.num_blocks = dev->xfer_size,
|
||||||
.cb_fn = cb,
|
.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),
|
.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,
|
.type = FTL_IO_ERASE,
|
||||||
.num_blocks = 1,
|
.num_blocks = 1,
|
||||||
.cb_fn = cb,
|
.cb_fn = cb,
|
||||||
.data = NULL,
|
.iovcnt = 0,
|
||||||
.md = NULL,
|
.md = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@ enum ftl_io_type {
|
|||||||
FTL_IO_ERASE,
|
FTL_IO_ERASE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FTL_IO_MAX_IOVEC 64
|
||||||
|
|
||||||
struct ftl_io_init_opts {
|
struct ftl_io_init_opts {
|
||||||
struct spdk_ftl_dev *dev;
|
struct spdk_ftl_dev *dev;
|
||||||
|
|
||||||
@ -109,7 +111,8 @@ struct ftl_io_init_opts {
|
|||||||
size_t num_blocks;
|
size_t num_blocks;
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
void *data;
|
struct iovec iovs[FTL_IO_MAX_IOVEC];
|
||||||
|
int iovcnt;
|
||||||
|
|
||||||
/* Metadata */
|
/* Metadata */
|
||||||
void *md;
|
void *md;
|
||||||
@ -164,7 +167,6 @@ struct ftl_io {
|
|||||||
/* Number of blocks */
|
/* Number of blocks */
|
||||||
size_t num_blocks;
|
size_t num_blocks;
|
||||||
|
|
||||||
#define FTL_IO_MAX_IOVEC 64
|
|
||||||
struct iovec iov[FTL_IO_MAX_IOVEC];
|
struct iovec iov[FTL_IO_MAX_IOVEC];
|
||||||
|
|
||||||
/* Metadata */
|
/* Metadata */
|
||||||
|
@ -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,
|
.flags = flags | FTL_IO_INTERNAL | FTL_IO_PHYSICAL_MODE,
|
||||||
.type = io_type,
|
.type = io_type,
|
||||||
.num_blocks = move->num_blocks,
|
.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,
|
.cb_fn = fn,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -706,7 +706,13 @@ ftl_nv_cache_alloc_io(struct ftl_nv_cache_block *block, uint64_t lba)
|
|||||||
.num_blocks = 1,
|
.num_blocks = 1,
|
||||||
.cb_fn = ftl_nv_cache_write_cb,
|
.cb_fn = ftl_nv_cache_write_cb,
|
||||||
.cb_ctx = block,
|
.cb_ctx = block,
|
||||||
.data = block->buf,
|
.iovs = {
|
||||||
|
{
|
||||||
|
.iov_base = block->buf,
|
||||||
|
.iov_len = FTL_BLOCK_SIZE,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.iovcnt = 1,
|
||||||
};
|
};
|
||||||
struct ftl_io *io;
|
struct ftl_io *io;
|
||||||
|
|
||||||
@ -1136,7 +1142,13 @@ ftl_restore_init_pad_io(struct ftl_restore_band *rband, void *buffer,
|
|||||||
.num_blocks = dev->xfer_size,
|
.num_blocks = dev->xfer_size,
|
||||||
.cb_fn = ftl_pad_zone_cb,
|
.cb_fn = ftl_pad_zone_cb,
|
||||||
.cb_ctx = rband,
|
.cb_ctx = rband,
|
||||||
.data = buffer,
|
.iovs = {
|
||||||
|
{
|
||||||
|
.iov_base = buffer,
|
||||||
|
.iov_len = dev->xfer_size * FTL_BLOCK_SIZE,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.iovcnt = 1,
|
||||||
.parent = NULL,
|
.parent = NULL,
|
||||||
};
|
};
|
||||||
struct ftl_io *io;
|
struct ftl_io *io;
|
||||||
|
@ -143,7 +143,8 @@ ftl_io_init_internal(const struct ftl_io_init_opts *opts)
|
|||||||
io->cb_fn = opts->cb_fn;
|
io->cb_fn = opts->cb_fn;
|
||||||
io->cb_ctx = io;
|
io->cb_ctx = io;
|
||||||
io->num_blocks = opts->num_blocks;
|
io->num_blocks = opts->num_blocks;
|
||||||
io->iov[0].iov_base = opts->data;
|
memcpy(&io->iov, &opts->iovs, sizeof(io->iov));
|
||||||
|
io->iov_cnt = opts->iovcnt;
|
||||||
|
|
||||||
if (opts->flags & FTL_IO_VECTOR_LBA) {
|
if (opts->flags & FTL_IO_VECTOR_LBA) {
|
||||||
io->lba.vector = calloc(io->num_blocks, sizeof(uint64_t));
|
io->lba.vector = calloc(io->num_blocks, sizeof(uint64_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user