bdev/raid: Set IO channel to raid_bdev_io at the start of IO submission

IO channel of the RAID bdev has not been changed during IO submission.
Hence it can be set to raid_bdev_io at the start of IO submission.

This will simplify the logic and improve maintainability.

Change-Id: I7d2f35d877be5ea0731e9b635133c1106f294a57
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/422790
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Kunal Sablok <kunal.sablok@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-08-21 10:00:51 +09:00 committed by Ben Walker
parent 87e849f88b
commit 88a1643dcc

View File

@ -306,23 +306,22 @@ raid_bdev_io_completion(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg
* base device by-passing the splitting logic. This is used for optimization * 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. * when the total number of base devices in a raid bdev is only 1.
* params: * params:
* ch - pointer to io channel for this io
* bdev_io - pointer to bdev_io * bdev_io - pointer to bdev_io
* returns: * returns:
* 0 - success * 0 - success
* non-zero - error * non-zero - error
*/ */
static int static int
raid_bdev_send_passthru(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io) raid_bdev_send_passthru(struct spdk_bdev_io *bdev_io)
{ {
struct raid_bdev_io_channel *raid_ch; struct raid_bdev_io_channel *raid_ch;
struct raid_bdev_io *raid_io; struct raid_bdev_io *raid_io;
struct raid_bdev *raid_bdev; struct raid_bdev *raid_bdev;
int ret; int ret;
raid_ch = spdk_io_channel_get_ctx(ch);
raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt; raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt;
raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx; 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; raid_io->status = SPDK_BDEV_IO_STATUS_SUCCESS;
if (raid_bdev->base_bdev_info[0].desc == NULL) { if (raid_bdev->base_bdev_info[0].desc == NULL) {
@ -359,7 +358,6 @@ raid_bdev_send_passthru(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io
*/ */
raid_io->splits_pending = 1; raid_io->splits_pending = 1;
raid_io->splits_comp_outstanding = 0; raid_io->splits_comp_outstanding = 0;
raid_io->ch = ch;
return ret; return ret;
} }
@ -372,7 +370,6 @@ raid_bdev_send_passthru(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io
* the childs to bdev layer. bdev layer redirects the childs to appropriate base * the childs to bdev layer. bdev layer redirects the childs to appropriate base
* bdev nvme module * bdev nvme module
* params: * params:
* ch - pointer to spdk_io_channel for the raid bdev
* bdev_io - parent bdev io * bdev_io - parent bdev io
* start_strip - start strip number of this io * start_strip - start strip number of this io
* end_strip - end strip number of this io * end_strip - end strip number of this io
@ -383,11 +380,11 @@ raid_bdev_send_passthru(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io
* non zero - failure * non zero - failure
*/ */
static int static int
raid_bdev_submit_children(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, raid_bdev_submit_children(struct spdk_bdev_io *bdev_io,
uint64_t start_strip, uint64_t end_strip, uint64_t cur_strip, uint8_t *buf) uint64_t start_strip, uint64_t end_strip, uint64_t cur_strip, uint8_t *buf)
{ {
struct raid_bdev_io_channel *raid_ch = spdk_io_channel_get_ctx(ch);
struct raid_bdev_io *raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx; struct raid_bdev_io *raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx;
struct raid_bdev_io_channel *raid_ch = spdk_io_channel_get_ctx(raid_io->ch);
struct raid_bdev *raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt; struct raid_bdev *raid_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt;
uint64_t pd_strip; uint64_t pd_strip;
uint32_t offset_in_strip; uint32_t offset_in_strip;
@ -458,7 +455,6 @@ raid_bdev_submit_children(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_
* try to submit the remaining 3 and 4 childs * try to submit the remaining 3 and 4 childs
*/ */
raid_io->buf = buf; raid_io->buf = buf;
raid_io->ch = ch;
raid_io->splits_comp_outstanding--; raid_io->splits_comp_outstanding--;
raid_io->splits_pending++; raid_io->splits_pending++;
return ret; return ret;
@ -589,10 +585,10 @@ raid_bdev_waitq_io_process(void *ctx)
end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >> end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >>
raid_bdev->strip_size_shift; raid_bdev->strip_size_shift;
cur_strip = start_strip + ((end_strip - start_strip + 1) - raid_io->splits_pending); cur_strip = start_strip + ((end_strip - start_strip + 1) - raid_io->splits_pending);
ret = raid_bdev_submit_children(raid_io->ch, bdev_io, start_strip, end_strip, cur_strip, ret = raid_bdev_submit_children(bdev_io, start_strip, end_strip, cur_strip,
raid_io->buf); raid_io->buf);
} else { } else {
ret = raid_bdev_send_passthru(raid_io->ch, bdev_io); ret = raid_bdev_send_passthru(bdev_io);
} }
if (ret != 0) { if (ret != 0) {
raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_io, ret); raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_io, ret);
@ -629,6 +625,7 @@ _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_bdev = (struct raid_bdev *)bdev_io->bdev->ctxt;
raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx; raid_io = (struct raid_bdev_io *)bdev_io->driver_ctx;
raid_io->ch = ch;
if (raid_bdev->num_base_bdevs > 1) { if (raid_bdev->num_base_bdevs > 1) {
start_strip = bdev_io->u.bdev.offset_blocks >> raid_bdev->strip_size_shift; 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) >> end_strip = (bdev_io->u.bdev.offset_blocks + bdev_io->u.bdev.num_blocks - 1) >>
@ -639,10 +636,10 @@ _raid_bdev_submit_rw_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bd
raid_io->splits_pending = (end_strip - start_strip + 1); raid_io->splits_pending = (end_strip - start_strip + 1);
raid_io->splits_comp_outstanding = 0; raid_io->splits_comp_outstanding = 0;
raid_io->status = SPDK_BDEV_IO_STATUS_SUCCESS; raid_io->status = SPDK_BDEV_IO_STATUS_SUCCESS;
ret = raid_bdev_submit_children(ch, bdev_io, start_strip, end_strip, start_strip, ret = raid_bdev_submit_children(bdev_io, start_strip, end_strip, start_strip,
bdev_io->u.bdev.iovs->iov_base); bdev_io->u.bdev.iovs->iov_base);
} else { } else {
ret = raid_bdev_send_passthru(ch, bdev_io); ret = raid_bdev_send_passthru(bdev_io);
} }
if (ret != 0) { if (ret != 0) {
raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_io, ret); raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_io, ret);