All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, jsnow@redhat.com, jcody@redhat.com,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 12/21] mirror: Switch mirror_do_read() to byte-based
Date: Thu, 6 Jul 2017 16:55:03 +0200	[thread overview]
Message-ID: <20170706145503.GL5975@noname.redhat.com> (raw)
In-Reply-To: <8c855cfa-a26e-cbab-b2fd-626f3520be9f@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3070 bytes --]

Am 06.07.2017 um 16:25 hat Eric Blake geschrieben:
> On 07/06/2017 08:30 AM, Kevin Wolf wrote:
> > Am 05.07.2017 um 23:08 hat Eric Blake geschrieben:
> >> We are gradually converting to byte-based interfaces, as they are
> >> easier to reason about than sector-based.  Convert another internal
> >> function (no semantic change).
> >>
> >> Signed-off-by: Eric Blake <eblake@redhat.com>
> >> Reviewed-by: John Snow <jsnow@redhat.com>
> >> Reviewed-by: Jeff Cody <jcody@redhat.com>
> > 
> >> -    /* The sector range must meet granularity because:
> >> +    assert(bytes <= s->buf_size);
> >> +    /* The range will be sector-aligned because:
> >>       * 1) Caller passes in aligned values;
> >> -     * 2) mirror_cow_align is used only when target cluster is larger. */
> >> -    assert(!(sector_num % sectors_per_chunk));
> 
> So the strict translation would be assert(!(offset % s->granularity)),
> or rewritten to be assert(QEMU_IS_ALIGNED(offset, s->granularity)).

Right.

> >> -    nb_chunks = DIV_ROUND_UP(nb_sectors, sectors_per_chunk);
> >> +     * 2) mirror_cow_align is used only when target cluster is larger.
> >> +     * But it might not be cluster-aligned at end-of-file. */
> >> +    assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE));
> 
> and you're right that this appears to be a new assertion.
> 
> >> +    nb_chunks = DIV_ROUND_UP(bytes, s->granularity);
> > 
> > The assertion in the old code was about sector_num (i.e.  that the start
> > of the range is cluster-aligned), not about nb_sectors, so while you add
> > a new assertion, it is asserting something different. This explains
> > why you had to switch to sector aligned even though the semantics
> > shouldn't be changed by this patch.
> > 
> > Is this intentional or did you confuse sector_num and nb_sectors? I
> > think we can just have both assertions.
> 
> At this point, I'm not sure if I confused things, or if I hit an actual
> iotest failure later in the series that I traced back to this point.

But if you did, wouldn't this indicate a real bug in the patch?

> If I have a reason to respin, I'll see if both assertions still hold
> (the rewritten alignment check on offset, and the new check on bytes
> being sector-aligned), through all the tests.

Actually, I think this one, while seemingly minor, is a reason to
respin. This kind of assertions is exactly for preventing bugs when
doing changes like this patch does, so removing the assertion in such a
patch looks really suspicious.

Also, with the new assertion, the comment doesn't really make that much
sense any more either.

> Also, while asserting that bytes is sector-aligned is good in the
> short term, it may be overkill by the time dirty-bitmap is changed to
> byte alignment (right now, bdrv_getlength() is always sector-aligned,
> because it rounds up; but if we ever make it byte-accurate, then the
> trailing cluster might not be a sector-aligned bytes length).

This is true, but I think for the time being the assertion is worth it.

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2017-07-06 14:55 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 21:08 [Qemu-devel] [PATCH v4 00/21] make bdrv_is_allocated[_above] byte-based Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 01/21] blockjob: Track job ratelimits via bytes, not sectors Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 02/21] trace: Show blockjob actions " Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 03/21] stream: Switch stream_populate() to byte-based Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 04/21] stream: Drop reached_end for stream_complete() Eric Blake
2017-07-06  0:05   ` John Snow
2017-07-06 10:38   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 05/21] stream: Switch stream_run() to byte-based Eric Blake
2017-07-06 10:39   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 06/21] commit: Switch commit_populate() " Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 07/21] commit: Switch commit_run() " Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 08/21] mirror: Switch MirrorBlockJob " Eric Blake
2017-07-06  0:14   ` John Snow
2017-07-06 10:42   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 09/21] mirror: Switch mirror_do_zero_or_discard() " Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 10/21] mirror: Update signature of mirror_clip_sectors() Eric Blake
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 11/21] mirror: Switch mirror_cow_align() to byte-based Eric Blake
2017-07-06 11:16   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 12/21] mirror: Switch mirror_do_read() " Eric Blake
2017-07-06 13:30   ` Kevin Wolf
2017-07-06 14:25     ` Eric Blake
2017-07-06 14:55       ` Kevin Wolf [this message]
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 13/21] mirror: Switch mirror_iteration() " Eric Blake
2017-07-06 13:47   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 14/21] block: Drop unused bdrv_round_sectors_to_clusters() Eric Blake
2017-07-06 13:49   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 15/21] backup: Switch BackupBlockJob to byte-based Eric Blake
2017-07-06 13:59   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 16/21] backup: Switch block_backup.h " Eric Blake
2017-07-06 14:11   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 17/21] backup: Switch backup_do_cow() " Eric Blake
2017-07-06 14:36   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 18/21] backup: Switch backup_run() " Eric Blake
2017-07-06 14:43   ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 19/21] block: Make bdrv_is_allocated() byte-based Eric Blake
2017-07-06 16:02   ` Kevin Wolf
2017-07-06 16:24     ` Eric Blake
2017-07-07  2:55     ` Eric Blake
2017-07-07  9:25       ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 20/21] block: Minimize raw use of bds->total_sectors Eric Blake
2017-07-06  0:23   ` John Snow
2017-07-06 16:48   ` Kevin Wolf
2017-07-06 17:03     ` Eric Blake
2017-07-06 17:27       ` Kevin Wolf
2017-07-05 21:08 ` [Qemu-devel] [PATCH v4 21/21] block: Make bdrv_is_allocated_above() byte-based Eric Blake
2017-07-06 17:13   ` Kevin Wolf

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=20170706145503.GL5975@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.