diff --git a/include/spdk/io_channel.h b/include/spdk/io_channel.h index aea084a75..996037dec 100644 --- a/include/spdk/io_channel.h +++ b/include/spdk/io_channel.h @@ -78,6 +78,8 @@ void spdk_free_thread(void); /** * \brief Get a handle to the current thread. This handle may be passed * to other threads and used as the target of spdk_thread_send_msg(). + * + * \sa spdk_io_channel_get_thread() */ struct spdk_thread *spdk_get_thread(void); @@ -140,6 +142,11 @@ void spdk_put_io_channel(struct spdk_io_channel *ch); */ void *spdk_io_channel_get_ctx(struct spdk_io_channel *ch); +/** + * \brief Returns the spdk_thread associated with an I/O channel. + */ +struct spdk_thread *spdk_io_channel_get_thread(struct spdk_io_channel *ch); + /** * \brief Call 'fn' on each channel associated with io_device. This happens * asynchronously, so fn may be called after spdk_for_each_channel returns. diff --git a/lib/util/io_channel.c b/lib/util/io_channel.c index 8d1f30f62..5a3609cc4 100644 --- a/lib/util/io_channel.c +++ b/lib/util/io_channel.c @@ -296,6 +296,12 @@ spdk_io_channel_get_ctx(struct spdk_io_channel *ch) return (uint8_t *)ch + sizeof(*ch); } +struct spdk_thread * +spdk_io_channel_get_thread(struct spdk_io_channel *ch) +{ + return ch->thread; +} + struct call_channel { void *io_device; spdk_channel_msg fn;