[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/28] qcow2: flush refcount cache correctly in allo
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 09/28] qcow2: flush refcount cache correctly in alloc_refcount_block() |
Date: |
Fri, 15 Mar 2013 16:14:06 +0100 |
update_refcount() affects the refcount cache, it does not write to disk.
Therefore bdrv_flush(bs->file) does nothing. We need to flush the
refcount cache in order to write out the refcount updates!
While we're here also add error returns when qcow2_cache_flush() fails.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-refcount.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 55543ed..e8b5d0a 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -201,7 +201,10 @@ static int alloc_refcount_block(BlockDriverState *bs,
*refcount_block = NULL;
/* We write to the refcount table, so we might depend on L2 tables */
- qcow2_cache_flush(bs, s->l2_table_cache);
+ ret = qcow2_cache_flush(bs, s->l2_table_cache);
+ if (ret < 0) {
+ return ret;
+ }
/* Allocate the refcount block itself and mark it as used */
int64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
@@ -237,7 +240,10 @@ static int alloc_refcount_block(BlockDriverState *bs,
goto fail_block;
}
- bdrv_flush(bs->file);
+ ret = qcow2_cache_flush(bs, s->refcount_block_cache);
+ if (ret < 0) {
+ goto fail_block;
+ }
/* Initialize the new refcount block only after updating its refcount,
* update_refcount uses the refcount cache itself */
--
1.8.1.4
- [Qemu-devel] [PULL 00/28] Block patches, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 04/28] block: Add options QDict to bdrv_open_common(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 03/28] Add qdict_clone_shallow(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 05/28] qemu-option: Add qemu_opts_absorb_qdict(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 08/28] qcow2: Allow lazy refcounts to be enabled on the command line, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 02/28] block: Add options QDict to bdrv_open() prototype, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 01/28] block: Add options QDict to .bdrv_open(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 10/28] qcow2: flush refcount cache correctly in qcow2_write_snapshots(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 11/28] qcow2: set L2 cache dependency in qcow2_alloc_bytes(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 09/28] qcow2: flush refcount cache correctly in alloc_refcount_block(),
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 07/28] block: Support driver specific options in drive_init(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 14/28] qcow2: drop unnecessary flush in qcow2_update_snapshot_refcount(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 06/28] blockdev: Keep a copy of DriveInfo.serial, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 12/28] qcow2: flush in qcow2_update_snapshot_refcount(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 13/28] qcow2: drop flush in update_cluster_refcount(), Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 15/28] qcow2: make is_allocated return true for zero clusters, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 16/28] sheepdog: use non-blocking fd in coroutine context, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 17/28] sheepdog: set io_flush handler in do_co_req, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 19/28] threadpool: move globals into struct ThreadPool, Stefan Hajnoczi, 2013/03/15
- [Qemu-devel] [PATCH 20/28] threadpool: add thread_pool_new() and thread_pool_free(), Stefan Hajnoczi, 2013/03/15