Commit 95bbc6bf authored by Ben Walker's avatar Ben Walker
Browse files

io_channel: Add spdk_io_channel_from_ctx



This is the inverse operation of spdk_io_channel_get_ctx.

Change-Id: Ica6593240dfb05cb53dc7ec910bc0a78270e81c0
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387679


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 8175e302
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -154,6 +154,12 @@ void spdk_put_io_channel(struct spdk_io_channel *ch);
 */
void *spdk_io_channel_get_ctx(struct spdk_io_channel *ch);

/**
 *  \brief Returns an I/O channel from a context buffer. This is
 * the inverse of spdk_io_channel_get_ctx().
 */
struct spdk_io_channel *spdk_io_channel_from_ctx(void *ctx);

/**
 * \brief Returns the spdk_thread associated with an I/O channel.
 */
+6 −0
Original line number Diff line number Diff line
@@ -400,6 +400,12 @@ spdk_io_channel_get_ctx(struct spdk_io_channel *ch)
	return (uint8_t *)ch + sizeof(*ch);
}

struct spdk_io_channel *
spdk_io_channel_from_ctx(void *ctx)
{
	return (struct spdk_io_channel *)((uint8_t *)ctx - sizeof(struct spdk_io_channel));
}

struct spdk_thread *
spdk_io_channel_get_thread(struct spdk_io_channel *ch)
{