From 5d41f22d24d681505ad3e616069fbcaf22255c43 Mon Sep 17 00:00:00 2001 From: Mike Gerdts Date: Wed, 4 Jan 2023 09:23:57 -0600 Subject: [PATCH] bdev: spdk_bdev_module_init_done with async init spdk_bdev_module_init() must only be called if the module sets async_init to true. This patch fixes the doc string to match the implementation and adds an assert() to catch API usage errors early. Change-Id: I677345de028c8f7597ecf81ff9b9b855867bbf01 Signed-off-by: Mike Gerdts Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16133 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- include/spdk/bdev_module.h | 4 ++-- lib/bdev/bdev.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index 6d0c2210f..b48979988 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -951,8 +951,8 @@ void spdk_bdev_module_examine_done(struct spdk_bdev_module *module); /** * Indicate to the bdev layer that the module is done initializing. * - * To be called once during module_init or asynchronously after - * an asynchronous operation required for module initialization is completed. + * To be called once after an asynchronous operation required for module initialization is + * completed. If module->async_init is false, the module must not call this function. * * \param module Pointer to the module completing the initialization. */ diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 2120fec6f..51c9b6f31 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -1583,6 +1583,7 @@ bdev_module_action_done(struct spdk_bdev_module *module) void spdk_bdev_module_init_done(struct spdk_bdev_module *module) { + assert(module->async_init); bdev_module_action_done(module); }