As of version 3, the qcow2 file format supports different widths for
refcount entries, ranging from 1 to 64 bit (only powers of two).
Currently, qemu only supports 16 bit, which is the only width supported
by version 2 (compat=0.10) images.

This series adds support to qemu for all other valid refcount orders.
This is mainly done by adding two function pointers into the
BDRVQcowState structure for reading and writing refcount values
independently of the current refcount entry width; all in-memory
refcount arrays (mostly cached refcount blocks) now are void pointers
and are accessed through these functions alone.

Thanks to previous work of making the qemu code agnostic of e.g. the
number of refcount entries per refcount block, the rest is fairly
trivial. The most complex patch in this series is patch 23 which
implements changing the refcount order through qemu-img amend.

To test different refcount widths, simply invoke the qemu-iotests check
program with -o refcount_width=${your_desired_width}. The final test in
this series adds some tests for operations which do not work with
certain refcount orders and for refcount order amendment.


v5:
- Patch 5: Use absolute value for addend instead of the two's complement
  for negative values [Stefan]
- Patch 6:
  - Conflicts due to the changes in patch 5
  - Dropped the "if (ret >= 0)" -> "if (ret == 0)" hunk; since the
    update_refcount() return value was never touched in this series
    there is no point in modifying the callers' checks for their return
    value [Eric]
- Patch 9: Use DIV_ROUND_UP() [Eric]
- Patch 16: Rebase conflicts due to Fam's patch removing trailing
  whitespace in all qemu-iotests/*.out files
  (7486458c33cd3e5714368f181a5fea39c54444ca); I kept the R-bs because
  these are only trailing whitespace conflicts in *.out files which are
  really trivial.
  There are two not-so-trivial conflicts: Two hunks are missing from v5
  which were part of v4 which did nothing but remove trailing
  whitespace. Obviously those are no longer necessary, so removing these
  hunks was actually trivial after all.


git-backport-diff against v4:

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/26:[----] [--] 'qcow2: Add two new fields to BDRVQcowState'
002/26:[----] [--] 'qcow2: Add refcount_bits to format-specific info'
003/26:[----] [--] 'qcow2: Do not return new value after refcount update'
004/26:[----] [--] 'qcow2: Only return status from qcow2_get_refcount'
005/26:[0040] [FC] 'qcow2: Use unsigned addend for update_refcount()'
006/26:[0028] [FC] 'qcow2: Use 64 bits for refcount values'
007/26:[----] [--] 'qcow2: Respect error in qcow2_alloc_bytes()'
008/26:[----] [--] 'qcow2: Refcount overflow and qcow2_alloc_bytes()'
009/26:[0002] [FC] 'qcow2: Helper for refcount array reallocation'
010/26:[----] [-C] 'qcow2: Helper function for refcount modification'
011/26:[----] [--] 'qcow2: More helpers for refcount modification'
012/26:[----] [--] 'qcow2: Open images with refcount order != 4'
013/26:[----] [--] 'qcow2: refcount_order parameter for qcow2_create2'
014/26:[----] [--] 'qcow2: Use symbolic macros in qcow2_amend_options'
015/26:[----] [--] 'iotests: Prepare for refcount_bits option'
016/26:[0126] [FC] 'qcow2: Allow creation with refcount order != 4'
017/26:[----] [--] 'progress: Allow regressing progress'
018/26:[----] [--] 'block: Add opaque value to the amend CB'
019/26:[----] [-C] 'qcow2: Use error_report() in qcow2_amend_options()'
020/26:[----] [--] 'qcow2: Use abort() instead of assert(false)'
021/26:[----] [--] 'qcow2: Split upgrade/downgrade paths for amend'
022/26:[----] [--] 'qcow2: Use intermediate helper CB for amend'
023/26:[----] [--] 'qcow2: Add function for refcount order amendment'
024/26:[----] [--] 'qcow2: Invoke refcount order amendment function'
025/26:[----] [--] 'qcow2: Point to amend function in check'
026/26:[----] [--] 'iotests: Add test for different refcount widths'


Max Reitz (26):
  qcow2: Add two new fields to BDRVQcowState
  qcow2: Add refcount_bits to format-specific info
  qcow2: Do not return new value after refcount update
  qcow2: Only return status from qcow2_get_refcount
  qcow2: Use unsigned addend for update_refcount()
  qcow2: Use 64 bits for refcount values
  qcow2: Respect error in qcow2_alloc_bytes()
  qcow2: Refcount overflow and qcow2_alloc_bytes()
  qcow2: Helper for refcount array reallocation
  qcow2: Helper function for refcount modification
  qcow2: More helpers for refcount modification
  qcow2: Open images with refcount order != 4
  qcow2: refcount_order parameter for qcow2_create2
  qcow2: Use symbolic macros in qcow2_amend_options
  iotests: Prepare for refcount_bits option
  qcow2: Allow creation with refcount order != 4
  progress: Allow regressing progress
  block: Add opaque value to the amend CB
  qcow2: Use error_report() in qcow2_amend_options()
  qcow2: Use abort() instead of assert(false)
  qcow2: Split upgrade/downgrade paths for amend
  qcow2: Use intermediate helper CB for amend
  qcow2: Add function for refcount order amendment
  qcow2: Invoke refcount order amendment function
  qcow2: Point to amend function in check
  iotests: Add test for different refcount widths

 block.c                          |    4 +-
 block/qcow2-cluster.c            |   24 +-
 block/qcow2-refcount.c           | 1054 +++++++++++++++++++++++++++++++-------
 block/qcow2.c                    |  286 ++++++++---
 block/qcow2.h                    |   23 +-
 include/block/block.h            |    4 +-
 include/block/block_int.h        |    4 +-
 qapi/block-core.json             |    5 +-
 qemu-img.c                       |    5 +-
 tests/qemu-iotests/007           |    3 +
 tests/qemu-iotests/015           |    2 +
 tests/qemu-iotests/026           |    7 +
 tests/qemu-iotests/029           |    2 +
 tests/qemu-iotests/049.out       |  108 ++--
 tests/qemu-iotests/051           |    3 +
 tests/qemu-iotests/058           |    2 +
 tests/qemu-iotests/060.out       |    1 +
 tests/qemu-iotests/061.out       |   14 +-
 tests/qemu-iotests/065           |   23 +-
 tests/qemu-iotests/067           |    2 +
 tests/qemu-iotests/067.out       |    5 +
 tests/qemu-iotests/079           |   10 +-
 tests/qemu-iotests/079.out       |   38 +-
 tests/qemu-iotests/080           |    2 +
 tests/qemu-iotests/082.out       |   48 +-
 tests/qemu-iotests/085.out       |   38 +-
 tests/qemu-iotests/089           |    2 +
 tests/qemu-iotests/089.out       |    2 +
 tests/qemu-iotests/108           |    2 +
 tests/qemu-iotests/112           |  296 +++++++++++
 tests/qemu-iotests/112.out       |  155 ++++++
 tests/qemu-iotests/common.filter |    3 +-
 tests/qemu-iotests/group         |    1 +
 util/qemu-progress.c             |    3 +-
 34 files changed, 1782 insertions(+), 399 deletions(-)
 create mode 100755 tests/qemu-iotests/112
 create mode 100644 tests/qemu-iotests/112.out

-- 
1.9.3


Reply via email to