diff options
author | Stefan Hajnoczi | 2020-03-05 18:08:03 +0100 |
---|---|---|
committer | Stefan Hajnoczi | 2020-03-09 17:41:31 +0100 |
commit | b321051cf48ccc2d3d832af111d688f2282f089b (patch) | |
tree | 32317a09036588fd33643a5e844da001b4bf5ddd /util | |
parent | aio-posix: extract ppoll(2) and epoll(7) fd monitoring (diff) | |
download | qemu-b321051cf48ccc2d3d832af111d688f2282f089b.tar.gz qemu-b321051cf48ccc2d3d832af111d688f2282f089b.tar.xz qemu-b321051cf48ccc2d3d832af111d688f2282f089b.zip |
aio-posix: simplify FDMonOps->update() prototype
The AioHandler *node, bool is_new arguments are more complicated to
think about than simply being given AioHandler *old_node, AioHandler
*new_node.
Furthermore, the new Linux io_uring file descriptor monitoring mechanism
added by the new patch requires access to both the old and the new
nodes. Make this change now in preparation.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Link: https://lore.kernel.org/r/20200305170806.1313245-5-stefanha@redhat.com
Message-Id: <20200305170806.1313245-5-stefanha@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/aio-posix.c | 7 | ||||
-rw-r--r-- | util/fdmon-epoll.c | 21 | ||||
-rw-r--r-- | util/fdmon-poll.c | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/util/aio-posix.c b/util/aio-posix.c index bc0b86547c..028b2abded 100644 --- a/util/aio-posix.c +++ b/util/aio-posix.c @@ -139,12 +139,7 @@ void aio_set_fd_handler(AioContext *ctx, atomic_set(&ctx->poll_disable_cnt, atomic_read(&ctx->poll_disable_cnt) + poll_disable_change); - if (new_node) { - ctx->fdmon_ops->update(ctx, new_node, is_new); - } else if (node) { - /* Unregister deleted fd_handler */ - ctx->fdmon_ops->update(ctx, node, false); - } + ctx->fdmon_ops->update(ctx, node, new_node); qemu_lockcnt_unlock(&ctx->list_lock); aio_notify(ctx); diff --git a/util/fdmon-epoll.c b/util/fdmon-epoll.c index 29c1454469..d56b69468b 100644 --- a/util/fdmon-epoll.c +++ b/util/fdmon-epoll.c @@ -30,21 +30,24 @@ static inline int epoll_events_from_pfd(int pfd_events) (pfd_events & G_IO_ERR ? EPOLLERR : 0); } -static void fdmon_epoll_update(AioContext *ctx, AioHandler *node, bool is_new) +static void fdmon_epoll_update(AioContext *ctx, + AioHandler *old_node, + AioHandler *new_node) { - struct epoll_event event; + struct epoll_event event = { + .data.ptr = new_node, + .events = new_node ? epoll_events_from_pfd(new_node->pfd.events) : 0, + }; int r; - int ctl; - if (!node->pfd.events) { - ctl = EPOLL_CTL_DEL; + if (!new_node) { + r = epoll_ctl(ctx->epollfd, EPOLL_CTL_DEL, old_node->pfd.fd, &event); + } else if (!old_node) { + r = epoll_ctl(ctx->epollfd, EPOLL_CTL_ADD, new_node->pfd.fd, &event); } else { - event.data.ptr = node; - event.events = epoll_events_from_pfd(node->pfd.events); - ctl = is_new ? EPOLL_CTL_ADD : EPOLL_CTL_MOD; + r = epoll_ctl(ctx->epollfd, EPOLL_CTL_MOD, new_node->pfd.fd, &event); } - r = epoll_ctl(ctx->epollfd, ctl, node->pfd.fd, &event); if (r) { fdmon_epoll_disable(ctx); } diff --git a/util/fdmon-poll.c b/util/fdmon-poll.c index 67992116b8..28114a0f39 100644 --- a/util/fdmon-poll.c +++ b/util/fdmon-poll.c @@ -93,7 +93,9 @@ static int fdmon_poll_wait(AioContext *ctx, AioHandlerList *ready_list, return ret; } -static void fdmon_poll_update(AioContext *ctx, AioHandler *node, bool is_new) +static void fdmon_poll_update(AioContext *ctx, + AioHandler *old_node, + AioHandler *new_node) { /* Do nothing, AioHandler already contains the state we'll need */ } |