diff --git a/include/spdk/io_channel.h b/include/spdk/io_channel.h index 8f5f77c52..5313083c9 100644 --- a/include/spdk/io_channel.h +++ b/include/spdk/io_channel.h @@ -46,8 +46,7 @@ struct spdk_io_channel; -typedef int (*io_channel_create_cb_t)(void *io_device, uint32_t priority, void *ctx_buf, - void *unique_ctx); +typedef int (*io_channel_create_cb_t)(void *io_device, uint32_t priority, void *ctx_buf); typedef void (*io_channel_destroy_cb_t)(void *io_device, void *ctx_buf); /** @@ -97,15 +96,8 @@ void spdk_io_device_unregister(void *io_device); * The priority parameter allows callers to create different I/O channels to the same * I/O device with varying priorities. Currently this value must be set to * SPDK_IO_PRIORITY_DEFAULT. - * - * The unique parameter allows callers to specify that an existing channel should not - * be used to satisfy this request, even if the io_device and priority fields match. - * - * The unique_ctx parameter allows callers to pass channel-specific context to the create_cb - * handler for unique channels. This value must be NULL for shared channels. */ -struct spdk_io_channel *spdk_get_io_channel(void *io_device, uint32_t priority, bool unique, - void *unique_ctx); +struct spdk_io_channel *spdk_get_io_channel(void *io_device, uint32_t priority); /** * \brief Releases a reference to an I/O channel. diff --git a/lib/bdev/aio/blockdev_aio.c b/lib/bdev/aio/blockdev_aio.c index 596911295..27b8d0393 100644 --- a/lib/bdev/aio/blockdev_aio.c +++ b/lib/bdev/aio/blockdev_aio.c @@ -290,7 +290,7 @@ blockdev_aio_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type) } static int -blockdev_aio_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +blockdev_aio_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { struct blockdev_aio_io_channel *ch = ctx_buf; @@ -318,7 +318,7 @@ blockdev_aio_get_io_channel(void *ctx, uint32_t priority) { struct file_disk *fdisk = ctx; - return spdk_get_io_channel(&fdisk->fd, priority, false, NULL); + return spdk_get_io_channel(&fdisk->fd, priority); } static const struct spdk_bdev_fn_table aio_fn_table = { diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 3399811ed..24ccd570c 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -507,8 +507,7 @@ spdk_bdev_dump_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w } static int -spdk_bdev_channel_create(void *io_device, uint32_t priority, void *ctx_buf, - void *unique_ctx) +spdk_bdev_channel_create(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_bdev *bdev = io_device; struct spdk_bdev_channel *ch = ctx_buf; @@ -530,7 +529,7 @@ spdk_bdev_channel_destroy(void *io_device, void *ctx_buf) struct spdk_io_channel * spdk_bdev_get_io_channel(struct spdk_bdev *bdev, uint32_t priority) { - return spdk_get_io_channel(bdev, priority, false, NULL); + return spdk_get_io_channel(bdev, priority); } const char * diff --git a/lib/bdev/null/blockdev_null.c b/lib/bdev/null/blockdev_null.c index eee21b221..2ea192b9b 100644 --- a/lib/bdev/null/blockdev_null.c +++ b/lib/bdev/null/blockdev_null.c @@ -110,7 +110,7 @@ blockdev_null_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type) static struct spdk_io_channel * blockdev_null_get_io_channel(void *ctx, uint32_t priority) { - return spdk_get_io_channel(&g_null_bdev_head, priority, false, NULL); + return spdk_get_io_channel(&g_null_bdev_head, priority); } static const struct spdk_bdev_fn_table null_fn_table = { @@ -160,7 +160,7 @@ create_null_bdev(const char *name, uint64_t num_blocks, uint32_t block_size) } static int -null_bdev_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +null_bdev_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { return 0; } diff --git a/lib/bdev/nvme/blockdev_nvme.c b/lib/bdev/nvme/blockdev_nvme.c index 66500ea3c..7b946cee9 100644 --- a/lib/bdev/nvme/blockdev_nvme.c +++ b/lib/bdev/nvme/blockdev_nvme.c @@ -343,7 +343,7 @@ bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type) } static int -bdev_nvme_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +bdev_nvme_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_nvme_ctrlr *ctrlr = io_device; struct nvme_io_channel *ch = ctx_buf; @@ -373,7 +373,7 @@ bdev_nvme_get_io_channel(void *ctx, uint32_t priority) { struct nvme_bdev *nvme_bdev = ctx; - return spdk_get_io_channel(nvme_bdev->nvme_ctrlr->ctrlr, priority, false, NULL); + return spdk_get_io_channel(nvme_bdev->nvme_ctrlr->ctrlr, priority); } static int diff --git a/lib/bdev/rbd/blockdev_rbd.c b/lib/bdev/rbd/blockdev_rbd.c index 7f04203cb..fee0719bb 100644 --- a/lib/bdev/rbd/blockdev_rbd.c +++ b/lib/bdev/rbd/blockdev_rbd.c @@ -399,8 +399,7 @@ blockdev_rbd_handle(void *arg) } static int -blockdev_rbd_create_cb(void *io_device, uint32_t priority, - void *ctx_buf, void *unique_ctx) +blockdev_rbd_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { struct blockdev_rbd_io_channel *ch = ctx_buf; int ret; @@ -466,7 +465,7 @@ blockdev_rbd_get_io_channel(void *ctx, uint32_t priority) { struct blockdev_rbd *rbd_bdev = ctx; - return spdk_get_io_channel(&rbd_bdev->info, priority, false, NULL); + return spdk_get_io_channel(&rbd_bdev->info, priority); } static const struct spdk_bdev_fn_table rbd_fn_table = { diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 5ecec170f..977382dc5 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -1077,7 +1077,7 @@ _spdk_bs_channel_create(struct spdk_blob_store *bs, struct spdk_bs_channel *chan } static int -_spdk_bs_md_channel_create(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +_spdk_bs_md_channel_create(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_blob_store *bs; struct spdk_bs_channel *channel = ctx_buf; @@ -1088,7 +1088,7 @@ _spdk_bs_md_channel_create(void *io_device, uint32_t priority, void *ctx_buf, vo } static int -_spdk_bs_io_channel_create(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +_spdk_bs_io_channel_create(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_blob_store *bs; struct spdk_bs_channel *channel = ctx_buf; @@ -1761,8 +1761,7 @@ spdk_bs_free_cluster_count(struct spdk_blob_store *bs) int spdk_bs_register_md_thread(struct spdk_blob_store *bs) { - bs->md_target.md_channel = spdk_get_io_channel(&bs->md_target, SPDK_IO_PRIORITY_DEFAULT, - false, NULL); + bs->md_target.md_channel = spdk_get_io_channel(&bs->md_target, SPDK_IO_PRIORITY_DEFAULT); return 0; } @@ -2105,7 +2104,7 @@ void spdk_bs_md_close_blob(struct spdk_blob **b, struct spdk_io_channel *spdk_bs_alloc_io_channel(struct spdk_blob_store *bs, uint32_t priority) { - return spdk_get_io_channel(&bs->io_target, priority, false, NULL); + return spdk_get_io_channel(&bs->io_target, priority); } void spdk_bs_free_io_channel(struct spdk_io_channel *channel) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 0f1d4a845..fecfc130f 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -272,7 +272,7 @@ _spdk_fs_channel_create(struct spdk_filesystem *fs, struct spdk_fs_channel *chan } static int -_spdk_fs_md_channel_create(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +_spdk_fs_md_channel_create(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_filesystem *fs; struct spdk_fs_channel *channel = ctx_buf; @@ -283,7 +283,7 @@ _spdk_fs_md_channel_create(void *io_device, uint32_t priority, void *ctx_buf, vo } static int -_spdk_fs_sync_channel_create(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +_spdk_fs_sync_channel_create(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_filesystem *fs; struct spdk_fs_channel *channel = ctx_buf; @@ -294,7 +294,7 @@ _spdk_fs_sync_channel_create(void *io_device, uint32_t priority, void *ctx_buf, } static int -_spdk_fs_io_channel_create(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +_spdk_fs_io_channel_create(void *io_device, uint32_t priority, void *ctx_buf) { struct spdk_filesystem *fs; struct spdk_fs_channel *channel = ctx_buf; @@ -369,15 +369,13 @@ fs_alloc(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn) fs->md_target.max_ops = 512; spdk_io_device_register(&fs->md_target, _spdk_fs_md_channel_create, _spdk_fs_channel_destroy, sizeof(struct spdk_fs_channel)); - fs->md_target.md_io_channel = spdk_get_io_channel(&fs->md_target, SPDK_IO_PRIORITY_DEFAULT, false, - NULL); + fs->md_target.md_io_channel = spdk_get_io_channel(&fs->md_target, SPDK_IO_PRIORITY_DEFAULT); fs->md_target.md_fs_channel = spdk_io_channel_get_ctx(fs->md_target.md_io_channel); fs->sync_target.max_ops = 512; spdk_io_device_register(&fs->sync_target, _spdk_fs_sync_channel_create, _spdk_fs_channel_destroy, sizeof(struct spdk_fs_channel)); - fs->sync_target.sync_io_channel = spdk_get_io_channel(&fs->sync_target, SPDK_IO_PRIORITY_DEFAULT, - false, NULL); + fs->sync_target.sync_io_channel = spdk_get_io_channel(&fs->sync_target, SPDK_IO_PRIORITY_DEFAULT); fs->sync_target.sync_fs_channel = spdk_io_channel_get_ctx(fs->sync_target.sync_io_channel); fs->io_target.max_ops = 512; @@ -1423,7 +1421,7 @@ spdk_fs_alloc_io_channel(struct spdk_filesystem *fs, uint32_t priority) struct spdk_io_channel *io_channel; struct spdk_fs_channel *fs_channel; - io_channel = spdk_get_io_channel(&fs->io_target, priority, false, NULL); + io_channel = spdk_get_io_channel(&fs->io_target, priority); fs_channel = spdk_io_channel_get_ctx(io_channel); fs_channel->bs_channel = spdk_bs_alloc_io_channel(fs->bs, SPDK_IO_PRIORITY_DEFAULT); fs_channel->send_request = __send_request_direct; @@ -1437,7 +1435,7 @@ spdk_fs_alloc_io_channel_sync(struct spdk_filesystem *fs, uint32_t priority) struct spdk_io_channel *io_channel; struct spdk_fs_channel *fs_channel; - io_channel = spdk_get_io_channel(&fs->io_target, priority, false, NULL); + io_channel = spdk_get_io_channel(&fs->io_target, priority); fs_channel = spdk_io_channel_get_ctx(io_channel); fs_channel->send_request = fs->send_request; diff --git a/lib/copy/copy_engine.c b/lib/copy/copy_engine.c index fa24359e0..06812c6b5 100644 --- a/lib/copy/copy_engine.c +++ b/lib/copy/copy_engine.c @@ -139,7 +139,7 @@ static struct spdk_copy_engine memcpy_copy_engine = { }; static int -memcpy_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +memcpy_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { return 0; } @@ -151,7 +151,7 @@ memcpy_destroy_cb(void *io_device, void *ctx_buf) static struct spdk_io_channel *mem_get_io_channel(uint32_t priority) { - return spdk_get_io_channel(&memcpy_copy_engine, priority, false, NULL); + return spdk_get_io_channel(&memcpy_copy_engine, priority); } static size_t @@ -175,7 +175,7 @@ void spdk_copy_module_list_add(struct spdk_copy_module_if *copy_module) } static int -copy_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +copy_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { struct copy_io_channel *copy_ch = ctx_buf; @@ -204,7 +204,7 @@ copy_destroy_cb(void *io_device, void *ctx_buf) struct spdk_io_channel * spdk_copy_engine_get_io_channel(uint32_t priority) { - return spdk_get_io_channel(&spdk_copy_module_list, priority, false, NULL); + return spdk_get_io_channel(&spdk_copy_module_list, priority); } static int diff --git a/lib/copy/ioat/copy_engine_ioat.c b/lib/copy/ioat/copy_engine_ioat.c index 305e38d8d..a63083c06 100644 --- a/lib/copy/ioat/copy_engine_ioat.c +++ b/lib/copy/ioat/copy_engine_ioat.c @@ -191,7 +191,7 @@ static struct spdk_copy_engine ioat_copy_engine = { }; static int -ioat_create_cb(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +ioat_create_cb(void *io_device, uint32_t priority, void *ctx_buf) { struct ioat_io_channel *ch = ctx_buf; struct ioat_device *ioat_dev; @@ -220,7 +220,7 @@ ioat_destroy_cb(void *io_device, void *ctx_buf) static struct spdk_io_channel * ioat_get_io_channel(uint32_t priority) { - return spdk_get_io_channel(&ioat_copy_engine, priority, false, NULL); + return spdk_get_io_channel(&ioat_copy_engine, priority); } struct ioat_probe_ctx { diff --git a/lib/util/io_channel.c b/lib/util/io_channel.c index ce6260055..34b2cfc8a 100644 --- a/lib/util/io_channel.c +++ b/lib/util/io_channel.c @@ -127,7 +127,7 @@ spdk_io_device_unregister(void *io_device) } struct spdk_io_channel * -spdk_get_io_channel(void *io_device, uint32_t priority, bool unique, void *unique_ctx) +spdk_get_io_channel(void *io_device, uint32_t priority) { struct spdk_io_channel *ch; struct io_device *dev; @@ -138,11 +138,6 @@ spdk_get_io_channel(void *io_device, uint32_t priority, bool unique, void *uniqu return NULL; } - if (unique == false && unique_ctx != NULL) { - SPDK_ERRLOG("non-NULL unique_ctx passed for shared channel\n"); - return NULL; - } - pthread_mutex_lock(&g_devlist_mutex); TAILQ_FOREACH(dev, &g_io_devices, tailq) { if (dev->io_device_ctx == io_device) { @@ -156,16 +151,14 @@ spdk_get_io_channel(void *io_device, uint32_t priority, bool unique, void *uniqu } pthread_mutex_unlock(&g_devlist_mutex); - if (unique == false) { - TAILQ_FOREACH(ch, &g_io_channels, tailq) { - if (ch->io_device == io_device && ch->priority == priority) { - ch->ref++; - /* - * An I/O channel already exists for this device on this - * thread, so return it. - */ - return ch; - } + TAILQ_FOREACH(ch, &g_io_channels, tailq) { + if (ch->io_device == io_device && ch->priority == priority) { + ch->ref++; + /* + * An I/O channel already exists for this device on this + * thread, so return it. + */ + return ch; } } @@ -174,7 +167,7 @@ spdk_get_io_channel(void *io_device, uint32_t priority, bool unique, void *uniqu SPDK_ERRLOG("could not calloc spdk_io_channel\n"); return NULL; } - rc = dev->create_cb(io_device, priority, (uint8_t *)ch + sizeof(*ch), unique_ctx); + rc = dev->create_cb(io_device, priority, (uint8_t *)ch + sizeof(*ch)); if (rc == -1) { free(ch); return NULL; diff --git a/test/lib/util/io_channel/io_channel_ut.c b/test/lib/util/io_channel/io_channel_ut.c index 7b3175ea0..2005d7f2b 100644 --- a/test/lib/util/io_channel/io_channel_ut.c +++ b/test/lib/util/io_channel/io_channel_ut.c @@ -55,7 +55,7 @@ static int g_create_cb_calls = 0; static int g_destroy_cb_calls = 0; static int -create_cb_1(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +create_cb_1(void *io_device, uint32_t priority, void *ctx_buf) { CU_ASSERT(io_device == &device1); CU_ASSERT(priority == SPDK_IO_PRIORITY_DEFAULT); @@ -73,15 +73,12 @@ destroy_cb_1(void *io_device, void *ctx_buf) } static int -create_cb_2(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +create_cb_2(void *io_device, uint32_t priority, void *ctx_buf) { CU_ASSERT(io_device == &device2); CU_ASSERT(priority == SPDK_IO_PRIORITY_DEFAULT); *(uint64_t *)ctx_buf = ctx2; g_create_cb_calls++; - if (unique_ctx != NULL) { - *(int *)unique_ctx = ~(*(int *)unique_ctx); - } return 0; } @@ -94,7 +91,7 @@ destroy_cb_2(void *io_device, void *ctx_buf) } static int -create_cb_null(void *io_device, uint32_t priority, void *ctx_buf, void *unique_ctx) +create_cb_null(void *io_device, uint32_t priority, void *ctx_buf) { return -1; } @@ -102,8 +99,7 @@ create_cb_null(void *io_device, uint32_t priority, void *ctx_buf, void *unique_c static void channel(void) { - struct spdk_io_channel *ch1, *ch2, *ch3; - int tmp; + struct spdk_io_channel *ch1, *ch2; void *ctx; spdk_allocate_thread(); @@ -112,12 +108,12 @@ channel(void) spdk_io_device_register(&device3, create_cb_null, NULL, 0); g_create_cb_calls = 0; - ch1 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT, false, NULL); + ch1 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT); CU_ASSERT(g_create_cb_calls == 1); SPDK_CU_ASSERT_FATAL(ch1 != NULL); g_create_cb_calls = 0; - ch2 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT, false, NULL); + ch2 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT); CU_ASSERT(g_create_cb_calls == 0); CU_ASSERT(ch1 == ch2); SPDK_CU_ASSERT_FATAL(ch2 != NULL); @@ -127,7 +123,7 @@ channel(void) CU_ASSERT(g_destroy_cb_calls == 0); g_create_cb_calls = 0; - ch2 = spdk_get_io_channel(&device2, SPDK_IO_PRIORITY_DEFAULT, false, NULL); + ch2 = spdk_get_io_channel(&device2, SPDK_IO_PRIORITY_DEFAULT); CU_ASSERT(g_create_cb_calls == 1); CU_ASSERT(ch1 != ch2); SPDK_CU_ASSERT_FATAL(ch2 != NULL); @@ -135,18 +131,6 @@ channel(void) ctx = spdk_io_channel_get_ctx(ch2); CU_ASSERT(*(uint64_t *)ctx == ctx2); - /* - * Confirm that specifying unique==true will generate a new I/O channel, - * and reuse ch2. - */ - g_create_cb_calls = 0; - tmp = 0x5a5a; - ch3 = spdk_get_io_channel(&device2, SPDK_IO_PRIORITY_DEFAULT, true, &tmp); - CU_ASSERT(g_create_cb_calls == 1); - CU_ASSERT(ch2 != ch3); - SPDK_CU_ASSERT_FATAL(ch3 != NULL); - CU_ASSERT(tmp == ~0x5a5a); - g_destroy_cb_calls = 0; spdk_put_io_channel(ch1); CU_ASSERT(g_destroy_cb_calls == 1); @@ -155,19 +139,11 @@ channel(void) spdk_put_io_channel(ch2); CU_ASSERT(g_destroy_cb_calls == 1); - g_destroy_cb_calls = 0; - spdk_put_io_channel(ch3); - CU_ASSERT(g_destroy_cb_calls == 1); - - ch1 = spdk_get_io_channel(&device3, SPDK_IO_PRIORITY_DEFAULT, false, NULL); + ch1 = spdk_get_io_channel(&device3, SPDK_IO_PRIORITY_DEFAULT); CU_ASSERT(ch1 == NULL); /* Confirm failure if user specifies an invalid I/O priority. */ - ch1 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT + 1, false, NULL); - CU_ASSERT(ch1 == NULL); - - /* Confirm failure if user specifies non-NULL unique_ctx for a shared channel. */ - ch1 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT, false, &tmp); + ch1 = spdk_get_io_channel(&device1, SPDK_IO_PRIORITY_DEFAULT + 1); CU_ASSERT(ch1 == NULL); spdk_io_device_unregister(&device1);