mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
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>
This commit is contained in:
parent
9154b02c53
commit
dcc772e2f2
2 changed files with 38 additions and 2 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue