Commit c89e2008 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

module/raid: support for raid module private io channel



Let the raid modules create their own IO channels by implementing the
get_io_channel callback.

Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Change-Id: Id4f6c90721474edd70a6e987c67f8f774737da27
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7700


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 95a04949
Loading
Loading
Loading
Loading
+26 −9
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
	struct raid_bdev            *raid_bdev = io_device;
	struct raid_bdev_io_channel *raid_ch = ctx_buf;
	uint8_t i;
	int ret = 0;

	SPDK_DEBUGLOG(bdev_raid, "raid_bdev_create_cb, %p\n", raid_ch);

@@ -114,6 +115,21 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
		raid_ch->base_channel[i] = spdk_bdev_get_io_channel(
						   raid_bdev->base_bdev_info[i].desc);
		if (!raid_ch->base_channel[i]) {
			SPDK_ERRLOG("Unable to create io channel for base bdev\n");
			ret = -ENOMEM;
			break;
		}
	}

	if (!ret && raid_bdev->module->get_io_channel) {
		raid_ch->module_channel = raid_bdev->module->get_io_channel(raid_bdev);
		if (!raid_ch->module_channel) {
			SPDK_ERRLOG("Unable to create io channel for raid module\n");
			ret = -ENOMEM;
		}
	}

	if (ret) {
		uint8_t j;

		for (j = 0; j < i; j++) {
@@ -121,12 +137,8 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
		}
		free(raid_ch->base_channel);
		raid_ch->base_channel = NULL;
			SPDK_ERRLOG("Unable to create io channel for base bdev\n");
			return -ENOMEM;
	}
	}

	return 0;
	return ret;
}

/*
@@ -149,6 +161,11 @@ raid_bdev_destroy_cb(void *io_device, void *ctx_buf)

	assert(raid_ch != NULL);
	assert(raid_ch->base_channel);

	if (raid_ch->module_channel) {
		spdk_put_io_channel(raid_ch->module_channel);
	}

	for (i = 0; i < raid_ch->num_channels; i++) {
		/* Free base bdev channels */
		assert(raid_ch->base_channel[i] != NULL);
+9 −0
Original line number Diff line number Diff line
@@ -199,6 +199,9 @@ struct raid_bdev_io_channel {

	/* Number of IO channels */
	uint8_t			num_channels;

	/* Private raid module IO channel */
	struct spdk_io_channel	*module_channel;
};

/* TAIL heads for various raid bdev lists */
@@ -265,6 +268,12 @@ struct raid_bdev_module {
	/* Handler for requests without payload (flush, unmap). Optional. */
	void (*submit_null_payload_request)(struct raid_bdev_io *raid_io);

	/*
	 * Called when the bdev's IO channel is created to get the module's private IO channel.
	 * Optional.
	 */
	struct spdk_io_channel *(*get_io_channel)(struct raid_bdev *raid_bdev);

	TAILQ_ENTRY(raid_bdev_module) link;
};