]>
Commit | Line | Data |
---|---|---|
1f050a46 SH |
1 | /* |
2 | * AioContext POSIX event loop implementation internal APIs | |
3 | * | |
4 | * Copyright IBM, Corp. 2008 | |
5 | * Copyright Red Hat, Inc. 2020 | |
6 | * | |
7 | * Authors: | |
8 | * Anthony Liguori <aliguori@us.ibm.com> | |
9 | * | |
10 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
11 | * the COPYING file in the top-level directory. | |
12 | * | |
13 | * Contributions after 2012-01-13 are licensed under the terms of the | |
14 | * GNU GPL, version 2 or (at your option) any later version. | |
15 | */ | |
16 | ||
17 | #ifndef AIO_POSIX_H | |
18 | #define AIO_POSIX_H | |
19 | ||
20 | #include "block/aio.h" | |
21 | ||
22 | struct AioHandler { | |
23 | GPollFD pfd; | |
24 | IOHandler *io_read; | |
25 | IOHandler *io_write; | |
26 | AioPollFn *io_poll; | |
27 | IOHandler *io_poll_begin; | |
28 | IOHandler *io_poll_end; | |
29 | void *opaque; | |
1f050a46 SH |
30 | QLIST_ENTRY(AioHandler) node; |
31 | QLIST_ENTRY(AioHandler) node_ready; /* only used during aio_poll() */ | |
32 | QLIST_ENTRY(AioHandler) node_deleted; | |
d37d0e36 | 33 | QLIST_ENTRY(AioHandler) node_poll; |
73fd282e SH |
34 | #ifdef CONFIG_LINUX_IO_URING |
35 | QSLIST_ENTRY(AioHandler) node_submitted; | |
36 | unsigned flags; /* see fdmon-io_uring.c */ | |
37 | #endif | |
d37d0e36 | 38 | int64_t poll_idle_timeout; /* when to stop userspace polling */ |
73fd282e | 39 | bool is_external; |
1f050a46 SH |
40 | }; |
41 | ||
42 | /* Add a handler to a ready list */ | |
43 | void aio_add_ready_handler(AioHandlerList *ready_list, AioHandler *node, | |
44 | int revents); | |
45 | ||
46 | extern const FDMonOps fdmon_poll_ops; | |
47 | ||
48 | #ifdef CONFIG_EPOLL_CREATE1 | |
49 | bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd); | |
50 | void fdmon_epoll_setup(AioContext *ctx); | |
51 | void fdmon_epoll_disable(AioContext *ctx); | |
52 | #else | |
53 | static inline bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd) | |
54 | { | |
55 | return false; | |
56 | } | |
57 | ||
58 | static inline void fdmon_epoll_setup(AioContext *ctx) | |
59 | { | |
60 | } | |
61 | ||
62 | static inline void fdmon_epoll_disable(AioContext *ctx) | |
63 | { | |
64 | } | |
65 | #endif /* !CONFIG_EPOLL_CREATE1 */ | |
66 | ||
73fd282e SH |
67 | #ifdef CONFIG_LINUX_IO_URING |
68 | bool fdmon_io_uring_setup(AioContext *ctx); | |
69 | void fdmon_io_uring_destroy(AioContext *ctx); | |
70 | #else | |
71 | static inline bool fdmon_io_uring_setup(AioContext *ctx) | |
72 | { | |
73 | return false; | |
74 | } | |
75 | ||
76 | static inline void fdmon_io_uring_destroy(AioContext *ctx) | |
77 | { | |
78 | } | |
79 | #endif /* !CONFIG_LINUX_IO_URING */ | |
80 | ||
1f050a46 | 81 | #endif /* AIO_POSIX_H */ |