From d38b3d28a8c3ccea03cb617f04cb849eb64208d6 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 23 Aug 2018 12:50:34 -0700 Subject: [PATCH] bdev/raid: remove raid_bdev_send_passthru This function was meant to handle case when a RAID volume only had one member disk. This is not a common case, so just go through the raid_bdev_submit_children() path in this case. This will simplify some upcoming patches to use split_on_optimal_io_boundary to enable vectored I/O. Signed-off-by: Jim Harris Change-Id: Ic7c7f7987d54ffd836deabb98530f7c339094809 Reviewed-on: https://review.gerrithub.io/423322 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- lib/bdev/raid/bdev_raid.c | 105 ++++++-------------------------------- 1 file changed, 16 insertions(+), 89 deletions(-) diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index 55af45a79..abfe6e2cc 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -300,70 +300,6 @@ raid_bdev_io_completion(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg } } -/* - * brief: - * raid_bdev_send_passthru function sends the bdev_io to the underlying - * base device by-passing the splitting logic. This is used for optimization - * when the total number of base devices in a raid bdev is only 1. - * params: - * bdev_io - pointer to bdev_io - * returns: - * 0 - success - * non-zero - error - */ -static int -raid_bdev_send_passthru(struct spdk_bdev_io *bdev_io) -{ - struct raid_bdev_io_channel *raid_ch; - struct raid_bdev_io *raid_io; - struct raid_bdev *raid_bdev; - int ret; - - raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt; - raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx; - raid_ch = spdk_io_channel_get_ctx(raid_io->ch); - raid_io->status = SPDK_BDEV_IO_STATUS_SUCCESS; - - if (raid_bdev->base_bdev_info[0].desc == NULL) { - SPDK_ERRLOG("base bdev desc null for pd_idx %u\n", 0); - assert(0); - } - raid_io->splits_pending = 0; - raid_io->splits_comp_outstanding = 1; - if (bdev_io->type == SPDK_BDEV_IO_TYPE_READ) { - ret = spdk_bdev_read_blocks(raid_bdev->base_bdev_info[0].desc, - raid_ch->base_channel[0], - bdev_io->u.bdev.iovs->iov_base, - bdev_io->u.bdev.offset_blocks, - bdev_io->u.bdev.num_blocks, raid_bdev_io_completion, - bdev_io); - } else if (bdev_io->type == SPDK_BDEV_IO_TYPE_WRITE) { - ret = spdk_bdev_write_blocks(raid_bdev->base_bdev_info[0].desc, - raid_ch->base_channel[0], - bdev_io->u.bdev.iovs->iov_base, - bdev_io->u.bdev.offset_blocks, - bdev_io->u.bdev.num_blocks, raid_bdev_io_completion, - bdev_io); - } else { - ret = -EINVAL; - } - if (ret != 0) { - /* - * If failed to submit child io to bdev layer then queue the parent - * bdev io with current active split information in the wait queue - * for that core. This will get resume from this point only. Assume - * if 4 splits are required and 2 childs are submitted, then parent - * io is queued to io waitq of this core and it will get resumed and - * try to submit the remaining 3 and 4 childs - */ - raid_io->splits_pending = 1; - raid_io->splits_comp_outstanding = 0; - return ret; - } - - return 0; -} - /* * brief: * raid_bdev_submit_children function is used to split the parent io and submit @@ -580,16 +516,11 @@ raid_bdev_waitq_io_process(void *ctx) * crunch then break the loop and don't try to process other queued IOs. */ raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt; - if (raid_bdev->num_base_bdevs > 1) { - start_strip = bdev_io->u.bdev.offset_blocks >> raid_bdev->strip_size_shift; - end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >> - raid_bdev->strip_size_shift; - cur_strip = start_strip + ((end_strip - start_strip + 1) - raid_io->splits_pending); - ret = raid_bdev_submit_children(bdev_io, start_strip, end_strip, cur_strip, - raid_io->buf); - } else { - ret = raid_bdev_send_passthru(bdev_io); - } + start_strip = bdev_io->u.bdev.offset_blocks >> raid_bdev->strip_size_shift; + end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >> + raid_bdev->strip_size_shift; + cur_strip = start_strip + ((end_strip - start_strip + 1) - raid_io->splits_pending); + ret = raid_bdev_submit_children(bdev_io, start_strip, end_strip, cur_strip, raid_io->buf); if (ret != 0) { raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_io, ret); } @@ -626,21 +557,17 @@ _raid_bdev_submit_rw_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bd raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt; raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx; raid_io->ch = ch; - if (raid_bdev->num_base_bdevs > 1) { - start_strip = bdev_io->u.bdev.offset_blocks >> raid_bdev->strip_size_shift; - end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >> - raid_bdev->strip_size_shift; - /* - * IO parameters used during io split and io completion - */ - raid_io->splits_pending = (end_strip - start_strip + 1); - raid_io->splits_comp_outstanding = 0; - raid_io->status = SPDK_BDEV_IO_STATUS_SUCCESS; - ret = raid_bdev_submit_children(bdev_io, start_strip, end_strip, start_strip, - bdev_io->u.bdev.iovs->iov_base); - } else { - ret = raid_bdev_send_passthru(bdev_io); - } + start_strip = bdev_io->u.bdev.offset_blocks >> raid_bdev->strip_size_shift; + end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >> + raid_bdev->strip_size_shift; + /* + * IO parameters used during io split and io completion + */ + raid_io->splits_pending = (end_strip - start_strip + 1); + raid_io->splits_comp_outstanding = 0; + raid_io->status = SPDK_BDEV_IO_STATUS_SUCCESS; + ret = raid_bdev_submit_children(bdev_io, start_strip, end_strip, start_strip, + bdev_io->u.bdev.iovs->iov_base); if (ret != 0) { raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_io, ret); }