From 8f424ed8f63b0ff21ecdaa3ea2756bfece7ce24d Mon Sep 17 00:00:00 2001 From: Krzysztof Smolinski Date: Wed, 19 Oct 2022 15:03:38 +0200 Subject: [PATCH] raid1: io metadata support Signed-off-by: Krzysztof Smolinski Change-Id: I53a57f85d94110365492d457715f8a8bc1194628 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15127 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Reviewed-by: Artur Paszkiewicz --- module/bdev/raid/raid1.c | 32 ++++++++++++++++------ test/unit/lib/bdev/raid/raid1.c/raid1_ut.c | 16 +++++------ 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/module/bdev/raid/raid1.c b/module/bdev/raid/raid1.c index f08a81d79..cfe1e6b8e 100644 --- a/module/bdev/raid/raid1.c +++ b/module/bdev/raid/raid1.c @@ -51,10 +51,18 @@ raid1_submit_read_request(struct raid_bdev_io *raid_io) raid_io->base_bdev_io_remaining = 1; - ret = spdk_bdev_readv_blocks(base_info->desc, base_ch, - bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, - pd_lba, pd_blocks, - raid1_bdev_io_completion, raid_io); + if (bdev_io->u.bdev.ext_opts != NULL) { + ret = spdk_bdev_readv_blocks_ext(base_info->desc, base_ch, + bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, + pd_lba, pd_blocks, raid1_bdev_io_completion, + raid_io, bdev_io->u.bdev.ext_opts); + } else { + ret = spdk_bdev_readv_blocks_with_md(base_info->desc, base_ch, + bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, + bdev_io->u.bdev.md_buf, + pd_lba, pd_blocks, + raid1_bdev_io_completion, raid_io); + } if (spdk_likely(ret == 0)) { raid_io->base_bdev_io_submitted++; @@ -90,10 +98,18 @@ raid1_submit_write_request(struct raid_bdev_io *raid_io) base_info = &raid_bdev->base_bdev_info[idx]; base_ch = raid_io->raid_ch->base_channel[idx]; - ret = spdk_bdev_writev_blocks(base_info->desc, base_ch, - bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, - pd_lba, pd_blocks, - raid1_bdev_io_completion, raid_io); + if (bdev_io->u.bdev.ext_opts != NULL) { + ret = spdk_bdev_writev_blocks_ext(base_info->desc, base_ch, + bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, + pd_lba, pd_blocks, raid1_bdev_io_completion, + raid_io, bdev_io->u.bdev.ext_opts); + } else { + ret = spdk_bdev_writev_blocks_with_md(base_info->desc, base_ch, + bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt, + bdev_io->u.bdev.md_buf, + pd_lba, pd_blocks, + raid1_bdev_io_completion, raid_io); + } if (spdk_unlikely(ret != 0)) { if (spdk_unlikely(ret == -ENOMEM)) { diff --git a/test/unit/lib/bdev/raid/raid1.c/raid1_ut.c b/test/unit/lib/bdev/raid/raid1.c/raid1_ut.c index 158cab0d8..4b4ff2a6d 100644 --- a/test/unit/lib/bdev/raid/raid1.c/raid1_ut.c +++ b/test/unit/lib/bdev/raid/raid1.c/raid1_ut.c @@ -19,24 +19,24 @@ DEFINE_STUB(raid_bdev_io_complete_part, bool, (struct raid_bdev_io *raid_io, uin DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *bdev_io)); DEFINE_STUB_V(raid_bdev_queue_io_wait, (struct raid_bdev_io *raid_io, struct spdk_bdev *bdev, struct spdk_io_channel *ch, spdk_bdev_io_wait_cb cb_fn)); -DEFINE_STUB(spdk_bdev_readv_blocks, int, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, - struct iovec *iov, int iovcnt, - uint64_t offset_blocks, uint64_t num_blocks, - spdk_bdev_io_completion_cb cb, void *cb_arg), 0); DEFINE_STUB(spdk_bdev_readv_blocks_with_md, int, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, struct iovec *iov, int iovcnt, void *md, uint64_t offset_blocks, uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg), 0); -DEFINE_STUB(spdk_bdev_writev_blocks, int, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, - struct iovec *iov, int iovcnt, - uint64_t offset_blocks, uint64_t num_blocks, - spdk_bdev_io_completion_cb cb, void *cb_arg), 0); DEFINE_STUB(spdk_bdev_writev_blocks_with_md, int, (struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, struct iovec *iov, int iovcnt, void *md, uint64_t offset_blocks, uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg), 0); +DEFINE_STUB(spdk_bdev_readv_blocks_ext, int, (struct spdk_bdev_desc *desc, + struct spdk_io_channel *ch, + struct iovec *iov, int iovcnt, uint64_t offset_blocks, uint64_t num_blocks, + spdk_bdev_io_completion_cb cb, void *cb_arg, struct spdk_bdev_ext_io_opts *opts), 0); +DEFINE_STUB(spdk_bdev_writev_blocks_ext, int, (struct spdk_bdev_desc *desc, + struct spdk_io_channel *ch, + struct iovec *iov, int iovcnt, uint64_t offset_blocks, uint64_t num_blocks, + spdk_bdev_io_completion_cb cb, void *cb_arg, struct spdk_bdev_ext_io_opts *opts), 0); static int test_setup(void)