Commit dbc4e509 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

bdev/raid: Refactor raid_bdev_config_destroy()



raid_bdev_config_destroy_check_raid_bdev_exists() and
raid_bdev_config_destroy() do almost same operation and can be
unified to raid_bdev_config_destroy().

Comment in spdk_rpc_destroy_raid_bdev() about raid_bdev_config_destroy()
are duplicated with the one on top of the raid_bdev_config_destroy().
Hence remove the former in this patch too.

Change-Id: I4a323bf24d2266e2da7f030c52771013d075eb31
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/424149


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarKunal Sablok <kunal.sablok@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 3f578219
Loading
Loading
Loading
Loading
+5 −35
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@

#define RPC_MAX_BASE_BDEVS 255

static void raid_bdev_config_destroy(struct raid_bdev_config *raid_cfg);

SPDK_LOG_REGISTER_COMPONENT("raidrpc", SPDK_LOG_RAID_RPC)

/*
@@ -342,46 +340,22 @@ static const struct spdk_json_object_decoder rpc_destroy_raid_bdev_decoders[] =
 * none
 */
static void
raid_bdev_config_destroy_check_raid_bdev_exists(void *arg)
raid_bdev_config_destroy(void *arg)
{
	struct raid_bdev_config	*raid_cfg = arg;

	assert(raid_cfg != NULL);
	if (raid_cfg->raid_bdev != NULL) {
		/* If raid bdev still exists, schedule event and come back later */
		spdk_thread_send_msg(spdk_get_thread(), raid_bdev_config_destroy_check_raid_bdev_exists,
				     raid_cfg);
		return;
	} else {
		/* If raid bdev does not exist now, go for raid bdev config cleanup */
		raid_bdev_config_destroy(raid_cfg);
	}
}

/*
 * brief:
 * This function will destroy the raid bdev at given slot
 * params:
 * slot - slot number of raid bdev config to destroy
 * returns:
 * none
 */
static void
raid_bdev_config_destroy(struct raid_bdev_config *raid_cfg)
{
	assert(raid_cfg != NULL);
	if (raid_cfg->raid_bdev != NULL) {
		/*
		 * If raid bdev exists for this config, wait for raid bdev to get
		 * destroyed and come back later
		 */
		spdk_thread_send_msg(spdk_get_thread(), raid_bdev_config_destroy_check_raid_bdev_exists,
		spdk_thread_send_msg(spdk_get_thread(), raid_bdev_config_destroy,
				     raid_cfg);
		return;
	}

	} else {
		raid_bdev_config_cleanup(raid_cfg);
	}
}

/*
 * brief:
@@ -433,10 +407,6 @@ spdk_rpc_destroy_raid_bdev(struct spdk_jsonrpc_request *request, const struct sp
		}
	}

	/*
	 * Call to destroy the raid bdev, but it will only destroy raid bdev if underlying
	 * cleanup is done
	 */
	raid_bdev_config_destroy(raid_cfg);

	free_rpc_destroy_raid_bdev(&req);