On 11/10/2017 02:37 PM, Max Reitz wrote:
> We can easily repair unaligned preallocated zero clusters by discarding
> them, so why not do it?
> 
> Signed-off-by: Max Reitz <mre...@redhat.com>
> ---
>  block/qcow2-refcount.c     | 70 
> ++++++++++++++++++++++++++++++++++++++--------
>  tests/qemu-iotests/060     |  3 +-
>  tests/qemu-iotests/060.out |  9 ++++++
>  3 files changed, 69 insertions(+), 13 deletions(-)
> 

>  
> +            /* Correct offsets are cluster aligned */
> +            if (offset_into_cluster(s, offset)) {
> +                if (qcow2_get_cluster_type(l2_entry) ==
> +                    QCOW2_CLUSTER_ZERO_ALLOC)
> +                {
> +                    fprintf(stderr, "%s offset=%" PRIx64 ": Preallocated 
> zero "
> +                            "cluster is not properly aligned; L2 entry "
> +                            "corrupted.\n",
> +                            fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR",
> +                            offset);

Is fprintf() still the right thing to be using?

> @@ -1586,13 +1637,6 @@ static int check_refcounts_l2(BlockDriverState *bs, 
> BdrvCheckResult *res,
>              if (ret < 0) {
>                  goto fail;
>              }
> -
> -            /* Correct offsets are cluster aligned */
> -            if (offset_into_cluster(s, offset)) {
> -                fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not "
> -                    "properly aligned; L2 entry corrupted.\n", offset);

But it's no worse than what you are refactoring.

Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to