From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com
Subject: Re: [Qemu-devel] [PATCH v12 01/10] qcow2: Use consistent switch indentation
Date: Fri, 5 May 2017 21:42:30 +0200 [thread overview]
Message-ID: <1b59906d-4d5f-c5d7-57db-8752685df262@redhat.com> (raw)
In-Reply-To: <20170504030755.1001-2-eblake@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 6671 bytes --]
On 04.05.2017 05:07, Eric Blake wrote:
> Fix a couple of inconsistent indentations, before an upcoming
> patch further tweaks the switch statements. While at it, make
> some tweaks for shorter lines to keep checkpatch happy (best
> viewed with 'git diff -b').
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> ---
> v12: new patch
> ---
> block/qcow2-cluster.c | 32 ++++++++---------
> block/qcow2-refcount.c | 96 ++++++++++++++++++++++++++------------------------
> 2 files changed, 65 insertions(+), 63 deletions(-)
[...]
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 4efca7e..a5a0076 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -1117,70 +1117,72 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
> goto fail;
> }
>
> - for(j = 0; j < s->l2_size; j++) {
> + for (j = 0; j < s->l2_size; j++) {
> uint64_t cluster_index;
> + uint64_t offset_masked;
>
> offset = be64_to_cpu(l2_table[j]);
> old_offset = offset;
> + offset_masked = offset & L2E_OFFSET_MASK;
I'd rather rename "offset" to "entry" (or "l2_entry") and name this just
"offset". Much less confusing.
Also, I really wouldn't mind splitting the non-indentation changes off
into their own patch.
Tentative
Reviewed-by: Max Reitz <mreitz@redhat.com>
> offset &= ~QCOW_OFLAG_COPIED;
>
> switch (qcow2_get_cluster_type(offset)) {
> - case QCOW2_CLUSTER_COMPRESSED:
> - nb_csectors = ((offset >> s->csize_shift) &
> - s->csize_mask) + 1;
> - if (addend != 0) {
> - ret = update_refcount(bs,
> - (offset & s->cluster_offset_mask) & ~511,
> - nb_csectors * 512, abs(addend), addend < 0,
> - QCOW2_DISCARD_SNAPSHOT);
> - if (ret < 0) {
> - goto fail;
> - }
> - }
> - /* compressed clusters are never modified */
> - refcount = 2;
> - break;
> -
> - case QCOW2_CLUSTER_NORMAL:
> - case QCOW2_CLUSTER_ZERO:
> - if (offset_into_cluster(s, offset & L2E_OFFSET_MASK)) {
> - qcow2_signal_corruption(bs, true, -1, -1, "Data "
> - "cluster offset %#llx "
> - "unaligned (L2 offset: %#"
> - PRIx64 ", L2 index: %#x)",
> - offset & L2E_OFFSET_MASK,
> - l2_offset, j);
> - ret = -EIO;
> + case QCOW2_CLUSTER_COMPRESSED:
> + nb_csectors = ((offset >> s->csize_shift) &
> + s->csize_mask) + 1;
> + if (addend != 0) {
> + ret = update_refcount(bs,
> + (offset & s->cluster_offset_mask) & ~511,
> + nb_csectors * 512, abs(addend), addend < 0,
> + QCOW2_DISCARD_SNAPSHOT);
> + if (ret < 0) {
> goto fail;
> }
> + }
> + /* compressed clusters are never modified */
> + refcount = 2;
> + break;
>
> - cluster_index = (offset & L2E_OFFSET_MASK) >> s->cluster_bits;
> - if (!cluster_index) {
> - /* unallocated */
> - refcount = 0;
> - break;
> - }
> - if (addend != 0) {
> - ret = qcow2_update_cluster_refcount(bs,
> + case QCOW2_CLUSTER_NORMAL:
> + case QCOW2_CLUSTER_ZERO:
> + if (offset_into_cluster(s, offset_masked)) {
> + qcow2_signal_corruption(bs, true, -1, -1, "Data "
> + "cluster offset %#" PRIx64
> + " unaligned (L2 offset: %#"
> + PRIx64 ", L2 index: %#x)",
> + offset_masked,
> + l2_offset, j);
> + ret = -EIO;
> + goto fail;
> + }
> +
> + cluster_index = offset_masked >> s->cluster_bits;
> + if (!cluster_index) {
> + /* unallocated */
> + refcount = 0;
> + break;
> + }
> + if (addend != 0) {
> + ret = qcow2_update_cluster_refcount(bs,
> cluster_index, abs(addend), addend < 0,
> QCOW2_DISCARD_SNAPSHOT);
> - if (ret < 0) {
> - goto fail;
> - }
> - }
> -
> - ret = qcow2_get_refcount(bs, cluster_index, &refcount);
> if (ret < 0) {
> goto fail;
> }
> - break;
> + }
>
> - case QCOW2_CLUSTER_UNALLOCATED:
> - refcount = 0;
> - break;
> + ret = qcow2_get_refcount(bs, cluster_index, &refcount);
> + if (ret < 0) {
> + goto fail;
> + }
> + break;
>
> - default:
> - abort();
> + case QCOW2_CLUSTER_UNALLOCATED:
> + refcount = 0;
> + break;
> +
> + default:
> + abort();
> }
>
> if (refcount == 1) {
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
next prev parent reply other threads:[~2017-05-05 19:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 3:07 [Qemu-devel] [PATCH v12 00/10] qcow2 zero-cluster tweaks [was add blkdebug tests] Eric Blake
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 01/10] qcow2: Use consistent switch indentation Eric Blake
2017-05-05 19:42 ` Max Reitz [this message]
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 02/10] block: Update comments on BDRV_BLOCK_* meanings Eric Blake
2017-05-05 20:06 ` Max Reitz
2017-05-05 20:13 ` Eric Blake
2017-05-05 20:23 ` Max Reitz
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 03/10] qcow2: Correctly report status of preallocated zero clusters Eric Blake
2017-05-05 20:24 ` Max Reitz
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 04/10] qcow2: Make distinction between zero cluster types obvious Eric Blake
2017-05-05 20:51 ` Max Reitz
2017-05-06 20:30 ` Eric Blake
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 05/10] qcow2: Optimize zero_single_l2() to minimize L2 churn Eric Blake
2017-05-05 20:55 ` Max Reitz
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 06/10] iotests: Improve _filter_qemu_img_map Eric Blake
2017-05-05 20:58 ` Max Reitz
2017-05-05 21:06 ` Eric Blake
2017-05-05 21:07 ` Max Reitz
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 07/10] iotests: Add test 179 to cover write zeroes with unmap Eric Blake
2017-05-05 21:24 ` Max Reitz
2017-05-05 22:29 ` Max Reitz
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 08/10] qcow2: Optimize write zero of unaligned tail cluster Eric Blake
2017-05-05 22:06 ` Max Reitz
2017-05-05 22:41 ` Eric Blake
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 09/10] qcow2: Assert that cluster operations are aligned Eric Blake
2017-05-04 3:07 ` [Qemu-devel] [PATCH v12 10/10] qcow2: Discard/zero clusters by byte count Eric Blake
2017-05-05 22:18 ` [Qemu-devel] [PATCH v12 00/10] qcow2 zero-cluster tweaks [was add blkdebug tests] Max Reitz
2017-05-05 22:43 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b59906d-4d5f-c5d7-57db-8752685df262@redhat.com \
--to=mreitz@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).