[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 00/13] qcow2: Fix image repairing
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v7 00/13] qcow2: Fix image repairing |
Date: |
Wed, 22 Oct 2014 10:08:31 +0200 |
As can be seen in the final patch of this series, there are certain
cases where the current repair implementation of qcow2 actually damages
the image further because it allocates new clusters for the refcount
structure which overlap with existing but according to the on-disk
refcounts (which are assumed to be wrong to begin with) unallocated
clusters.
This series fixes this by completely recreating the refcount structure
based on the in-memory information calculated during the check operation
if the possibility of damaging the image while repairing the refcount
structures in-place exists.
v7:
- Patch 1 (added): Adds qemu_blockalign0()
- Patch 5 (added): Converts a pre-existing instance of sizeof(uint16_t)
for the in-memory refcount table to sizeof(**refcount_table) [Kevin]
- Patch 8 (prev. 6):
- INT64_MAX comparison reordered [Kevin]
- Use sizeof(**refcount_table) instead of sizeof(uint16_t) [Kevin]
- Patch 9 (prev. 7):
- Rebase conflict because of sizeof(**refcount_table)
- Pull the lonely "if (refcount1 == 0)" block up into the other
condition blocks regarding refcount1 and refcount2 [Kevin]
- Increment res->check_errors in case the refcount structure should be
rebuilt [Kevin]
- Patch 10 (prev. 8):
- Renamed nb_clusters to imrt_nb_clusters in alloc_clusters_imrt();
nowhere else because it's already called nb_clusters in all of the
check-related functions [Kevin]
- Fixed leaks due to g_try_realloc() by saving the result in a
temporary variable before overwriting the "real" pointer [Kevin]
- Use sizeof(**refcount_table) instead of sizeof(uint16_t) [Kevin]
- Renamed reftable to on_disk_reftable in rebuild_refcount_structure()
[Kevin]
- One instance of rt instead of reftable was left, fix it [BenoƮt]
- Use qemu_blockalign0() instead of g_malloc() for the
on_disk_refblock [Kevin]
- Use s->refcount_block_size instead of
s->cluster_size / sizeof(uint16_t)
- Use bdrv_pwrite() instead of bdrv_write() for writing the reftable
[Kevin]
- Increment res->check_errors and bail out if the refcount structures
need to be rebuilt but errors should not be fixed [Kevin]
- Patch 11 (prev. 9):
- Use an additional temporary variable for saving and restoring the
check result [Kevin]
- Keep track of leaks introduced by rebuilding the refcount structure
that could not be fixed [Kevin]
- Patch 13 (prev. 10): Use hexadecimal numbers (enclosed by $(()), if
necessary) [Kevin said it would be possible, so I did it]
git-backport-diff against v6:
Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively
001/13:[down] 'block: Add qemu_{,try_}blockalign0()'
002/13:[----] [--] 'qcow2: Calculate refcount block entry count'
003/13:[----] [--] 'qcow2: Fix leaks in dirty images'
004/13:[----] [--] 'qcow2: Split qcow2_check_refcounts()'
005/13:[down] 'qcow2: Use sizeof(**refcount_table)'
006/13:[----] [--] 'qcow2: Pull check_refblocks() up'
007/13:[----] [--] 'qcow2: Reuse refcount table in calculate_refcounts()'
008/13:[0007] [FC] 'qcow2: Fix refcount blocks beyond image end'
009/13:[0012] [FC] 'qcow2: Do not perform potentially damaging repairs'
010/13:[0082] [FC] 'qcow2: Rebuild refcount structure during check'
011/13:[0016] [FC] 'qcow2: Clean up after refcount rebuild'
012/13:[----] [--] 'iotests: Fix test outputs'
013/13:[0034] [FC] 'iotests: Add test for potentially damaging repairs'
Max Reitz (13):
block: Add qemu_{,try_}blockalign0()
qcow2: Calculate refcount block entry count
qcow2: Fix leaks in dirty images
qcow2: Split qcow2_check_refcounts()
qcow2: Use sizeof(**refcount_table)
qcow2: Pull check_refblocks() up
qcow2: Reuse refcount table in calculate_refcounts()
qcow2: Fix refcount blocks beyond image end
qcow2: Do not perform potentially damaging repairs
qcow2: Rebuild refcount structure during check
qcow2: Clean up after refcount rebuild
iotests: Fix test outputs
iotests: Add test for potentially damaging repairs
block.c | 16 +
block/qcow2-refcount.c | 706 ++++++++++++++++++++++++++++++++-------------
block/qcow2.c | 5 +-
block/qcow2.h | 2 +
include/block/block.h | 2 +
tests/qemu-iotests/039.out | 10 +-
tests/qemu-iotests/060.out | 10 +-
tests/qemu-iotests/061.out | 18 +-
tests/qemu-iotests/108 | 141 +++++++++
tests/qemu-iotests/108.out | 110 +++++++
tests/qemu-iotests/group | 1 +
11 files changed, 815 insertions(+), 206 deletions(-)
create mode 100755 tests/qemu-iotests/108
create mode 100644 tests/qemu-iotests/108.out
--
1.9.3
- [Qemu-devel] [PATCH v7 00/13] qcow2: Fix image repairing,
Max Reitz <=
- [Qemu-devel] [PATCH v7 01/13] block: Add qemu_{, try_}blockalign0(), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 03/13] qcow2: Fix leaks in dirty images, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 02/13] qcow2: Calculate refcount block entry count, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 04/13] qcow2: Split qcow2_check_refcounts(), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 05/13] qcow2: Use sizeof(**refcount_table), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 06/13] qcow2: Pull check_refblocks() up, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 07/13] qcow2: Reuse refcount table in calculate_refcounts(), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v7 08/13] qcow2: Fix refcount blocks beyond image end, Max Reitz, 2014/10/22