bdev: clean up spdk_bdev_register()
Clean up spdk_bdev_register() to facilitate the upcoming patch which uses RB tree to speed up bdev name lookup. * move TAILQ_INSERT from bdev_start() into bdev_init(); * rename bdev_init() to bdev_register() and rename bdev_start_finished() to bdev_register_finished(); * inline bdev_start() into spdk_bdev_register(). Signed-off-by: Jiewei Ke <jiewei@smartx.com> Change-Id: Idbfc800472bc8c6f9b615046e082772e9f6026e3 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8043 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
c3cf9ec295
commit
1a22f9b6ac
@ -5513,7 +5513,7 @@ spdk_bdev_io_get_io_channel(struct spdk_bdev_io *bdev_io)
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_init(struct spdk_bdev *bdev)
|
||||
bdev_register(struct spdk_bdev *bdev)
|
||||
{
|
||||
char *bdev_name;
|
||||
|
||||
@ -5593,6 +5593,10 @@ bdev_init(struct spdk_bdev *bdev)
|
||||
free(bdev_name);
|
||||
|
||||
pthread_mutex_init(&bdev->internal.mutex, NULL);
|
||||
|
||||
SPDK_DEBUGLOG(bdev, "Inserting bdev %s into list\n", bdev->name);
|
||||
TAILQ_INSERT_TAIL(&g_bdev_mgr.bdevs, bdev, internal.link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5621,32 +5625,23 @@ bdev_destroy_cb(void *io_device)
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_start_finished(void *arg)
|
||||
bdev_register_finished(void *arg)
|
||||
{
|
||||
struct spdk_bdev *bdev = arg;
|
||||
|
||||
spdk_notify_send("bdev_register", spdk_bdev_get_name(bdev));
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_start(struct spdk_bdev *bdev)
|
||||
{
|
||||
SPDK_DEBUGLOG(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 */
|
||||
bdev_examine(bdev);
|
||||
|
||||
spdk_bdev_wait_for_examine(bdev_start_finished, bdev);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_bdev_register(struct spdk_bdev *bdev)
|
||||
{
|
||||
int rc = bdev_init(bdev);
|
||||
int rc = bdev_register(bdev);
|
||||
|
||||
if (rc == 0) {
|
||||
bdev_start(bdev);
|
||||
/* Examine configuration before initializing I/O */
|
||||
bdev_examine(bdev);
|
||||
|
||||
spdk_bdev_wait_for_examine(bdev_register_finished, bdev);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
Loading…
Reference in New Issue
Block a user