[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 07/11] aio-posix: introduce aio_{disable, enable}
From: |
Fam Zheng |
Subject: |
[Qemu-block] [PATCH v2 07/11] aio-posix: introduce aio_{disable, enable}_clients |
Date: |
Wed, 29 Jul 2015 12:42:10 +0800 |
Signed-off-by: Fam Zheng <address@hidden>
---
aio-posix.c | 17 ++++++++++++++++-
include/block/aio.h | 24 ++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/aio-posix.c b/aio-posix.c
index d25fcfc..840b769 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -26,6 +26,7 @@ struct AioHandler
int deleted;
void *opaque;
int type;
+ int disable_cnt;
QLIST_ENTRY(AioHandler) node;
};
@@ -261,7 +262,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
/* fill pollfds */
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
- if (!node->deleted && node->pfd.events) {
+ if (!node->deleted && node->pfd.events && !node->disable_cnt) {
add_pollfd(node);
}
}
@@ -301,3 +302,17 @@ bool aio_poll(AioContext *ctx, bool blocking)
return progress;
}
+
+void aio_disable_enable_clients(AioContext *ctx, int clients_mask,
+ bool is_disable)
+{
+ AioHandler *node;
+ aio_context_acquire(ctx);
+
+ QLIST_FOREACH(node, &ctx->aio_handlers, node) {
+ if (!node->deleted && node->type & clients_mask) {
+ node->disable_cnt += is_disable ? 1 : -1;
+ }
+ }
+ aio_context_release(ctx);
+}
diff --git a/include/block/aio.h b/include/block/aio.h
index 9541bdd..fb70cc5 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -379,4 +379,28 @@ static inline void aio_timer_init(AioContext *ctx,
*/
int64_t aio_compute_timeout(AioContext *ctx);
+void aio_disable_enable_clients(AioContext *ctx, int clients_mask,
+ bool is_disable);
+/**
+ * aio_disable_clients:
+ * @ctx: the aio context
+ *
+ * Disable the furthur processing by aio_poll(ctx) of clients.
+ */
+static inline void aio_disable_clients(AioContext *ctx, int clients_mask)
+{
+ aio_disable_enable_clients(ctx, clients_mask, true);
+}
+
+/**
+ * aio_enable_clients:
+ * @ctx: the aio context
+ *
+ * Enable the processing of the clients.
+ */
+static inline void aio_enable_clients(AioContext *ctx, int clients_mask)
+{
+ aio_disable_enable_clients(ctx, clients_mask, false);
+}
+
#endif
--
2.4.3
- [Qemu-block] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane, Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 02/11] aio: Save type to AioHandler, Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 01/11] aio: Introduce "type" in aio_set_fd_handler and aio_set_event_notifier, Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 03/11] block: Mark fd handlers as "protocol", Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 04/11] nbd: Mark fd handlers client type as "nbd server", Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 05/11] aio: Mark ctx->notifier's client type as "context", Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 06/11] dataplane: Mark host notifiers' client type as "dataplane", Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 07/11] aio-posix: introduce aio_{disable, enable}_clients,
Fam Zheng <=
- [Qemu-block] [PATCH v2 08/11] aio-win32: Implement aio_{disable, enable}_clients, Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 09/11] block: Introduce bdrv_aio_poll, Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 10/11] block: Replace nested aio_poll with bdrv_aio_poll, Fam Zheng, 2015/07/29
- [Qemu-block] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll, Fam Zheng, 2015/07/29