Commit 9d258c75 authored by Piotr Pelplinski's avatar Piotr Pelplinski Committed by Jim Harris
Browse files

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: default avatarPiotr Pelplinski <piotr.pelplinski@intel.com>
Change-Id: I1448dd368cf3a24a5daccab387d7af7c3d231127
Reviewed-on: https://review.gerrithub.io/413913


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent d1aa8f62
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -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,
+0 −1
Original line number Diff line number Diff line
@@ -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)
+21 −3
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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,

};
+1 −1
Original line number Diff line number Diff line
@@ -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)
Loading