Commit cabe0203 authored by Jim Harris's avatar Jim Harris
Browse files

raid: break out read/write code into separate function



This is needed for next patch which needs to defer reads
when getting an io buf.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: If31e7d76384c7fd05cc77a3b2124ee4e9354823e

Reviewed-on: https://review.gerrithub.io/420676


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent 9928e9d9
Loading
Loading
Loading
Loading
+54 −38
Original line number Diff line number Diff line
@@ -581,10 +581,8 @@ raid_bdev_waitq_io_process(void *ctx)

/*
 * brief:
 * raid_bdev_submit_request function is the submit_request function pointer of
 * raid bdev function table. This is used to submit the io on raid_bdev to below
 * layers. If iowaitq is not empty, it will queue the parent bdev_io to the end
 * of the queue.
 * _raid_bdev_submit_rw_request function is the submit_request function for
 * read/write requests
 * params:
 * ch - pointer to raid bdev io channel
 * bdev_io - pointer to parent bdev_io on raid bdev device
@@ -592,7 +590,7 @@ raid_bdev_waitq_io_process(void *ctx)
 * none
 */
static void
raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
_raid_bdev_submit_rw_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	struct raid_bdev_io_channel	*raid_bdev_io_channel;
	struct raid_bdev_io		*raid_bdev_io;
@@ -601,14 +599,12 @@ raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
	uint64_t			end_strip = 0;
	int				ret;

	switch (bdev_io->type) {
	case SPDK_BDEV_IO_TYPE_READ:
	case SPDK_BDEV_IO_TYPE_WRITE:
	if (bdev_io->u.bdev.iovcnt != 1) {
		SPDK_ERRLOG("iov vector count is not 1\n");
		spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
			break;
		return;
	}

	/*
	 * IO parameters used during io split and io completion
	 */
@@ -633,6 +629,26 @@ raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
	if (ret != 0) {
		raid_bdev_io_submit_fail_process(raid_bdev, bdev_io, raid_bdev_io, ret);
	}
}

/*
 * brief:
 * raid_bdev_submit_request function is the submit_request function pointer of
 * raid bdev function table. This is used to submit the io on raid_bdev to below
 * layers.
 * params:
 * ch - pointer to raid bdev io channel
 * bdev_io - pointer to parent bdev_io on raid bdev device
 * returns:
 * none
 */
static void
raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	switch (bdev_io->type) {
	case SPDK_BDEV_IO_TYPE_READ:
	case SPDK_BDEV_IO_TYPE_WRITE:
		_raid_bdev_submit_rw_request(ch, bdev_io);
		break;

	case SPDK_BDEV_IO_TYPE_FLUSH: