From dbc4e5094aa597030d2cbf6fe54761c600c883f5 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 31 Aug 2018 11:00:59 +0900 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/424149 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Kunal Sablok Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/bdev/raid/bdev_raid_rpc.c | 40 +++++------------------------------ 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/lib/bdev/raid/bdev_raid_rpc.c b/lib/bdev/raid/bdev_raid_rpc.c index a58c5cd29..7c5ec5013 100644 --- a/lib/bdev/raid/bdev_raid_rpc.c +++ b/lib/bdev/raid/bdev_raid_rpc.c @@ -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);