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; }