util: defer put_io_channel

With vbdevs, there are many more cases where the last
(or only) channel for a given I/O device may be destroyed
in the context of the poller for that I/O device.  To
avoid returning to the poller and having it check
for data on a resource that was just released, instead
defer the actual put_io_channel work via
spdk_thread_send_msg().

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ic99776bddbe9a305f221f8c094ea97dce2d6df0b

Reviewed-on: https://review.gerrithub.io/368619
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2017-07-07 13:45:12 -07:00
parent be2cb0c535
commit 5533c3d208

View File

@ -273,9 +273,11 @@ spdk_get_io_channel(void *io_device)
return ch;
}
void
spdk_put_io_channel(struct spdk_io_channel *ch)
static void
_spdk_put_io_channel(void *arg)
{
struct spdk_io_channel *ch = arg;
if (ch->ref == 0) {
SPDK_ERRLOG("ref already zero\n");
return;
@ -290,6 +292,12 @@ spdk_put_io_channel(struct spdk_io_channel *ch)
}
}
void
spdk_put_io_channel(struct spdk_io_channel *ch)
{
spdk_thread_send_msg(ch->thread, _spdk_put_io_channel, ch);
}
void *
spdk_io_channel_get_ctx(struct spdk_io_channel *ch)
{