bdev/aio: Move aio context onto group channel
We only need one aio context for the entire set of channels sharing a thread. Change-Id: I1143247901586efe50530b28323ddb923bc6b242 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/443314 Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
318bd602ac
commit
6bb59dff48
@ -49,7 +49,6 @@
|
|||||||
#include <libaio.h>
|
#include <libaio.h>
|
||||||
|
|
||||||
struct bdev_aio_io_channel {
|
struct bdev_aio_io_channel {
|
||||||
io_context_t io_ctx;
|
|
||||||
uint64_t io_inflight;
|
uint64_t io_inflight;
|
||||||
struct bdev_aio_group_channel *group_ch;
|
struct bdev_aio_group_channel *group_ch;
|
||||||
TAILQ_ENTRY(bdev_aio_io_channel) link;
|
TAILQ_ENTRY(bdev_aio_io_channel) link;
|
||||||
@ -58,6 +57,8 @@ struct bdev_aio_io_channel {
|
|||||||
struct bdev_aio_group_channel {
|
struct bdev_aio_group_channel {
|
||||||
struct spdk_poller *poller;
|
struct spdk_poller *poller;
|
||||||
|
|
||||||
|
io_context_t io_ctx;
|
||||||
|
|
||||||
TAILQ_HEAD(, bdev_aio_io_channel) channels;
|
TAILQ_HEAD(, bdev_aio_io_channel) channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ bdev_aio_readv(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
|||||||
SPDK_DEBUGLOG(SPDK_LOG_AIO, "read %d iovs size %lu to off: %#lx\n",
|
SPDK_DEBUGLOG(SPDK_LOG_AIO, "read %d iovs size %lu to off: %#lx\n",
|
||||||
iovcnt, nbytes, offset);
|
iovcnt, nbytes, offset);
|
||||||
|
|
||||||
rc = io_submit(aio_ch->io_ctx, 1, &iocb);
|
rc = io_submit(aio_ch->group_ch->io_ctx, 1, &iocb);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (rc == -EAGAIN) {
|
if (rc == -EAGAIN) {
|
||||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_NOMEM);
|
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_NOMEM);
|
||||||
@ -194,7 +195,7 @@ bdev_aio_writev(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
|||||||
SPDK_DEBUGLOG(SPDK_LOG_AIO, "write %d iovs size %lu from off: %#lx\n",
|
SPDK_DEBUGLOG(SPDK_LOG_AIO, "write %d iovs size %lu from off: %#lx\n",
|
||||||
iovcnt, len, offset);
|
iovcnt, len, offset);
|
||||||
|
|
||||||
rc = io_submit(aio_ch->io_ctx, 1, &iocb);
|
rc = io_submit(aio_ch->group_ch->io_ctx, 1, &iocb);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (rc == -EAGAIN) {
|
if (rc == -EAGAIN) {
|
||||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_NOMEM);
|
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_NOMEM);
|
||||||
@ -237,8 +238,7 @@ static int
|
|||||||
bdev_aio_group_poll(void *arg)
|
bdev_aio_group_poll(void *arg)
|
||||||
{
|
{
|
||||||
struct bdev_aio_group_channel *group_ch = arg;
|
struct bdev_aio_group_channel *group_ch = arg;
|
||||||
struct bdev_aio_io_channel *ch, *tch;
|
int nr, i = 0;
|
||||||
int nr, i, total_nr = 0;
|
|
||||||
enum spdk_bdev_io_status status;
|
enum spdk_bdev_io_status status;
|
||||||
struct bdev_aio_task *aio_task;
|
struct bdev_aio_task *aio_task;
|
||||||
struct timespec timeout;
|
struct timespec timeout;
|
||||||
@ -247,16 +247,13 @@ bdev_aio_group_poll(void *arg)
|
|||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_nsec = 0;
|
timeout.tv_nsec = 0;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(ch, &group_ch->channels, link, tch) {
|
nr = io_getevents(group_ch->io_ctx, 1, SPDK_AIO_QUEUE_DEPTH,
|
||||||
nr = io_getevents(ch->io_ctx, 1, SPDK_AIO_QUEUE_DEPTH,
|
|
||||||
events, &timeout);
|
events, &timeout);
|
||||||
|
|
||||||
if (nr < 0) {
|
if (nr < 0) {
|
||||||
SPDK_ERRLOG("Returned %d on bdev_aio_io_channel %p\n", nr, ch);
|
return -1;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
total_nr += nr;
|
|
||||||
for (i = 0; i < nr; i++) {
|
for (i = 0; i < nr; i++) {
|
||||||
aio_task = events[i].data;
|
aio_task = events[i].data;
|
||||||
if (events[i].res != aio_task->len) {
|
if (events[i].res != aio_task->len) {
|
||||||
@ -266,11 +263,10 @@ bdev_aio_group_poll(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), status);
|
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), status);
|
||||||
ch->io_inflight--;
|
aio_task->ch->io_inflight--;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -406,12 +402,8 @@ bdev_aio_create_cb(void *io_device, void *ctx_buf)
|
|||||||
{
|
{
|
||||||
struct bdev_aio_io_channel *ch = ctx_buf;
|
struct bdev_aio_io_channel *ch = ctx_buf;
|
||||||
|
|
||||||
if (io_setup(SPDK_AIO_QUEUE_DEPTH, &ch->io_ctx) < 0) {
|
|
||||||
SPDK_ERRLOG("async I/O context setup failure\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ch->group_ch = spdk_io_channel_get_ctx(spdk_get_io_channel(&aio_if));
|
ch->group_ch = spdk_io_channel_get_ctx(spdk_get_io_channel(&aio_if));
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&ch->group_ch->channels, ch, link);
|
TAILQ_INSERT_TAIL(&ch->group_ch->channels, ch, link);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -424,7 +416,6 @@ bdev_aio_destroy_cb(void *io_device, void *ctx_buf)
|
|||||||
|
|
||||||
TAILQ_REMOVE(&ch->group_ch->channels, ch, link);
|
TAILQ_REMOVE(&ch->group_ch->channels, ch, link);
|
||||||
spdk_put_io_channel(spdk_io_channel_from_ctx(ch->group_ch));
|
spdk_put_io_channel(spdk_io_channel_from_ctx(ch->group_ch));
|
||||||
io_destroy(ch->io_ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct spdk_io_channel *
|
static struct spdk_io_channel *
|
||||||
@ -496,6 +487,11 @@ bdev_aio_group_create_cb(void *io_device, void *ctx_buf)
|
|||||||
|
|
||||||
TAILQ_INIT(&ch->channels);
|
TAILQ_INIT(&ch->channels);
|
||||||
|
|
||||||
|
if (io_setup(SPDK_AIO_QUEUE_DEPTH, &ch->io_ctx) < 0) {
|
||||||
|
SPDK_ERRLOG("async I/O context setup failure\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ch->poller = spdk_poller_register(bdev_aio_group_poll, ch, 0);
|
ch->poller = spdk_poller_register(bdev_aio_group_poll, ch, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -505,6 +501,8 @@ bdev_aio_group_destroy_cb(void *io_device, void *ctx_buf)
|
|||||||
{
|
{
|
||||||
struct bdev_aio_group_channel *ch = ctx_buf;
|
struct bdev_aio_group_channel *ch = ctx_buf;
|
||||||
|
|
||||||
|
io_destroy(ch->io_ctx);
|
||||||
|
|
||||||
spdk_poller_unregister(&ch->poller);
|
spdk_poller_unregister(&ch->poller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user