Skip to content

Commit

Permalink
fix(bs): correctly passing additional I/O flags to blob store
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Jul 11, 2023
1 parent 45c4b74 commit 4b3b937
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
6 changes: 4 additions & 2 deletions include/spdk/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,12 @@ void spdk_blob_io_writev(struct spdk_blob *blob, struct spdk_io_channel *channel
* \param iovcnt The number of buffers.
* \param offset Offset is in io units from the beginning of the blob.
* \param length Size of data in io units.
* \param ext_io_flags Additional I/O flags.
* \param cb_fn Called when the operation is complete.
* \param cb_arg Argument passed to function cb_fn.
*/
void spdk_blob_io_readv(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg);

/**
Expand Down Expand Up @@ -888,12 +889,13 @@ void spdk_blob_io_writev_ext(struct spdk_blob *blob, struct spdk_io_channel *cha
* \param iovcnt The number of buffers.
* \param offset Offset is in io units from the beginning of the blob.
* \param length Size of data in io units.
* \param ext_io_flags Additional I/O flags.
* \param cb_fn Called when the operation is complete.
* \param cb_arg Argument passed to function cb_fn.
* \param io_opts Optional extended IO request options
*/
void spdk_blob_io_readv_ext(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg,
struct spdk_blob_ext_io_opts *io_opts);

Expand Down
10 changes: 10 additions & 0 deletions lib/bdev/bdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4872,6 +4872,7 @@ bdev_write_blocks_with_md(struct spdk_bdev_desc *desc, struct spdk_io_channel *c
bdev_io->u.bdev.num_blocks = num_blocks;
bdev_io->u.bdev.offset_blocks = offset_blocks;
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;
bdev_io_init(bdev_io, bdev, cb_arg, cb);

bdev_io_submit(bdev_io);
Expand Down Expand Up @@ -4958,6 +4959,7 @@ bdev_writev_blocks_with_md(struct spdk_bdev_desc *desc, struct spdk_io_channel *
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->internal.ext_opts = opts;
bdev_io->u.bdev.ext_opts = opts;
bdev_io->u.bdev.ext_io_flags = 0;

_bdev_io_submit_ext(desc, bdev_io, opts, copy_opts);

Expand Down Expand Up @@ -5126,6 +5128,7 @@ bdev_comparev_blocks_with_md(struct spdk_bdev_desc *desc, struct spdk_io_channel
bdev_io->u.bdev.offset_blocks = offset_blocks;
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

if (bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_COMPARE)) {
bdev_io_submit(bdev_io);
Expand Down Expand Up @@ -5195,6 +5198,7 @@ bdev_compare_blocks_with_md(struct spdk_bdev_desc *desc, struct spdk_io_channel
bdev_io->u.bdev.offset_blocks = offset_blocks;
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

if (bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_COMPARE)) {
bdev_io_submit(bdev_io);
Expand Down Expand Up @@ -5381,6 +5385,7 @@ spdk_bdev_comparev_and_writev_blocks(struct spdk_bdev_desc *desc, struct spdk_io
bdev_io->u.bdev.offset_blocks = offset_blocks;
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

if (bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_COMPARE_AND_WRITE)) {
bdev_io_submit(bdev_io);
Expand Down Expand Up @@ -5432,6 +5437,7 @@ spdk_bdev_zcopy_start(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
bdev_io->u.bdev.zcopy.start = 1;
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

bdev_io_submit(bdev_io);

Expand Down Expand Up @@ -5507,6 +5513,7 @@ spdk_bdev_write_zeroes_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channe
bdev_io->u.bdev.num_blocks = num_blocks;
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

if (bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_WRITE_ZEROES)) {
bdev_io_submit(bdev_io);
Expand Down Expand Up @@ -5577,6 +5584,7 @@ spdk_bdev_unmap_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
bdev_io->u.bdev.num_blocks = num_blocks;
bdev_io_init(bdev_io, bdev, cb_arg, cb);
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

bdev_io_submit(bdev_io);
return 0;
Expand Down Expand Up @@ -8624,6 +8632,8 @@ spdk_bdev_copy_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
bdev_io->u.bdev.copy.src_offset_blocks = src_offset_blocks;
bdev_io->u.bdev.num_blocks = num_blocks;
bdev_io->u.bdev.ext_opts = NULL;
bdev_io->u.bdev.ext_io_flags = 0;

bdev_io_init(bdev_io, bdev, cb_arg, cb);

bdev_io_submit(bdev_io);
Expand Down
4 changes: 2 additions & 2 deletions lib/blob/blob_bs_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ blob_bs_dev_readv(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
{
struct spdk_blob_bs_dev *b = (struct spdk_blob_bs_dev *)dev;

spdk_blob_io_readv(b->blob, channel, iov, iovcnt, lba, lba_count,
spdk_blob_io_readv(b->blob, channel, iov, iovcnt, lba, lba_count, 0,
blob_bs_dev_read_cpl, cb_args);
}

Expand All @@ -94,7 +94,7 @@ blob_bs_dev_readv_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
{
struct spdk_blob_bs_dev *b = (struct spdk_blob_bs_dev *)dev;

spdk_blob_io_readv_ext(b->blob, channel, iov, iovcnt, lba, lba_count,
spdk_blob_io_readv_ext(b->blob, channel, iov, iovcnt, lba, lba_count, 0,
blob_bs_dev_read_cpl, cb_args, ext_opts);
}

Expand Down
22 changes: 11 additions & 11 deletions lib/blob/blobstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -3015,7 +3015,7 @@ rw_iov_split_next(void *cb_arg, int bserrno)

if (ctx->read) {
spdk_blob_io_readv_ext(ctx->blob, ctx->channel, iov, iovcnt, io_unit_offset,
io_units_count, rw_iov_split_next, ctx, ctx->ext_io_opts);
io_units_count, 0, rw_iov_split_next, ctx, ctx->ext_io_opts);
} else {
spdk_blob_io_writev_ext(ctx->blob, ctx->channel, iov, iovcnt, io_unit_offset,
io_units_count, rw_iov_split_next, ctx, ctx->ext_io_opts);
Expand All @@ -3025,11 +3025,11 @@ rw_iov_split_next(void *cb_arg, int bserrno)
static void
blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_channel,
struct iovec *iov, int iovcnt,
uint64_t offset, uint64_t length, spdk_blob_op_complete cb_fn, void *cb_arg, bool read,
uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg, bool read,
struct spdk_blob_ext_io_opts *ext_io_opts)
{
struct spdk_bs_cpl cpl;
struct spdk_bdev_io *bdev_io = cb_arg;

assert(blob != NULL);

Expand Down Expand Up @@ -3094,7 +3094,7 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan
if (read) {
spdk_bs_sequence_t *seq;

if (bdev_io->u.bdev.ext_io_flags & SPDK_NVME_IO_FLAGS_UNWRITTEN_READ_FAIL) {
if (ext_io_flags & SPDK_NVME_IO_FLAGS_UNWRITTEN_READ_FAIL) {
if (!is_allocated) {
/* ETXTBSY was chosen to indicate read of unwritten block.
* It is not used by SPDK, so it should be fine. */
Expand Down Expand Up @@ -3149,7 +3149,7 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan
} else {
struct rw_iov_ctx *ctx;

assert(!(bdev_io->u.bdev.ext_io_flags & SPDK_NVME_IO_FLAGS_UNWRITTEN_READ_FAIL));
assert(ext_io_flags == 0);

ctx = calloc(1, sizeof(struct rw_iov_ctx) + iovcnt * sizeof(struct iovec));
if (ctx == NULL) {
Expand Down Expand Up @@ -7845,32 +7845,32 @@ spdk_blob_io_writev(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
spdk_blob_op_complete cb_fn, void *cb_arg)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, cb_fn, cb_arg, false, NULL);
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, 0, cb_fn, cb_arg, false, NULL);
}

void
spdk_blob_io_readv(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, cb_fn, cb_arg, true, NULL);
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, ext_io_flags, cb_fn, cb_arg, true, NULL);
}

void
spdk_blob_io_writev_ext(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
spdk_blob_op_complete cb_fn, void *cb_arg, struct spdk_blob_ext_io_opts *io_opts)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, cb_fn, cb_arg, false,
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, 0, cb_fn, cb_arg, false,
io_opts);
}

void
spdk_blob_io_readv_ext(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg, struct spdk_blob_ext_io_opts *io_opts)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, cb_fn, cb_arg, true,
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, ext_io_flags, cb_fn, cb_arg, true,
io_opts);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/blob/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ bs_user_op_execute(spdk_bs_user_op_t *op)
break;
case SPDK_BLOB_READV:
spdk_blob_io_readv_ext(args->blob, ch, args->payload, args->iovcnt,
args->offset, args->length,
args->offset, args->length, 0,
set->cpl.u.blob_basic.cb_fn, set->cpl.u.blob_basic.cb_arg,
set->ext_io_opts);
break;
Expand Down
5 changes: 3 additions & 2 deletions module/bdev/lvol/vbdev_lvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,11 @@ lvol_read(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
lvol_io->ext_io_opts.user_ctx = bdev_io->u.bdev.ext_opts;

spdk_blob_io_readv_ext(blob, ch, bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, start_page,
num_pages, lvol_op_comp, bdev_io, &lvol_io->ext_io_opts);
num_pages, bdev_io->u.bdev.ext_io_flags, lvol_op_comp, bdev_io,
&lvol_io->ext_io_opts);
} else {
spdk_blob_io_readv(blob, ch, bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, start_page,
num_pages, lvol_op_comp, bdev_io);
num_pages, bdev_io->u.bdev.ext_io_flags, lvol_op_comp, bdev_io);
}
}

Expand Down

0 comments on commit 4b3b937

Please sign in to comment.