[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 25/67] block: reintroduce bdrv_flush_all
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 25/67] block: reintroduce bdrv_flush_all |
Date: |
Wed, 14 Dec 2016 18:44:19 -0600 |
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>
(cherry picked from commit 4085f5c7a239567a292876f46cb59d9b19bcf6ac)
Signed-off-by: Michael Roth <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 420944d..487755a 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1615,6 +1615,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 11c162d..acddf3b 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -336,6 +336,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.9.1
- [Qemu-devel] [PATCH 16/67] crypto: ensure XTS is only used with ciphers with 16 byte blocks, (continued)
- [Qemu-devel] [PATCH 16/67] crypto: ensure XTS is only used with ciphers with 16 byte blocks, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 18/67] scsi-disk: Cleaning up around tray open state, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 17/67] iothread: Stop threads before main() quits, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 19/67] virtio-scsi: Don't abort when media is ejected, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 20/67] ahci: clear aiocb in ncq_cb, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 01/67] linux-headers: update, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 21/67] s390x/css: handle cssid 255 correctly, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 23/67] qcow2: fix encryption during cow of sectors, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 24/67] iscsi: Fix divide-by-zero regression on raw SG devices, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 22/67] vfio/pci: Fix regression in MSI routing configuration, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 25/67] block: reintroduce bdrv_flush_all,
Michael Roth <=
- [Qemu-devel] [PATCH 26/67] qemu: use bdrv_flush_all for vm_stop et al, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 30/67] qht: fix unlock-after-free segfault upon resizing, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 27/67] block-backend: remove blk_flush_all, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 02/67] hw/ppc/spapr: Move code related to "ibm, pa-features" to a separate function, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 33/67] qapi: Fix crash when 'any' or 'null' parameter is missing, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 29/67] qht: simplify qht_reset_size, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 31/67] char: fix missing return in error path for chardev TLS init, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 28/67] migrate: Fix cpu-throttle-increment regression in HMP, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 36/67] ppc/kvm: Mark 64kB page size support as disabled if not available, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 39/67] net: rtl8139: limit processing of ring descriptors, Michael Roth, 2016/12/14