From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:47765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKsN0-0000RF-MM for qemu-devel@nongnu.org; Sun, 28 Apr 2019 18:34:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hKsLj-00075I-Mo for qemu-devel@nongnu.org; Sun, 28 Apr 2019 18:32:45 -0400 References: <20190205090825.14059-1-dplotnikov@virtuozzo.com> From: Max Reitz Message-ID: Date: Mon, 29 Apr 2019 00:32:34 +0200 MIME-Version: 1.0 In-Reply-To: <20190205090825.14059-1-dplotnikov@virtuozzo.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV" Subject: Re: [Qemu-devel] [PATCH] [RFC] qcow2: add compression type feature List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Denis Plotnikov , kwolf@redhat.com Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, den@virtuozzo.com, eblake@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV From: Max Reitz To: Denis Plotnikov , kwolf@redhat.com Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, den@virtuozzo.com, eblake@redhat.com Message-ID: Subject: Re: [PATCH] [RFC] qcow2: add compression type feature References: <20190205090825.14059-1-dplotnikov@virtuozzo.com> In-Reply-To: <20190205090825.14059-1-dplotnikov@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05.02.19 10:08, Denis Plotnikov wrote: > The patch adds some preparation parts for incompatible compression type= > feature into QCOW2 header that indicates that *all* compressed clusters= > must be (de)compressed using a certain compression type. >=20 > It is implied that the compression type is set on the image creation an= d > can be changed only later by image convertion, thus the only compressio= n > algorithm is used for the image. >=20 > The plan is to add support for ZSTD and then may be something more effe= ctive > in the future. >=20 > ZSDT compression algorithm consumes 3-5 times less CPU power with a > comparable comression ratio with zlib. It would be wise to use it for > data compression f.e. for backups. >=20 > The default compression is ZLIB. >=20 > Signed-off-by: Denis Plotnikov > --- > block/qcow2.c | 25 +++++++++++++++++++++++++ > block/qcow2.h | 26 ++++++++++++++++++++++---- > 2 files changed, 47 insertions(+), 4 deletions(-) Are there plans to pursue this further? [...] > diff --git a/block/qcow2.h b/block/qcow2.h > index 32cce9eee2..fdde5bbefd 100644 > --- a/block/qcow2.h > +++ b/block/qcow2.h > @@ -112,6 +112,10 @@ > #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size" > #define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval" > =20 > +/* Compression types */ > +#define QCOW2_COMPRESSION_TYPE_ZLIB 0 > +#define QCOW2_COMPRESSION_TYPE_ZSTD 1 We probably want QAPI types anyway (qemu-img info should report the compression type), so I think we could use them instead. > typedef struct QCowHeader { > uint32_t magic; > uint32_t version; > @@ -197,10 +201,13 @@ enum { > =20 > /* Incompatible feature bits */ > enum { > - QCOW2_INCOMPAT_DIRTY_BITNR =3D 0, > - QCOW2_INCOMPAT_CORRUPT_BITNR =3D 1, > - QCOW2_INCOMPAT_DIRTY =3D 1 << QCOW2_INCOMPAT_DIRTY_BITNR, > - QCOW2_INCOMPAT_CORRUPT =3D 1 << QCOW2_INCOMPAT_CORRUPT_BITNR= , > + QCOW2_INCOMPAT_DIRTY_BITNR =3D 0, > + QCOW2_INCOMPAT_CORRUPT_BITNR =3D 1, > + QCOW2_INCOMPAT_COMPRESSION_TYPE_BITNR =3D 2, > + QCOW2_INCOMPAT_DIRTY =3D 1 << QCOW2_INCOMPAT_DIRT= Y_BITNR, > + QCOW2_INCOMPAT_CORRUPT =3D 1 << QCOW2_INCOMPAT_CORR= UPT_BITNR, > + QCOW2_INCOMPAT_COMPRESSION_TYPE =3D > + 1 << QCOW2_INCOMPAT_COMPRESSION_TY= PE_BITNR, > =20 > QCOW2_INCOMPAT_MASK =3D QCOW2_INCOMPAT_DIRTY > | QCOW2_INCOMPAT_CORRUPT, This mask needs to be expanded by QCOW2_INCOMPAT_COMPRESSION_TYPE. > @@ -256,6 +263,10 @@ typedef struct Qcow2BitmapHeaderExt { > uint64_t bitmap_directory_offset; > } QEMU_PACKED Qcow2BitmapHeaderExt; > =20 > +typedef struct Qcow2CompressionTypeExt { > + uint32_t compression_type; > +} QEMU_PACKED Qcow2CompressionTypeExt; > + > typedef struct BDRVQcow2State { > int cluster_bits; > int cluster_size; > @@ -340,6 +351,13 @@ typedef struct BDRVQcow2State { > =20 > CoQueue compress_wait_queue; > int nb_compress_threads; > + /** > + * Compression type used for the image. Default: 0 - ZLIB > + * The image compression type is set on image creation. > + * The only way to change the compression type is to convert the i= mage > + * with the desired compresion type set *compression And, well, ideally qemu-img amend could perform this operation, too. Max > + */ > + uint32_t compression_type; > } BDRVQcow2State; > =20 > typedef struct Qcow2COWRegion { >=20 --6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAlzGKgIACgkQ9AfbAGHV z0B0/Qf/a9epd/IVJODcHCMTjUeoOlsFDEgxj4KIdlFk/Rjzse7P4nIFqr4QmY6l WYPE/1lZOUBQ/3DIuosc2vktphIQoImjN7W0W7JEZdV0ptAL4vqFIeCraRI7BeVz KQExc3Ozugq+LT/jYWwTlMOAaFvVwQy2Zm00kp5k1Ev3QRjzBiH5SSH+qLZBMeza i6fS+U8k9RistuvJE1lyksbZqxUaLi7Zd+Be5fT4MV4hUKfsD10B+cmmUexlu6E1 Ts/Ahr7SjNyH7JAPFE3evWscj3DMl0Xvs/vGG0MLx6cTU4yJTgshubSHgdHHhr8y gSRB9S12bIniXa2w98VERif97Dx3dg== =j6ah -----END PGP SIGNATURE----- --6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31E91C43218 for ; Sun, 28 Apr 2019 22:34:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E039520679 for ; Sun, 28 Apr 2019 22:34:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E039520679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:49163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKsNu-0000nU-5S for qemu-devel@archiver.kernel.org; Sun, 28 Apr 2019 18:34:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKsN0-0000RF-MM for qemu-devel@nongnu.org; Sun, 28 Apr 2019 18:34:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hKsLj-00075I-Mo for qemu-devel@nongnu.org; Sun, 28 Apr 2019 18:32:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hKsLh-00073S-Ub; Sun, 28 Apr 2019 18:32:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3916F309178C; Sun, 28 Apr 2019 22:32:39 +0000 (UTC) Received: from dresden.str.redhat.com (ovpn-204-32.brq.redhat.com [10.40.204.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E827C10018E0; Sun, 28 Apr 2019 22:32:36 +0000 (UTC) To: Denis Plotnikov , kwolf@redhat.com References: <20190205090825.14059-1-dplotnikov@virtuozzo.com> From: Max Reitz Openpgp: preference=signencrypt Autocrypt: addr=mreitz@redhat.com; prefer-encrypt=mutual; keydata= mQENBFXOJlcBCADEyyhOTsoa/2ujoTRAJj4MKA21dkxxELVj3cuILpLTmtachWj7QW+TVG8U /PsMCFbpwsQR7oEy8eHHZwuGQsNpEtNC2G/L8Yka0BIBzv7dEgrPzIu+W3anZXQW4702+uES U29G8TP/NGfXRRHGlbBIH9KNUnOSUD2vRtpOLXkWsV5CN6vQFYgQfFvmp5ZpPeUe6xNplu8V mcTw8OSEDW/ZnxJc8TekCKZSpdzYoxfzjm7xGmZqB18VFwgJZlIibt1HE0EB4w5GsD7x5ekh awIe3RwoZgZDLQMdOitJ1tUc8aqaxvgA4tz6J6st8D8pS//m1gAoYJWGwwIVj1DjTYLtABEB AAG0HU1heCBSZWl0eiA8bXJlaXR6QHJlZGhhdC5jb20+iQFTBBMBCAA9AhsDBQkSzAMABQsJ CAcCBhUICQoLAgQWAgMBAh4BAheABQJVzie5FRhoa3A6Ly9rZXlzLmdudXBnLm5ldAAKCRD0 B9sAYdXPQDcIB/9uNkbYEex1rHKz3mr12uxYMwLOOFY9fstP5aoVJQ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ID: Date: Mon, 29 Apr 2019 00:32:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190205090825.14059-1-dplotnikov@virtuozzo.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV" X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 28 Apr 2019 22:32:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [PATCH] [RFC] qcow2: add compression type feature X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, den@virtuozzo.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190428223234.SDT9p1ZMjXq7CZaDxMyltbJCo8epSzH0okyyCxCorG8@z> This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV From: Max Reitz To: Denis Plotnikov , kwolf@redhat.com Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, den@virtuozzo.com, eblake@redhat.com Message-ID: Subject: Re: [PATCH] [RFC] qcow2: add compression type feature References: <20190205090825.14059-1-dplotnikov@virtuozzo.com> In-Reply-To: <20190205090825.14059-1-dplotnikov@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05.02.19 10:08, Denis Plotnikov wrote: > The patch adds some preparation parts for incompatible compression type= > feature into QCOW2 header that indicates that *all* compressed clusters= > must be (de)compressed using a certain compression type. >=20 > It is implied that the compression type is set on the image creation an= d > can be changed only later by image convertion, thus the only compressio= n > algorithm is used for the image. >=20 > The plan is to add support for ZSTD and then may be something more effe= ctive > in the future. >=20 > ZSDT compression algorithm consumes 3-5 times less CPU power with a > comparable comression ratio with zlib. It would be wise to use it for > data compression f.e. for backups. >=20 > The default compression is ZLIB. >=20 > Signed-off-by: Denis Plotnikov > --- > block/qcow2.c | 25 +++++++++++++++++++++++++ > block/qcow2.h | 26 ++++++++++++++++++++++---- > 2 files changed, 47 insertions(+), 4 deletions(-) Are there plans to pursue this further? [...] > diff --git a/block/qcow2.h b/block/qcow2.h > index 32cce9eee2..fdde5bbefd 100644 > --- a/block/qcow2.h > +++ b/block/qcow2.h > @@ -112,6 +112,10 @@ > #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size" > #define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval" > =20 > +/* Compression types */ > +#define QCOW2_COMPRESSION_TYPE_ZLIB 0 > +#define QCOW2_COMPRESSION_TYPE_ZSTD 1 We probably want QAPI types anyway (qemu-img info should report the compression type), so I think we could use them instead. > typedef struct QCowHeader { > uint32_t magic; > uint32_t version; > @@ -197,10 +201,13 @@ enum { > =20 > /* Incompatible feature bits */ > enum { > - QCOW2_INCOMPAT_DIRTY_BITNR =3D 0, > - QCOW2_INCOMPAT_CORRUPT_BITNR =3D 1, > - QCOW2_INCOMPAT_DIRTY =3D 1 << QCOW2_INCOMPAT_DIRTY_BITNR, > - QCOW2_INCOMPAT_CORRUPT =3D 1 << QCOW2_INCOMPAT_CORRUPT_BITNR= , > + QCOW2_INCOMPAT_DIRTY_BITNR =3D 0, > + QCOW2_INCOMPAT_CORRUPT_BITNR =3D 1, > + QCOW2_INCOMPAT_COMPRESSION_TYPE_BITNR =3D 2, > + QCOW2_INCOMPAT_DIRTY =3D 1 << QCOW2_INCOMPAT_DIRT= Y_BITNR, > + QCOW2_INCOMPAT_CORRUPT =3D 1 << QCOW2_INCOMPAT_CORR= UPT_BITNR, > + QCOW2_INCOMPAT_COMPRESSION_TYPE =3D > + 1 << QCOW2_INCOMPAT_COMPRESSION_TY= PE_BITNR, > =20 > QCOW2_INCOMPAT_MASK =3D QCOW2_INCOMPAT_DIRTY > | QCOW2_INCOMPAT_CORRUPT, This mask needs to be expanded by QCOW2_INCOMPAT_COMPRESSION_TYPE. > @@ -256,6 +263,10 @@ typedef struct Qcow2BitmapHeaderExt { > uint64_t bitmap_directory_offset; > } QEMU_PACKED Qcow2BitmapHeaderExt; > =20 > +typedef struct Qcow2CompressionTypeExt { > + uint32_t compression_type; > +} QEMU_PACKED Qcow2CompressionTypeExt; > + > typedef struct BDRVQcow2State { > int cluster_bits; > int cluster_size; > @@ -340,6 +351,13 @@ typedef struct BDRVQcow2State { > =20 > CoQueue compress_wait_queue; > int nb_compress_threads; > + /** > + * Compression type used for the image. Default: 0 - ZLIB > + * The image compression type is set on image creation. > + * The only way to change the compression type is to convert the i= mage > + * with the desired compresion type set *compression And, well, ideally qemu-img amend could perform this operation, too. Max > + */ > + uint32_t compression_type; > } BDRVQcow2State; > =20 > typedef struct Qcow2COWRegion { >=20 --6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAlzGKgIACgkQ9AfbAGHV z0B0/Qf/a9epd/IVJODcHCMTjUeoOlsFDEgxj4KIdlFk/Rjzse7P4nIFqr4QmY6l WYPE/1lZOUBQ/3DIuosc2vktphIQoImjN7W0W7JEZdV0ptAL4vqFIeCraRI7BeVz KQExc3Ozugq+LT/jYWwTlMOAaFvVwQy2Zm00kp5k1Ev3QRjzBiH5SSH+qLZBMeza i6fS+U8k9RistuvJE1lyksbZqxUaLi7Zd+Be5fT4MV4hUKfsD10B+cmmUexlu6E1 Ts/Ahr7SjNyH7JAPFE3evWscj3DMl0Xvs/vGG0MLx6cTU4yJTgshubSHgdHHhr8y gSRB9S12bIniXa2w98VERif97Dx3dg== =j6ah -----END PGP SIGNATURE----- --6S5hCFRNsHRbRe9kOzQF3AWHoioq0dCDV--