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: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/387679
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Ben Walker 2017-11-14 12:15:58 -07:00
parent 8175e30229
commit 95bbc6bf29
2 changed files with 12 additions and 0 deletions

View File

@ -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.
*/

View File

@ -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)
{