bdev/raid: Get base bdevs from its raid bdev simply in remove_base_devices()
This is a preparation to add completion callback to the destroy_raid_bdev RPC. Getting raid bdev from its config and processing base bdevs by using it throughout is much more natural. Checking if base bdev is active can be done by checking if the pointer to the base bdev in base_bdev_info is not NULL. Change-Id: Idd43b13eb342d9cd21ba55943bdcd1f564b3760e Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450568 Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
2cccea55ed
commit
ca34df9807
@ -1823,20 +1823,43 @@ raid_bdev_remove_base_bdev(void *ctx)
|
|||||||
void
|
void
|
||||||
raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg)
|
raid_bdev_remove_base_devices(struct raid_bdev_config *raid_cfg)
|
||||||
{
|
{
|
||||||
struct spdk_bdev *base_bdev;
|
struct raid_bdev *raid_bdev;
|
||||||
|
struct raid_base_bdev_info *info;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid_bdev_remove_base_devices\n");
|
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid_bdev_remove_base_devices\n");
|
||||||
|
|
||||||
for (i = 0; i < raid_cfg->num_base_bdevs; i++) {
|
raid_bdev = raid_cfg->raid_bdev;
|
||||||
base_bdev = spdk_bdev_get_by_name(raid_cfg->base_bdev[i].name);
|
if (raid_bdev == NULL) {
|
||||||
if (base_bdev == NULL) {
|
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid bdev %s doesn't exist now\n", raid_cfg->name);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "base bdev %s doesn't exist now\n",
|
return;
|
||||||
raid_cfg->base_bdev[i].name);
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < raid_bdev->num_base_bdevs; i++) {
|
||||||
|
info = &raid_bdev->base_bdev_info[i];
|
||||||
|
|
||||||
|
if (info->bdev == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
raid_bdev_remove_base_bdev(base_bdev);
|
assert(info->desc);
|
||||||
|
info->remove_scheduled = true;
|
||||||
|
|
||||||
|
if (raid_bdev->destruct_called == true ||
|
||||||
|
raid_bdev->state == RAID_BDEV_STATE_CONFIGURING) {
|
||||||
|
/*
|
||||||
|
* As raid bdev is not registered yet or already unregistered,
|
||||||
|
* so cleanup should be done here itself.
|
||||||
|
*/
|
||||||
|
raid_bdev_free_base_bdev_resource(raid_bdev, i);
|
||||||
|
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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
raid_bdev_deconfigure(raid_bdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user