[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/18] block: reintroduce bdrv_flush_all
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/18] block: reintroduce bdrv_flush_all |
Date: |
Tue, 27 Sep 2016 15:53:44 +0200 |
From: John Snow <address@hidden>
Commit fe1a9cbc moved the flush_all routine from the bdrv layer to the
block-backend layer. In doing so, however, the semantics of the routine
changed slightly such that flush_all now used blk_flush instead of
bdrv_flush.
blk_flush can fail if the attached device model reports that it is not
"available," (i.e. the tray is open.) This changed the semantics of
flush_all such that it can now fail for e.g. open CDROM drives.
Reintroduce bdrv_flush_all to regain the old semantics without having to
alter the behavior of blk_flush or blk_flush_all, which are already
'doing the right thing.'
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Acked-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 25 +++++++++++++++++++++++++
include/block/block.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/block/io.c b/block/io.c
index fdf7080..57a2eeb 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1619,6 +1619,31 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child,
int64_t offset,
BDRV_REQ_ZERO_WRITE | flags);
}
+/*
+ * Flush ALL BDSes regardless of if they are reachable via a BlkBackend or not.
+ */
+int bdrv_flush_all(void)
+{
+ BdrvNextIterator it;
+ BlockDriverState *bs = NULL;
+ int result = 0;
+
+ for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
+ AioContext *aio_context = bdrv_get_aio_context(bs);
+ int ret;
+
+ aio_context_acquire(aio_context);
+ ret = bdrv_flush(bs);
+ if (ret < 0 && !result) {
+ result = ret;
+ }
+ aio_context_release(aio_context);
+ }
+
+ return result;
+}
+
+
typedef struct BdrvCoGetBlockStatusData {
BlockDriverState *bs;
BlockDriverState *base;
diff --git a/include/block/block.h b/include/block/block.h
index e18233a..811b060 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -333,6 +333,7 @@ int bdrv_inactivate_all(void);
/* Ensure contents are flushed to disk. */
int bdrv_flush(BlockDriverState *bs);
int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
+int bdrv_flush_all(void);
void bdrv_close_all(void);
void bdrv_drain(BlockDriverState *bs);
void coroutine_fn bdrv_co_drain(BlockDriverState *bs);
--
1.8.3.1
- [Qemu-devel] [PULL 16/18] blockdev: Modularize nfs block driver, (continued)
- [Qemu-devel] [PULL 16/18] blockdev: Modularize nfs block driver, Max Reitz, 2016/09/14
- [Qemu-devel] [PULL 15/18] blockdev: Add dynamic module loading for block drivers, Max Reitz, 2016/09/14
- [Qemu-devel] [PULL 17/18] commit: get the overlay node before manipulating the backing chain, Max Reitz, 2016/09/14
- [Qemu-devel] [PULL 18/18] iotest 055: refactor and speed up, Max Reitz, 2016/09/14
- Re: [Qemu-devel] [PULL 00/18] Block layer patches, no-reply, 2016/09/14
- Re: [Qemu-devel] [PULL 00/18] Block layer patches, Peter Maydell, 2016/09/15
- [Qemu-devel] [PULL 00/18] Block layer patches, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 05/18] block: Drop aio/cache consistency check from qmp_blockdev_add(), Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 02/18] qemu: use bdrv_flush_all for vm_stop et al, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 01/18] block: reintroduce bdrv_flush_all,
Kevin Wolf <=
- [Qemu-devel] [PULL 03/18] block-backend: remove blk_flush_all, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 06/18] block/qapi: Use separate options type for curl driver, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 08/18] block: Parse 'detect-zeroes' in bdrv_open_common(), Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 04/18] block: Fix error path in qmp_blockdev_change_medium(), Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 11/18] block: Remove qemu_root_bds_opts, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 09/18] block: Use 'detect-zeroes' option for 'blockdev-change-medium', Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 16/18] coroutine-sigaltstack: use helper for allocating stack memory, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 10/18] block: Move 'discard' option to bdrv_open_common(), Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 18/18] coroutine: reduce stack size to 60kB, Kevin Wolf, 2016/09/27
- [Qemu-devel] [PULL 07/18] block/qapi: Move 'aio' option to file driver, Kevin Wolf, 2016/09/27