From 35ab754449a306b21107cb0521dd4fe520b789c5 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 9 May 2017 15:07:56 -0700 Subject: [PATCH] bdev: Make spdk_bdev_mgr an I/O device Currently this is just a placeholder, but eventually it will be used to replace the per-core queues. Change-Id: Iefeb90711bcf001a383e36cd4eaadf813af66506 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/362613 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/bdev/bdev.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 37b9453fe..49e211436 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -76,11 +76,17 @@ static struct spdk_bdev_mgr g_bdev_mgr = { .bdevs = TAILQ_HEAD_INITIALIZER(g_bdev_mgr.bdevs), }; +struct spdk_bdev_mgmt_channel { +}; + struct spdk_bdev_channel { struct spdk_bdev *bdev; /* The channel for the underlying device */ struct spdk_io_channel *channel; + + /* Channel for the bdev manager */ + struct spdk_io_channel *mgmt_channel; }; struct spdk_bdev * @@ -241,6 +247,17 @@ spdk_bdev_config_text(FILE *fp) } } +static int +spdk_bdev_mgmt_channel_create(void *io_device, void *ctx_buf) +{ + return 0; +} + +static void +spdk_bdev_mgmt_channel_destroy(void *io_device, void *ctx_buf) +{ +} + static int spdk_bdev_initialize(void) { @@ -305,6 +322,10 @@ spdk_bdev_initialize(void) } } + spdk_io_device_register(&g_bdev_mgr, spdk_bdev_mgmt_channel_create, + spdk_bdev_mgmt_channel_destroy, + sizeof(struct spdk_bdev_mgmt_channel)); + return 0; } @@ -349,6 +370,8 @@ spdk_bdev_finish(void) spdk_mempool_free(g_bdev_mgr.buf_small_pool); spdk_mempool_free(g_bdev_mgr.buf_large_pool); + spdk_io_device_unregister(&g_bdev_mgr); + return 0; } @@ -514,6 +537,7 @@ spdk_bdev_channel_create(void *io_device, void *ctx_buf) ch->bdev = io_device; ch->channel = bdev->fn_table->get_io_channel(bdev->ctxt); + ch->mgmt_channel = spdk_get_io_channel(&g_bdev_mgr); return 0; } @@ -524,6 +548,7 @@ spdk_bdev_channel_destroy(void *io_device, void *ctx_buf) struct spdk_bdev_channel *ch = ctx_buf; spdk_put_io_channel(ch->channel); + spdk_put_io_channel(ch->mgmt_channel); } struct spdk_io_channel *