bdev/raid: release claim and close descriptors during destruct
During system shutdown, we want each module to release its claim and close any open descriptors when one of its bdevs is unregistered. This prepares for a future patch which will unregister bdevs at shutdown in reverse order - i.e the RAID bdev will be unregistered before its member disks. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ib4c2b9d25463e420dbc4ec5d3d7030e3d6e8d981 Reviewed-on: https://review.gerrithub.io/420927 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
1469679f09
commit
fd75d35771
@ -41,6 +41,8 @@
|
||||
#include "spdk/json.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
static bool g_shutdown_started = false;
|
||||
|
||||
/* raid bdev config as read from config file */
|
||||
struct raid_config g_spdk_raid_config = {
|
||||
.raid_bdev_config_head = TAILQ_HEAD_INITIALIZER(g_spdk_raid_config.raid_bdev_config_head),
|
||||
@ -65,6 +67,7 @@ struct spdk_raid_offline_tailq g_spdk_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);
|
||||
|
||||
|
||||
/*
|
||||
@ -227,16 +230,23 @@ raid_bdev_destruct(void *ctxt)
|
||||
for (uint16_t i = 0; i < raid_bdev->num_base_bdevs; i++) {
|
||||
/*
|
||||
* Close all base bdev descriptors for which call has come from below
|
||||
* layers
|
||||
* layers. Also close the descriptors if we have started shutdown.
|
||||
*/
|
||||
if ((raid_bdev->base_bdev_info[i].base_bdev_remove_scheduled == true) &&
|
||||
(raid_bdev->base_bdev_info[i].base_bdev != NULL)) {
|
||||
if (g_shutdown_started ||
|
||||
((raid_bdev->base_bdev_info[i].base_bdev_remove_scheduled == true) &&
|
||||
(raid_bdev->base_bdev_info[i].base_bdev != NULL))) {
|
||||
raid_bdev_free_base_bdev_resource(raid_bdev, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_shutdown_started) {
|
||||
TAILQ_REMOVE(&g_spdk_raid_bdev_configured_list, raid_bdev, link_specific_list);
|
||||
raid_bdev->state = RAID_BDEV_STATE_OFFLINE;
|
||||
TAILQ_INSERT_TAIL(&g_spdk_raid_bdev_offline_list, raid_bdev, link_specific_list);
|
||||
}
|
||||
|
||||
if (raid_bdev->num_base_bdevs_discovered == 0) {
|
||||
/* Free raid_bdev when there no base bdevs left */
|
||||
/* Free raid_bdev when there are no base bdevs left */
|
||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid bdev base bdevs is 0, going to free all in destruct\n");
|
||||
raid_bdev_cleanup(raid_bdev);
|
||||
}
|
||||
@ -1042,6 +1052,22 @@ raid_bdev_parse_config(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* brief:
|
||||
* raid_bdev_fini_start is called when bdev layer is starting the
|
||||
* shutdown process
|
||||
* params:
|
||||
* none
|
||||
* returns:
|
||||
* none
|
||||
*/
|
||||
static void
|
||||
raid_bdev_fini_start(void)
|
||||
{
|
||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV_RAID, "raid_bdev_fini_start\n");
|
||||
g_shutdown_started = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* brief:
|
||||
* raid_bdev_exit is called on raid bdev module exit time by bdev layer
|
||||
@ -1117,6 +1143,7 @@ raid_bdev_can_claim_bdev(const char *bdev_name, struct raid_bdev_config **raid_b
|
||||
static struct spdk_bdev_module g_raid_if = {
|
||||
.name = "raid",
|
||||
.module_init = raid_bdev_init,
|
||||
.fini_start = raid_bdev_fini_start,
|
||||
.module_fini = raid_bdev_exit,
|
||||
.get_ctx_size = raid_bdev_get_ctx_size,
|
||||
.examine_config = raid_bdev_examine,
|
||||
|
Loading…
Reference in New Issue
Block a user