From 0497ae8ea35fb454774718ef590bbb7c47781ab9 Mon Sep 17 00:00:00 2001 From: Piotr Pelplinski Date: Fri, 15 Mar 2019 10:32:24 +0100 Subject: [PATCH] bdev: Allow bdev module to finish start asynchronously Currently if module claims a bdev in examine_config, it cannot start asynchronously. This patch changes this behaviour by calling examine_disk on modules which previously claimed bdev trough examine_config. Signed-off-by: Piotr Pelplinski Change-Id: I85b603590c6dab50e59ef7e68f292cb9abc47d98 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448132 Reviewed-by: Darek Stojaczyk Reviewed-by: Vitaliy Mysak Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- doc/bdev_module.md | 4 ++-- include/spdk/bdev_module.h | 7 ++++++- lib/bdev/bdev.c | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/bdev_module.md b/doc/bdev_module.md index 24a08df4b..6ada6bd0d 100644 --- a/doc/bdev_module.md +++ b/doc/bdev_module.md @@ -34,8 +34,8 @@ initialization (`module_init`) and teardown (`module_fini`) functions, the function that returns context size (`get_ctx_size`) - scratch space that will be allocated in each I/O request for use by this module, and a callback that will be called each time a new bdev is registered by another module -(`examine`). Please check the documentation of struct spdk_bdev_module for -more details. +(`examine_config` and `examine_disk`). Please check the documentation of +struct spdk_bdev_module for more details. ## Creating Bdevs diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index 1a767a235..79b06b65a 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -119,7 +119,12 @@ struct spdk_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, but no I/O to device can be send to bdev at this point. - * Only vbdevs based on config files can be created here. + * Only vbdevs based on config files can be created here. This callback must make + * its decision to claim the module synchronously. + * It must also call spdk_bdev_module_examine_done() before returning. If the module + * needs to perform asynchronous operations such as I/O after claiming the bdev, + * it may define an examine_disk callback. The examine_disk callback will then + * be called immediately after the examine_config callback returns. */ void (*examine_config)(struct spdk_bdev *bdev); diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index dbba28d12..95eccba2b 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -3721,6 +3721,10 @@ spdk_bdev_start(struct spdk_bdev *bdev) } if (bdev->internal.claim_module) { + if (bdev->internal.claim_module->examine_disk) { + bdev->internal.claim_module->internal.action_in_progress++; + bdev->internal.claim_module->examine_disk(bdev); + } return; }