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

module/raid: remove num_channels from raid_bdev_io_channel



This value is always equal to the number of base bdevs so just use that.

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


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent d8a22322
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -75,17 +75,15 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
	assert(raid_bdev != NULL);
	assert(raid_bdev->state == RAID_BDEV_STATE_ONLINE);

	raid_ch->num_channels = raid_bdev->num_base_bdevs;

	raid_ch->base_channel = calloc(raid_ch->num_channels,
				       sizeof(struct spdk_io_channel *));
	raid_ch->base_channel = calloc(raid_bdev->num_base_bdevs, sizeof(struct spdk_io_channel *));
	if (!raid_ch->base_channel) {
		SPDK_ERRLOG("Unable to allocate base bdevs io channel\n");
		return -ENOMEM;
	}

	spdk_spin_lock(&raid_bdev->base_bdev_lock);
	for (i = 0; i < raid_ch->num_channels; i++) {
	for (i = 0; i < raid_bdev->num_base_bdevs; i++) {
		/*
		 * Get the spdk_io_channel for all the base bdevs. This is used during
		 * split logic to send the respective child bdev ios to respective base
@@ -113,7 +111,7 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
	}

	if (ret) {
		for (i = 0; i < raid_ch->num_channels; i++) {
		for (i = 0; i < raid_bdev->num_base_bdevs; i++) {
			if (raid_ch->base_channel[i] != NULL) {
				spdk_put_io_channel(raid_ch->base_channel[i]);
			}
@@ -137,6 +135,7 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
static void
raid_bdev_destroy_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;

@@ -149,7 +148,7 @@ raid_bdev_destroy_cb(void *io_device, void *ctx_buf)
		spdk_put_io_channel(raid_ch->module_channel);
	}

	for (i = 0; i < raid_ch->num_channels; i++) {
	for (i = 0; i < raid_bdev->num_base_bdevs; i++) {
		/* Free base bdev channels */
		if (raid_ch->base_channel[i] != NULL) {
			spdk_put_io_channel(raid_ch->base_channel[i]);
+0 −3
Original line number Diff line number Diff line
@@ -193,9 +193,6 @@ struct raid_bdev_io_channel {
	/* Array of IO channels of base bdevs */
	struct spdk_io_channel	**base_channel;

	/* Number of IO channels */
	uint8_t			num_channels;

	/* Private raid module IO channel */
	struct spdk_io_channel	*module_channel;
};
+3 −3
Original line number Diff line number Diff line
@@ -88,14 +88,14 @@ raid1_init_ext_io_opts(struct spdk_bdev_io *bdev_io, struct spdk_bdev_ext_io_opt
}

static uint8_t
raid1_channel_next_read_base_bdev(struct raid_bdev_io_channel *raid_ch)
raid1_channel_next_read_base_bdev(struct raid_bdev *raid_bdev, struct raid_bdev_io_channel *raid_ch)
{
	struct raid1_io_channel *raid1_ch = spdk_io_channel_get_ctx(raid_ch->module_channel);
	uint64_t read_blocks_min = UINT64_MAX;
	uint8_t idx = UINT8_MAX;
	uint8_t i;

	for (i = 0; i < raid_ch->num_channels; i++) {
	for (i = 0; i < raid_bdev->num_base_bdevs; i++) {
		if (raid_ch->base_channel[i] != NULL &&
		    raid1_ch->read_blocks_outstanding[i] < read_blocks_min) {
			read_blocks_min = raid1_ch->read_blocks_outstanding[i];
@@ -122,7 +122,7 @@ raid1_submit_read_request(struct raid_bdev_io *raid_io)
	pd_lba = bdev_io->u.bdev.offset_blocks;
	pd_blocks = bdev_io->u.bdev.num_blocks;

	idx = raid1_channel_next_read_base_bdev(raid_ch);
	idx = raid1_channel_next_read_base_bdev(raid_bdev, raid_ch);
	if (spdk_unlikely(idx == UINT8_MAX)) {
		raid_bdev_io_complete(raid_io, SPDK_BDEV_IO_STATUS_FAILED);
		return 0;
+2 −3
Original line number Diff line number Diff line
@@ -167,10 +167,9 @@ run_for_each_raid1_config(void (*test_fn)(struct raid_bdev *raid_bdev,

		r1_info = create_raid1(params);

		raid_ch.num_channels = params->num_base_bdevs;
		raid_ch.base_channel = calloc(params->num_base_bdevs, sizeof(struct spdk_io_channel *));
		SPDK_CU_ASSERT_FATAL(raid_ch.base_channel != NULL);
		for (i = 0; i < raid_ch.num_channels; i++) {
		for (i = 0; i < params->num_base_bdevs; i++) {
			raid_ch.base_channel[i] = calloc(1, sizeof(*raid_ch.base_channel));
			SPDK_CU_ASSERT_FATAL(raid_ch.base_channel[i] != NULL);
		}
@@ -183,7 +182,7 @@ run_for_each_raid1_config(void (*test_fn)(struct raid_bdev *raid_bdev,
		spdk_put_io_channel(raid_ch.module_channel);
		poll_threads();

		for (i = 0; i < raid_ch.num_channels; i++) {
		for (i = 0; i < params->num_base_bdevs; i++) {
			free(raid_ch.base_channel[i]);
		}
		free(raid_ch.base_channel);
+0 −1
Original line number Diff line number Diff line
@@ -912,7 +912,6 @@ run_for_each_raid5f_config(void (*test_fn)(struct raid_bdev *raid_bdev,

		r5f_info = create_raid5f(params);

		raid_ch.num_channels = params->num_base_bdevs;
		raid_ch.base_channel = calloc(params->num_base_bdevs, sizeof(struct spdk_io_channel *));
		SPDK_CU_ASSERT_FATAL(raid_ch.base_channel != NULL);