From c94020001adcc0d8fae89ff7902e2e0f2243e25d Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Thu, 30 Aug 2018 13:26:50 -0700 Subject: [PATCH] thread: Add a name parameter to spdk_register_io_device This is a string name used for debugging only. Change-Id: I9827f0e6c83be7bc13951c7b5f0951ce6c2a1ece Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/424127 Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System --- include/spdk/thread.h | 5 ++- lib/bdev/aio/bdev_aio.c | 6 ++- lib/bdev/bdev.c | 18 +++++++- lib/bdev/iscsi/bdev_iscsi.c | 3 +- lib/bdev/null/bdev_null.c | 3 +- lib/bdev/nvme/bdev_nvme.c | 3 +- lib/bdev/part.c | 5 ++- lib/bdev/passthru/vbdev_passthru.c | 3 +- lib/bdev/pmem/bdev_pmem.c | 2 +- lib/bdev/raid/bdev_raid.c | 3 +- lib/bdev/rbd/bdev_rbd.c | 3 +- lib/bdev/virtio/bdev_virtio_blk.c | 3 +- lib/bdev/virtio/bdev_virtio_scsi.c | 3 +- lib/blob/blobstore.c | 2 +- lib/blobfs/blobfs.c | 6 +-- lib/copy/copy_engine.c | 5 ++- lib/copy/ioat/copy_engine_ioat.c | 2 +- lib/nvmf/nvmf.c | 3 +- lib/nvmf/rdma.c | 3 +- lib/thread/thread.c | 45 ++++++++++++------- test/unit/lib/bdev/bdev.c/bdev_ut.c | 2 +- test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c | 3 +- test/unit/lib/bdev/mt/bdev.c/bdev_ut.c | 4 +- test/unit/lib/thread/thread.c/thread_ut.c | 10 ++--- 24 files changed, 95 insertions(+), 50 deletions(-) diff --git a/include/spdk/thread.h b/include/spdk/thread.h index 07352ba32..00590e4fd 100644 --- a/include/spdk/thread.h +++ b/include/spdk/thread.h @@ -291,9 +291,12 @@ void spdk_poller_unregister(struct spdk_poller **ppoller); * I/O channel. * \param ctx_size The size of the context buffer allocated to store references * to allocated I/O channel resources. + * \param name A string name for the device used only for debugging. Optional - + * may be NULL. */ void spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb, - spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size); + spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size, + const char *name); /** * Unregister the opaque io_device context as an I/O device. diff --git a/lib/bdev/aio/bdev_aio.c b/lib/bdev/aio/bdev_aio.c index 4ffe5c208..bb0289ed1 100644 --- a/lib/bdev/aio/bdev_aio.c +++ b/lib/bdev/aio/bdev_aio.c @@ -599,7 +599,8 @@ create_aio_disk(const char *name, const char *filename, uint32_t block_size) fdisk->disk.fn_table = &aio_fn_table; spdk_io_device_register(fdisk, bdev_aio_create_cb, bdev_aio_destroy_cb, - sizeof(struct bdev_aio_io_channel)); + sizeof(struct bdev_aio_io_channel), + fdisk->disk.name); rc = spdk_bdev_register(&fdisk->disk); if (rc) { spdk_io_device_unregister(fdisk, NULL); @@ -664,7 +665,8 @@ bdev_aio_initialize(void) TAILQ_INIT(&g_aio_disk_head); spdk_io_device_register(&aio_if, bdev_aio_group_create_cb, bdev_aio_group_destroy_cb, - sizeof(struct bdev_aio_group_channel)); + sizeof(struct bdev_aio_group_channel), + "aio_module"); sp = spdk_conf_find_section(NULL, "AIO"); if (!sp) { diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 8235aaf72..df6cf45b3 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -813,7 +813,8 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg) spdk_io_device_register(&g_bdev_mgr, spdk_bdev_mgmt_channel_create, spdk_bdev_mgmt_channel_destroy, - sizeof(struct spdk_bdev_mgmt_channel)); + sizeof(struct spdk_bdev_mgmt_channel), + "bdev_mgr"); rc = spdk_bdev_modules_init(); if (rc != 0) { @@ -3036,6 +3037,8 @@ _spdk_bdev_qos_config(struct spdk_bdev *bdev) static int spdk_bdev_init(struct spdk_bdev *bdev) { + char *bdev_name; + assert(bdev->module != NULL); if (!bdev->name) { @@ -3048,6 +3051,14 @@ spdk_bdev_init(struct spdk_bdev *bdev) return -EEXIST; } + /* Users often register their own I/O devices using the bdev name. In + * order to avoid conflicts, prepend bdev_. */ + bdev_name = spdk_sprintf_alloc("bdev_%s", bdev->name); + if (!bdev_name) { + SPDK_ERRLOG("Unable to allocate memory for internal bdev name.\n"); + return -ENOMEM; + } + bdev->internal.status = SPDK_BDEV_STATUS_READY; bdev->internal.measured_queue_depth = UINT64_MAX; @@ -3061,7 +3072,10 @@ spdk_bdev_init(struct spdk_bdev *bdev) spdk_io_device_register(__bdev_to_io_dev(bdev), spdk_bdev_channel_create, spdk_bdev_channel_destroy, - sizeof(struct spdk_bdev_channel)); + sizeof(struct spdk_bdev_channel), + bdev_name); + + free(bdev_name); pthread_mutex_init(&bdev->internal.mutex, NULL); return 0; diff --git a/lib/bdev/iscsi/bdev_iscsi.c b/lib/bdev/iscsi/bdev_iscsi.c index 732116322..d4611359b 100644 --- a/lib/bdev/iscsi/bdev_iscsi.c +++ b/lib/bdev/iscsi/bdev_iscsi.c @@ -613,7 +613,8 @@ create_iscsi_lun(struct iscsi_context *context, char *url, char *initiator_iqn, lun->bdev.fn_table = &iscsi_fn_table; spdk_io_device_register(lun, bdev_iscsi_create_cb, bdev_iscsi_destroy_cb, - sizeof(struct bdev_iscsi_io_channel)); + sizeof(struct bdev_iscsi_io_channel), + name); rc = spdk_bdev_register(&lun->bdev); if (rc) { spdk_io_device_unregister(lun, NULL); diff --git a/lib/bdev/null/bdev_null.c b/lib/bdev/null/bdev_null.c index 40e0987ae..9ff64725d 100644 --- a/lib/bdev/null/bdev_null.c +++ b/lib/bdev/null/bdev_null.c @@ -291,7 +291,8 @@ bdev_null_initialize(void) * address of the global tailq. */ spdk_io_device_register(&g_null_bdev_head, null_bdev_create_cb, null_bdev_destroy_cb, - sizeof(struct null_io_channel)); + sizeof(struct null_io_channel), + "null_bdev"); if (sp == NULL) { goto end; diff --git a/lib/bdev/nvme/bdev_nvme.c b/lib/bdev/nvme/bdev_nvme.c index 33a5191c5..3d3b520c3 100644 --- a/lib/bdev/nvme/bdev_nvme.c +++ b/lib/bdev/nvme/bdev_nvme.c @@ -970,7 +970,8 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr, } spdk_io_device_register(ctrlr, bdev_nvme_create_cb, bdev_nvme_destroy_cb, - sizeof(struct nvme_io_channel)); + sizeof(struct nvme_io_channel), + name); if (nvme_ctrlr_create_bdevs(nvme_ctrlr) != 0) { spdk_io_device_unregister(ctrlr, bdev_nvme_unregister_cb); diff --git a/lib/bdev/part.c b/lib/bdev/part.c index f649eef82..cd652633b 100644 --- a/lib/bdev/part.c +++ b/lib/bdev/part.c @@ -37,6 +37,7 @@ #include "spdk/bdev.h" #include "spdk/log.h" +#include "spdk/string.h" #include "spdk/bdev_module.h" @@ -363,7 +364,9 @@ spdk_bdev_part_construct(struct spdk_bdev_part *part, struct spdk_bdev_part_base spdk_io_device_register(part, spdk_bdev_part_channel_create_cb, spdk_bdev_part_channel_destroy_cb, - base->channel_size); + base->channel_size, + name); + spdk_vbdev_register(&part->internal.bdev, &base->bdev, 1); TAILQ_INSERT_TAIL(base->tailq, part, tailq); diff --git a/lib/bdev/passthru/vbdev_passthru.c b/lib/bdev/passthru/vbdev_passthru.c index 7d0761515..7afd11015 100755 --- a/lib/bdev/passthru/vbdev_passthru.c +++ b/lib/bdev/passthru/vbdev_passthru.c @@ -523,7 +523,8 @@ vbdev_passthru_register(struct spdk_bdev *bdev) TAILQ_INSERT_TAIL(&g_pt_nodes, pt_node, link); spdk_io_device_register(pt_node, pt_bdev_ch_create_cb, pt_bdev_ch_destroy_cb, - sizeof(struct pt_io_channel)); + sizeof(struct pt_io_channel), + name->bdev_name); SPDK_NOTICELOG("io_device created at: 0x%p\n", pt_node); rc = spdk_bdev_open(bdev, true, vbdev_passthru_base_bdev_hotremove_cb, diff --git a/lib/bdev/pmem/bdev_pmem.c b/lib/bdev/pmem/bdev_pmem.c index 2b6b4e5cd..9238e0858 100644 --- a/lib/bdev/pmem/bdev_pmem.c +++ b/lib/bdev/pmem/bdev_pmem.c @@ -442,7 +442,7 @@ bdev_pmem_initialize(void) return -1; } - spdk_io_device_register(&g_pmem_disks, bdev_pmem_create_cb, bdev_pmem_destroy_cb, 0); + spdk_io_device_register(&g_pmem_disks, bdev_pmem_create_cb, bdev_pmem_destroy_cb, 0, "pmem_bdev"); bdev_pmem_read_conf(); diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index e2deeea43..35e09189d 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -1181,7 +1181,8 @@ raid_bdev_configure(struct raid_bdev *raid_bdev) if (raid_bdev->state == RAID_BDEV_STATE_CONFIGURING) { raid_bdev->state = RAID_BDEV_STATE_ONLINE; spdk_io_device_register(raid_bdev, raid_bdev_create_cb, raid_bdev_destroy_cb, - sizeof(struct raid_bdev_io_channel)); + sizeof(struct raid_bdev_io_channel), + raid_bdev->bdev.name); rc = spdk_bdev_register(raid_bdev_gen); if (rc != 0) { /* diff --git a/lib/bdev/rbd/bdev_rbd.c b/lib/bdev/rbd/bdev_rbd.c index 594a65d94..4904d4da2 100644 --- a/lib/bdev/rbd/bdev_rbd.c +++ b/lib/bdev/rbd/bdev_rbd.c @@ -647,7 +647,8 @@ spdk_bdev_rbd_create(const char *name, const char *pool_name, const char *rbd_na spdk_io_device_register(rbd, bdev_rbd_create_cb, bdev_rbd_destroy_cb, - sizeof(struct bdev_rbd_io_channel)); + sizeof(struct bdev_rbd_io_channel), + rbd_name); ret = spdk_bdev_register(&rbd->disk); if (ret) { spdk_io_device_unregister(rbd, NULL); diff --git a/lib/bdev/virtio/bdev_virtio_blk.c b/lib/bdev/virtio/bdev_virtio_blk.c index c1a75a1da..598f7f15f 100644 --- a/lib/bdev/virtio/bdev_virtio_blk.c +++ b/lib/bdev/virtio/bdev_virtio_blk.c @@ -455,7 +455,8 @@ virtio_blk_dev_init(struct virtio_blk_dev *bvdev, uint16_t max_queues) spdk_io_device_register(bvdev, bdev_virtio_blk_ch_create_cb, bdev_virtio_blk_ch_destroy_cb, - sizeof(struct bdev_virtio_blk_io_channel)); + sizeof(struct bdev_virtio_blk_io_channel), + vdev->name); rc = spdk_bdev_register(bdev); if (rc) { diff --git a/lib/bdev/virtio/bdev_virtio_scsi.c b/lib/bdev/virtio/bdev_virtio_scsi.c index 6f75ee896..4ff3db4a3 100644 --- a/lib/bdev/virtio/bdev_virtio_scsi.c +++ b/lib/bdev/virtio/bdev_virtio_scsi.c @@ -295,7 +295,8 @@ virtio_scsi_dev_init(struct virtio_scsi_dev *svdev, uint16_t max_queues) spdk_io_device_register(svdev, bdev_virtio_scsi_ch_create_cb, bdev_virtio_scsi_ch_destroy_cb, - sizeof(struct bdev_virtio_io_channel)); + sizeof(struct bdev_virtio_io_channel), + svdev->vdev.name); pthread_mutex_lock(&g_virtio_scsi_mutex); TAILQ_INSERT_TAIL(&g_virtio_scsi_devs, svdev, tailq); diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 5a09285ce..01546277f 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -2479,7 +2479,7 @@ _spdk_bs_alloc(struct spdk_bs_dev *dev, struct spdk_bs_opts *opts, struct spdk_b pthread_mutex_init(&bs->used_clusters_mutex, NULL); spdk_io_device_register(bs, _spdk_bs_channel_create, _spdk_bs_channel_destroy, - sizeof(struct spdk_bs_channel)); + sizeof(struct spdk_bs_channel), "blobstore"); rc = spdk_bs_register_md_thread(bs); if (rc == -1) { spdk_io_device_unregister(bs, NULL); diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 7e1c42c45..608d49445 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -440,19 +440,19 @@ 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)); + sizeof(struct spdk_fs_channel), "blobfs_md"); fs->md_target.md_io_channel = spdk_get_io_channel(&fs->md_target); 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)); + sizeof(struct spdk_fs_channel), "blobfs_sync"); fs->sync_target.sync_io_channel = spdk_get_io_channel(&fs->sync_target); fs->sync_target.sync_fs_channel = spdk_io_channel_get_ctx(fs->sync_target.sync_io_channel); fs->io_target.max_ops = 512; spdk_io_device_register(&fs->io_target, _spdk_fs_io_channel_create, _spdk_fs_channel_destroy, - sizeof(struct spdk_fs_channel)); + sizeof(struct spdk_fs_channel), "blobfs_io"); return fs; } diff --git a/lib/copy/copy_engine.c b/lib/copy/copy_engine.c index 971f0b753..72ccf9a0d 100644 --- a/lib/copy/copy_engine.c +++ b/lib/copy/copy_engine.c @@ -214,7 +214,8 @@ static int copy_engine_mem_init(void) { spdk_memcpy_register(&memcpy_copy_engine); - spdk_io_device_register(&memcpy_copy_engine, memcpy_create_cb, memcpy_destroy_cb, 0); + spdk_io_device_register(&memcpy_copy_engine, memcpy_create_cb, memcpy_destroy_cb, 0, + "memcpy_engine"); return 0; } @@ -238,7 +239,7 @@ spdk_copy_engine_initialize(void) * spdk_copy_module_list address for this purpose. */ spdk_io_device_register(&spdk_copy_module_list, copy_create_cb, copy_destroy_cb, - sizeof(struct copy_io_channel)); + sizeof(struct copy_io_channel), "copy_module"); return 0; } diff --git a/lib/copy/ioat/copy_engine_ioat.c b/lib/copy/ioat/copy_engine_ioat.c index 625521a5e..40bc6cf54 100644 --- a/lib/copy/ioat/copy_engine_ioat.c +++ b/lib/copy/ioat/copy_engine_ioat.c @@ -386,7 +386,7 @@ copy_engine_ioat_init(void) SPDK_INFOLOG(SPDK_LOG_COPY_IOAT, "Ioat Copy Engine Offload Enabled\n"); spdk_copy_engine_register(&ioat_copy_engine); spdk_io_device_register(&ioat_copy_engine, ioat_create_cb, ioat_destroy_cb, - sizeof(struct ioat_io_channel)); + sizeof(struct ioat_io_channel), "ioat_copy_engine"); return 0; } diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index 3235c0d46..ecf4b61e8 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -258,7 +258,8 @@ spdk_nvmf_tgt_create(struct spdk_nvmf_tgt_opts *opts) spdk_io_device_register(tgt, spdk_nvmf_tgt_create_poll_group, spdk_nvmf_tgt_destroy_poll_group, - sizeof(struct spdk_nvmf_poll_group)); + sizeof(struct spdk_nvmf_poll_group), + "nvmf_tgt"); return tgt; } diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index 8ac75d48f..24ad3f8a3 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -1550,7 +1550,8 @@ spdk_nvmf_rdma_create(struct spdk_nvmf_transport_opts *opts) spdk_io_device_register(rtransport, spdk_nvmf_rdma_mgmt_channel_create, spdk_nvmf_rdma_mgmt_channel_destroy, - sizeof(struct spdk_nvmf_rdma_mgmt_channel)); + sizeof(struct spdk_nvmf_rdma_mgmt_channel), + "rdma_transport"); TAILQ_INIT(&rtransport->devices); TAILQ_INIT(&rtransport->ports); diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 92a8da7f5..bf484ccee 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -50,6 +50,7 @@ static pthread_mutex_t g_devlist_mutex = PTHREAD_MUTEX_INITIALIZER; struct io_device { void *io_device; + char *name; spdk_io_channel_create_cb create_cb; spdk_io_channel_destroy_cb destroy_cb; spdk_io_device_unregister_cb unregister_cb; @@ -344,7 +345,8 @@ spdk_for_each_thread(spdk_thread_fn fn, void *ctx, spdk_thread_fn cpl) void spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb, - spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size) + spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size, + const char *name) { struct io_device *dev, *tmp; @@ -359,6 +361,11 @@ spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb, } dev->io_device = io_device; + if (name) { + dev->name = strdup(name); + } else { + dev->name = spdk_sprintf_alloc("%p", dev); + } dev->create_cb = create_cb; dev->destroy_cb = destroy_cb; dev->unregister_cb = NULL; @@ -367,13 +374,14 @@ spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb, dev->unregistered = false; dev->refcnt = 0; - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Registering io_device %p on thread %s\n", - dev, spdk_get_thread()->name); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Registering io_device %s (%p) on thread %s\n", + dev->name, dev->io_device, spdk_get_thread()->name); pthread_mutex_lock(&g_devlist_mutex); TAILQ_FOREACH(tmp, &g_io_devices, tailq) { if (tmp->io_device == io_device) { SPDK_ERRLOG("io_device %p already registered\n", io_device); + free(dev->name); free(dev); pthread_mutex_unlock(&g_devlist_mutex); return; @@ -388,10 +396,11 @@ _finish_unregister(void *arg) { struct io_device *dev = arg; - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Finishing unregistration of io_device %p on thread %s\n", - dev, dev->unregister_thread->name); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Finishing unregistration of io_device %s (%p) on thread %s\n", + dev->name, dev->io_device, dev->unregister_thread->name); dev->unregister_cb(dev->io_device); + free(dev->name); free(dev); } @@ -399,11 +408,12 @@ static void _spdk_io_device_free(struct io_device *dev) { if (dev->unregister_cb == NULL) { + free(dev->name); free(dev); } else { assert(dev->unregister_thread != NULL); - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "io_device %p needs to unregister from thread %s\n", - dev, dev->unregister_thread->name); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, "io_device %s (%p) needs to unregister from thread %s\n", + dev->name, dev->io_device, dev->unregister_thread->name); spdk_thread_send_msg(dev->unregister_thread, _finish_unregister, dev); } } @@ -444,8 +454,8 @@ spdk_io_device_unregister(void *io_device, spdk_io_device_unregister_cb unregist dev->unregister_thread = thread; pthread_mutex_unlock(&g_devlist_mutex); - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Unregistering io_device %p from thread %s\n", - dev, thread->name); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Unregistering io_device %s (%p) from thread %s\n", + dev->name, dev->io_device, thread->name); if (refcnt > 0) { /* defer deletion */ @@ -486,8 +496,8 @@ spdk_get_io_channel(void *io_device) if (ch->dev == dev) { ch->ref++; - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Get io_channel %p for io_device %p on thread %s refcnt %u\n", - ch, dev, thread->name, ch->ref); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Get io_channel %p for io_device %s (%p) on thread %s refcnt %u\n", + ch, dev->name, dev->io_device, thread->name, ch->ref); /* * An I/O channel already exists for this device on this @@ -511,8 +521,8 @@ spdk_get_io_channel(void *io_device) ch->ref = 1; TAILQ_INSERT_TAIL(&thread->io_channels, ch, tailq); - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Get io_channel %p for io_device %p on thread %s refcnt %u\n", - ch, dev, thread->name, ch->ref); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Get io_channel %p for io_device %s (%p) on thread %s refcnt %u\n", + ch, dev->name, dev->io_device, thread->name, ch->ref); dev->refcnt++; @@ -538,8 +548,8 @@ _spdk_put_io_channel(void *arg) bool do_remove_dev = true; SPDK_DEBUGLOG(SPDK_LOG_THREAD, - "Releasing io_channel %p for io_device %p. Channel thread %p. Current thread %s\n", - ch, ch->dev, ch->thread, spdk_get_thread()->name); + "Releasing io_channel %p for io_device %s (%p). Channel thread %p. Current thread %s\n", + ch, ch->dev->name, ch->dev->io_device, ch->thread, spdk_get_thread()->name); assert(ch->thread == spdk_get_thread()); @@ -581,8 +591,9 @@ _spdk_put_io_channel(void *arg) void spdk_put_io_channel(struct spdk_io_channel *ch) { - SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Putting io_channel %p for io_device %p on thread %s refcnt %u\n", - ch, ch->dev, ch->thread->name, ch->ref); + SPDK_DEBUGLOG(SPDK_LOG_THREAD, + "Putting io_channel %p for io_device %s (%p) on thread %s refcnt %u\n", + ch, ch->dev->name, ch->dev->io_device, ch->thread->name, ch->ref); ch->ref--; diff --git a/test/unit/lib/bdev/bdev.c/bdev_ut.c b/test/unit/lib/bdev/bdev.c/bdev_ut.c index a600a7193..3b4ce193a 100644 --- a/test/unit/lib/bdev/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/bdev.c/bdev_ut.c @@ -202,7 +202,7 @@ static int bdev_ut_module_init(void) { spdk_io_device_register(&g_bdev_ut_io_device, bdev_ut_create_ch, bdev_ut_destroy_ch, - sizeof(struct bdev_ut_channel)); + sizeof(struct bdev_ut_channel), NULL); return 0; } diff --git a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c index d1733a5e3..9505d5f60 100644 --- a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c +++ b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c @@ -269,7 +269,8 @@ spdk_sprintf_alloc(const char *format, ...) void spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb, - spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size) + spdk_io_channel_destroy_cb destroy_cb, uint32_t ctx_size, + const char *name) { } diff --git a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c index e75c19227..543c9ac5d 100644 --- a/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/mt/bdev.c/bdev_ut.c @@ -258,7 +258,7 @@ setup_test(void) allocate_threads(BDEV_UT_NUM_THREADS); spdk_bdev_initialize(bdev_init_cb, &done); spdk_io_device_register(&g_io_device, stub_create_ch, stub_destroy_ch, - sizeof(struct ut_bdev_channel)); + sizeof(struct ut_bdev_channel), NULL); register_bdev(&g_bdev, "ut_bdev", &g_io_device); spdk_bdev_open(&g_bdev.bdev, true, NULL, NULL, &g_desc); } @@ -1011,7 +1011,7 @@ enomem_multi_io_target(void) /* Create new io_target and a second bdev using it */ spdk_io_device_register(&new_io_device, stub_create_ch, stub_destroy_ch, - sizeof(struct ut_bdev_channel)); + sizeof(struct ut_bdev_channel), NULL); second_bdev = calloc(1, sizeof(*second_bdev)); SPDK_CU_ASSERT_FATAL(second_bdev != NULL); register_bdev(second_bdev, "ut_bdev2", &new_io_device); diff --git a/test/unit/lib/thread/thread.c/thread_ut.c b/test/unit/lib/thread/thread.c/thread_ut.c index e8326b372..464e430f2 100644 --- a/test/unit/lib/thread/thread.c/thread_ut.c +++ b/test/unit/lib/thread/thread.c/thread_ut.c @@ -227,7 +227,7 @@ for_each_channel_remove(void) int count = 0; allocate_threads(3); - spdk_io_device_register(&io_target, channel_create, channel_destroy, sizeof(int)); + spdk_io_device_register(&io_target, channel_create, channel_destroy, sizeof(int), NULL); set_thread(0); ch0 = spdk_get_io_channel(&io_target); set_thread(1); @@ -302,7 +302,7 @@ for_each_channel_unreg(void) allocate_threads(1); CU_ASSERT(TAILQ_EMPTY(&g_io_devices)); - spdk_io_device_register(&io_target, channel_create, channel_destroy, sizeof(int)); + spdk_io_device_register(&io_target, channel_create, channel_destroy, sizeof(int), NULL); CU_ASSERT(!TAILQ_EMPTY(&g_io_devices)); dev = TAILQ_FIRST(&g_io_devices); SPDK_CU_ASSERT_FATAL(dev != NULL); @@ -317,7 +317,7 @@ for_each_channel_unreg(void) * have removed the device. */ CU_ASSERT(dev == TAILQ_FIRST(&g_io_devices)); - spdk_io_device_register(&io_target, channel_create, channel_destroy, sizeof(int)); + spdk_io_device_register(&io_target, channel_create, channel_destroy, sizeof(int), NULL); /* * There is already a device registered at &io_target, so a new io_device should not * have been added to g_io_devices. @@ -418,8 +418,8 @@ channel(void) void *ctx; spdk_allocate_thread(_send_msg, NULL, NULL, NULL, "thread0"); - spdk_io_device_register(&device1, create_cb_1, destroy_cb_1, sizeof(ctx1)); - spdk_io_device_register(&device2, create_cb_2, destroy_cb_2, sizeof(ctx2)); + spdk_io_device_register(&device1, create_cb_1, destroy_cb_1, sizeof(ctx1), NULL); + spdk_io_device_register(&device2, create_cb_2, destroy_cb_2, sizeof(ctx2), NULL); g_create_cb_calls = 0; ch1 = spdk_get_io_channel(&device1);