bdev: split examine into two parts

During spdk_bdev_init, examine_config is called.
This call can claim bdev synchronously, based on
configuration. On spdk_bdev_start if none module
claimed bdev, examine_disk is called and can
perform I/O before claiming bdev.

Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com>
Change-Id: I1448dd368cf3a24a5daccab387d7af7c3d231127
Reviewed-on: https://review.gerrithub.io/413913
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Piotr Pelplinski 2018-06-26 14:07:11 +02:00 committed by Jim Harris
parent d1aa8f622d
commit 9d258c75af
10 changed files with 39 additions and 15 deletions

View File

@ -99,11 +99,19 @@ struct spdk_bdev_module {
int (*get_ctx_size)(void);
/**
* Notification that a bdev should be examined by a virtual bdev module.
* First notification that a bdev should be examined by a virtual bdev module.
* Virtual bdev modules may use this to examine newly-added bdevs and automatically
* create their own vbdevs.
* create their own vbdevs, but no I/O to device can be send to bdev at this point.
* Only vbdevs based on config files can be created here.
*/
void (*examine)(struct spdk_bdev *bdev);
void (*examine_config)(struct spdk_bdev *bdev);
/**
* Second notification that a bdev should be examined by a virtual bdev module.
* Virtual bdev modules may use this to examine newly-added bdevs and automatically
* create their own vbdevs. This callback may use I/O operations end finish asynchronously.
*/
void (*examine_disk)(struct spdk_bdev *bdev);
/**
* Denotes if the module_init function may complete asynchronously. If set to true,

View File

@ -65,7 +65,6 @@ static struct spdk_bdev_module aio_if = {
.module_fini = NULL,
.config_text = bdev_aio_get_spdk_running_config,
.get_ctx_size = bdev_aio_get_ctx_size,
.examine = NULL,
};
SPDK_BDEV_MODULE_REGISTER(&aio_if)

View File

@ -2801,14 +2801,32 @@ static void
spdk_bdev_start(struct spdk_bdev *bdev)
{
struct spdk_bdev_module *module;
uint32_t action;
SPDK_DEBUGLOG(SPDK_LOG_BDEV, "Inserting bdev %s into list\n", bdev->name);
TAILQ_INSERT_TAIL(&g_bdev_mgr.bdevs, bdev, internal.link);
/* Examine configuration before initializing I/O */
TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
if (module->examine) {
if (module->examine_config) {
action = module->internal.action_in_progress;
module->internal.action_in_progress++;
module->examine(bdev);
module->examine_config(bdev);
if (action != module->internal.action_in_progress) {
SPDK_ERRLOG("examine_config for module %s did not call spdk_bdev_module_examine_done()\n",
module->name);
}
}
}
if (bdev->internal.claim_module) {
return;
}
TAILQ_FOREACH(module, &g_bdev_mgr.bdev_modules, internal.tailq) {
if (module->examine_disk) {
module->internal.action_in_progress++;
module->examine_disk(bdev);
}
}
}
@ -3165,7 +3183,7 @@ spdk_bdev_module_list_add(struct spdk_bdev_module *bdev_module)
* ready to handle examine callbacks from later modules that will
* register physical bdevs.
*/
if (bdev_module->examine != NULL) {
if (bdev_module->examine_config != NULL || bdev_module->examine_disk != NULL) {
TAILQ_INSERT_HEAD(&g_bdev_mgr.bdev_modules, bdev_module, internal.tailq);
} else {
TAILQ_INSERT_TAIL(&g_bdev_mgr.bdev_modules, bdev_module, internal.tailq);

View File

@ -89,7 +89,7 @@ static struct spdk_bdev_module error_if = {
.name = "error",
.module_init = vbdev_error_init,
.module_fini = vbdev_error_fini,
.examine = vbdev_error_examine,
.examine_config = vbdev_error_examine,
.config_json = vbdev_error_config_json,
};

View File

@ -55,7 +55,7 @@ static void vbdev_gpt_examine(struct spdk_bdev *bdev);
static struct spdk_bdev_module gpt_if = {
.name = "gpt",
.module_init = vbdev_gpt_init,
.examine = vbdev_gpt_examine,
.examine_disk = vbdev_gpt_examine,
};
SPDK_BDEV_MODULE_REGISTER(&gpt_if)

View File

@ -50,7 +50,7 @@ static void vbdev_lvs_examine(struct spdk_bdev *bdev);
static struct spdk_bdev_module g_lvol_if = {
.name = "lvol",
.module_init = vbdev_lvs_init,
.examine = vbdev_lvs_examine,
.examine_disk = vbdev_lvs_examine,
.get_ctx_size = vbdev_lvs_get_ctx_size,
};

View File

@ -62,7 +62,7 @@ static struct spdk_bdev_module passthru_if = {
.module_init = vbdev_passthru_init,
.config_text = vbdev_passthru_get_spdk_running_config,
.get_ctx_size = vbdev_passthru_get_ctx_size,
.examine = vbdev_passthru_examine,
.examine_config = vbdev_passthru_examine,
.module_fini = vbdev_passthru_finish
};

View File

@ -78,7 +78,7 @@ static struct spdk_bdev_module split_if = {
.name = "split",
.module_init = vbdev_split_init,
.module_fini = vbdev_split_fini,
.examine = vbdev_split_examine,
.examine_config = vbdev_split_examine,
.config_json = vbdev_split_config_json,
};
@ -426,7 +426,6 @@ vbdev_split_examine(struct spdk_bdev *bdev)
SPDK_ERRLOG("could not split bdev %s\n", bdev->name);
}
}
spdk_bdev_module_examine_done(&split_if);
}

View File

@ -181,9 +181,9 @@ vbdev_ut_module_fini(void)
struct spdk_bdev_module vbdev_ut_if = {
.name = "vbdev_ut",
.examine = vbdev_ut_examine,
.module_init = vbdev_ut_module_init,
.module_fini = vbdev_ut_module_fini,
.examine_config = vbdev_ut_examine,
};
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)

View File

@ -68,7 +68,7 @@ static void vbdev_ut_examine(struct spdk_bdev *bdev);
struct spdk_bdev_module vbdev_ut_if = {
.name = "vbdev_ut",
.examine = vbdev_ut_examine,
.examine_config = vbdev_ut_examine,
};
SPDK_BDEV_MODULE_REGISTER(&bdev_ut_if)