[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 29/35] block: acquire AioContext in do_drive_del()
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 29/35] block: acquire AioContext in do_drive_del() |
Date: |
Fri, 29 Aug 2014 17:29:57 +0100 |
Make drive_del safe for dataplane where another thread may be running
the BlockDriverState's AioContext.
Note the assumption that AioContext's lifetime exceeds DriveInfo and
BlockDriverState. We release AioContext after DriveInfo and
BlockDriverState are potentially freed.
This is clearly safe with the global AioContext but also with -object
iothread and implicit iothreads created by -device
virtio-blk-pci,x-data-plane=on (their lifetime is tied to DeviceState,
not BlockDriverState).
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
blockdev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index eeb414e..e37b068 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1757,6 +1757,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
BlockDriverState *bs;
+ AioContext *aio_context;
Error *local_err = NULL;
bs = bdrv_find(id);
@@ -1764,9 +1765,14 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
error_report("Device '%s' not found", id);
return -1;
}
+
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
+ aio_context_release(aio_context);
return -1;
}
@@ -1790,6 +1796,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict,
QObject **ret_data)
drive_del(drive_get_by_blockdev(bs));
}
+ aio_context_release(aio_context);
return 0;
}
--
1.9.3
- [Qemu-devel] [PULL 18/35] aio-win32: add aio_set_dispatching optimization, (continued)
- [Qemu-devel] [PULL 18/35] aio-win32: add aio_set_dispatching optimization, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 19/35] AioContext: introduce aio_prepare, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 20/35] qemu-coroutine-io: fix for Win32, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 22/35] sheepdog: fix a core dump while do auto-reconnecting, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 21/35] aio-win32: add support for sockets, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 23/35] nbd: Drop nbd_can_read(), Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 24/35] block: Add AIO context notifiers, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 26/35] block: fix overlapping multiwrite requests, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 27/35] qemu-iotests: add multiwrite test cases, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 25/35] nbd: Follow the BDS' AIO context, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 29/35] block: acquire AioContext in do_drive_del(),
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 28/35] linux-aio: avoid deadlock in nested aio_poll() calls, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 30/35] virtio-blk: allow drive_del with dataplane, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 32/35] curl: Don't deref NULL pointer in call to aio_poll., Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 33/35] nfs: Fix leak of opts in nfs_file_open, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 31/35] curl: Allow a cookie or cookies to be sent with http/https requests., Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 34/35] blkverify: Fix leak of opts in blkverify_open, Stefan Hajnoczi, 2014/08/29
- [Qemu-devel] [PULL 35/35] quorum: Fix leak of opts in quorum_open, Stefan Hajnoczi, 2014/08/29