From 4b3b937d1f0903d41c1252459b7578a2fcb00bee Mon Sep 17 00:00:00 2001 From: Dmitry Savitskiy Date: Tue, 11 Jul 2023 16:38:31 +0300 Subject: [PATCH] fix(bs): correctly passing additional I/O flags to blob store Signed-off-by: Dmitry Savitskiy --- include/spdk/blob.h | 6 ++++-- lib/bdev/bdev.c | 10 ++++++++++ lib/blob/blob_bs_dev.c | 4 ++-- lib/blob/blobstore.c | 22 +++++++++++----------- lib/blob/request.c | 2 +- module/bdev/lvol/vbdev_lvol.c | 5 +++-- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/spdk/blob.h b/include/spdk/blob.h index 903c2738103..e955987a351 100644 --- a/include/spdk/blob.h +++ b/include/spdk/blob.h @@ -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); /** @@ -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); diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 9c407b34d18..ac766f84463 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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; @@ -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); diff --git a/lib/blob/blob_bs_dev.c b/lib/blob/blob_bs_dev.c index eae2ae87f9b..6c18e275d38 100644 --- a/lib/blob/blob_bs_dev.c +++ b/lib/blob/blob_bs_dev.c @@ -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); } @@ -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); } diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 423094a7502..05f5081ad7b 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -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); @@ -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); @@ -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. */ @@ -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) { @@ -7845,15 +7845,15 @@ 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 @@ -7861,16 +7861,16 @@ 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); } diff --git a/lib/blob/request.c b/lib/blob/request.c index bd4d32825e6..d4d3a7acde5 100644 --- a/lib/blob/request.c +++ b/lib/blob/request.c @@ -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; diff --git a/module/bdev/lvol/vbdev_lvol.c b/module/bdev/lvol/vbdev_lvol.c index f3a6bf0eac1..c3ebb0d8d0f 100644 --- a/module/bdev/lvol/vbdev_lvol.c +++ b/module/bdev/lvol/vbdev_lvol.c @@ -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); } }