Skip to content

Commit 0505d48

Browse files
XanClicmdroth
authored andcommitted
qcow2: Flushing the caches in qcow2_close may fail
qcow2_cache_flush() may fail; if one of the caches failed to be flushed successfully to disk in qcow2_close() the image should not be marked clean, and we should emit a warning. This breaks the (qcow2-specific) iotests 026, 071 and 089; change their output accordingly. Cc: [email protected] Signed-off-by: Max Reitz <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> (cherry picked from commit 3b5e14c) Signed-off-by: Michael Roth <[email protected]>
1 parent 0073781 commit 0505d48

File tree

4 files changed

+146
-3
lines changed

4 files changed

+146
-3
lines changed

block/qcow2.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,10 +1275,23 @@ static void qcow2_close(BlockDriverState *bs)
12751275
s->l1_table = NULL;
12761276

12771277
if (!(bs->open_flags & BDRV_O_INCOMING)) {
1278-
qcow2_cache_flush(bs, s->l2_table_cache);
1279-
qcow2_cache_flush(bs, s->refcount_block_cache);
1278+
int ret1, ret2;
12801279

1281-
qcow2_mark_clean(bs);
1280+
ret1 = qcow2_cache_flush(bs, s->l2_table_cache);
1281+
ret2 = qcow2_cache_flush(bs, s->refcount_block_cache);
1282+
1283+
if (ret1) {
1284+
error_report("Failed to flush the L2 table cache: %s",
1285+
strerror(-ret1));
1286+
}
1287+
if (ret2) {
1288+
error_report("Failed to flush the refcount block cache: %s",
1289+
strerror(-ret2));
1290+
}
1291+
1292+
if (!ret1 && !ret2) {
1293+
qcow2_mark_clean(bs);
1294+
}
12821295
}
12831296

12841297
qcow2_cache_destroy(bs, s->l2_table_cache);

0 commit comments

Comments
 (0)