aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLiu Ping Fan <qemulist@gmail.com>2013-07-16 12:28:58 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2013-07-19 12:29:21 +0800
commitdcc772e2f2b7c2a68644133fea2b874f6751a57b (patch)
tree4082fc020fff1669f1e81a70fe27921e6b393e55 /include
parent9154b02c53bb6685797c973fcdbec51c4714777d (diff)
downloadqemu-dcc772e2f2b7c2a68644133fea2b874f6751a57b.zip
qemu-dcc772e2f2b7c2a68644133fea2b874f6751a57b.tar.gz
qemu-dcc772e2f2b7c2a68644133fea2b874f6751a57b.tar.bz2
QEMUBH: make AioContext's bh re-entrant
BH will be used outside big lock, so introduce lock to protect between the writers, ie, bh's adders and deleter. The lock only affects the writers and bh's callback does not take this extra lock. Note that for the same AioContext, aio_bh_poll() can not run in parallel yet. Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/block/aio.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/block/aio.h b/include/block/aio.h
index 1836793..cc77771 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -17,6 +17,7 @@
#include "qemu-common.h"
#include "qemu/queue.h"
#include "qemu/event_notifier.h"
+#include "qemu/thread.h"
typedef struct BlockDriverAIOCB BlockDriverAIOCB;
typedef void BlockDriverCompletionFunc(void *opaque, int ret);
@@ -53,6 +54,8 @@ typedef struct AioContext {
*/
int walking_handlers;
+ /* lock to protect between bh's adders and deleter */
+ QemuMutex bh_lock;
/* Anchor of the list of Bottom Halves belonging to the context */
struct QEMUBH *first_bh;
@@ -127,6 +130,8 @@ void aio_notify(AioContext *ctx);
* aio_bh_poll: Poll bottom halves for an AioContext.
*
* These are internal functions used by the QEMU main loop.
+ * And notice that multiple occurrences of aio_bh_poll cannot
+ * be called concurrently
*/
int aio_bh_poll(AioContext *ctx);
@@ -163,6 +168,8 @@ void qemu_bh_cancel(QEMUBH *bh);
* Deleting a bottom half frees the memory that was allocated for it by
* qemu_bh_new. It also implies canceling the bottom half if it was
* scheduled.
+ * This func is async. The bottom half will do the delete action at the finial
+ * end.
*
* @bh: The bottom half to be deleted.
*/