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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/424149
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Kunal Sablok <kunal.sablok@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-08-31 11:00:59 +09:00 committed by Jim Harris
parent 3f578219be
commit dbc4e5094a

View File

@ -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,45 +340,21 @@ 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;
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);
}
raid_bdev_config_cleanup(raid_cfg);
}
/*
@ -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);