bdev/raid: Add callback parameters to remove_base_devices()

This is a preparation to add completion callback to the
destroy_raid_bdev RPC.

Newly added callback parameters are passed to spdk_bdev_unregister()
in the end. This patch adds just parameters and the next patch will
utilize them.

Change-Id: Ic239c55872c0c69f3d1625eaccdb91a32a9d4d30
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450572
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-04-09 09:40:54 +09:00 committed by Jim Harris
parent b2dd6e7ec2
commit 5f51f0aff6
4 changed files with 31 additions and 8 deletions

View File

@ -67,7 +67,8 @@ struct raid_offline_tailq g_raid_bdev_offline_list;
static void raid_bdev_examine(struct spdk_bdev *bdev);
static int raid_bdev_init(void);
static void raid_bdev_waitq_io_process(void *ctx);
static void raid_bdev_deconfigure(struct raid_bdev *raid_bdev);
static void raid_bdev_deconfigure(struct raid_bdev *raid_bdev,
raid_bdev_destruct_cb cb_fn, void *cb_arg);
static void raid_bdev_remove_base_bdev(void *ctx);
/*
@ -1716,13 +1717,19 @@ raid_bdev_configure(struct raid_bdev *raid_bdev)
* in configuring list
* params:
* raid_bdev - pointer to raid bdev
* cb_fn - callback function
* cb_arg - argument to callback function
* returns:
* none
*/
static void
raid_bdev_deconfigure(struct raid_bdev *raid_bdev)
raid_bdev_deconfigure(struct raid_bdev *raid_bdev, raid_bdev_destruct_cb cb_fn,
void *cb_arg)
{
if (raid_bdev->state != RAID_BDEV_STATE_ONLINE) {
if (cb_fn) {
cb_fn(cb_arg, 0);
}
return;
}
@ -1733,7 +1740,7 @@ raid_bdev_deconfigure(struct raid_bdev *raid_bdev)
TAILQ_INSERT_TAIL(&g_raid_bdev_offline_list, raid_bdev, state_link);
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid bdev state chaning from online to offline\n");
spdk_bdev_unregister(&raid_bdev->bdev, NULL, NULL);
spdk_bdev_unregister(&raid_bdev->bdev, cb_fn, cb_arg);
}
/*
@ -1810,7 +1817,7 @@ raid_bdev_remove_base_bdev(void *ctx)
}
}
raid_bdev_deconfigure(raid_bdev);
raid_bdev_deconfigure(raid_bdev, NULL, NULL);
}
/*
@ -1819,9 +1826,12 @@ raid_bdev_remove_base_bdev(void *ctx)
* doesn't exist.
* params:
* raid_cfg - pointer to raid bdev config.
* cb_fn - callback function
* cb_ctx - argument to callback function
*/
void
raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg)
raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg,
raid_bdev_destruct_cb cb_fn, void *cb_arg)
{
struct raid_bdev *raid_bdev;
struct raid_base_bdev_info *info;
@ -1832,6 +1842,9 @@ raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg)
raid_bdev = raid_cfg->raid_bdev;
if (raid_bdev == NULL) {
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid bdev %s doesn't exist now\n", raid_cfg->name);
if (cb_fn) {
cb_fn(cb_arg, 0);
}
return;
}
@ -1855,12 +1868,15 @@ raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg)
if (raid_bdev->num_base_bdevs_discovered == 0) {
/* There is no base bdev for this raid, so free the raid device. */
raid_bdev_cleanup(raid_bdev);
if (cb_fn) {
cb_fn(cb_arg, 0);
}
return;
}
}
}
raid_bdev_deconfigure(raid_bdev);
raid_bdev_deconfigure(raid_bdev, cb_fn, cb_arg);
}
/*

View File

@ -214,9 +214,12 @@ extern struct raid_all_tailq g_raid_bdev_list;
extern struct raid_offline_tailq g_raid_bdev_offline_list;
extern struct raid_config g_raid_config;
typedef void (*raid_bdev_destruct_cb)(void *cb_ctx, int rc);
int raid_bdev_create(struct raid_bdev_config *raid_cfg);
int raid_bdev_add_base_devices(struct raid_bdev_config *raid_cfg);
void raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg);
void raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg,
raid_bdev_destruct_cb cb_fn, void *cb_ctx);
int raid_bdev_config_add(const char *raid_name, int strip_size, int num_base_bdevs,
int raid_level, struct raid_bdev_config **_raid_cfg);
int raid_bdev_config_add_base_bdev(struct raid_bdev_config *raid_cfg,

View File

@ -399,7 +399,7 @@ spdk_rpc_destroy_raid_bdev(struct spdk_jsonrpc_request *request, const struct sp
}
/* Remove all the base bdevs from this raid bdev before destroying the raid bdev */
raid_bdev_remove_base_devices(raid_cfg);
raid_bdev_remove_base_devices(raid_cfg, NULL, NULL);
raid_bdev_config_destroy(raid_cfg);

View File

@ -324,6 +324,10 @@ void
spdk_bdev_unregister(struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void *cb_arg)
{
bdev->fn_table->destruct(bdev->ctxt);
if (cb_fn) {
cb_fn(cb_arg, 0);
}
}
int