All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org,
	el13635@mail.ntua.gr, Max Reitz <mreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	jsnow@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 03/15] block: Add flag to avoid wasted work in bdrv_is_allocated()
Date: Wed, 5 Jul 2017 06:56:29 -0500	[thread overview]
Message-ID: <6aafcf61-7923-23c1-496d-6f2c195149d1@redhat.com> (raw)
In-Reply-To: <20170704070643.GB10298@lemon.lan>

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

On 07/04/2017 02:06 AM, Fam Zheng wrote:
> On Mon, 07/03 17:14, Eric Blake wrote:
>> @@ -1717,6 +1718,10 @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs,
>>   * Drivers not implementing the functionality are assumed to not support
>>   * backing files, hence all their sectors are reported as allocated.
>>   *
>> + * If 'allocation' is true, the caller only cares about allocation
>> + * status; this is a hint that a larger 'pnum' result is more
>> + * important than including BDRV_BLOCK_OFFSET_VALID in the return.
>> + *
> 
> This is slightly unintuitive. I would guess "allocation == false" means "I don't
> care about the allocation status" but it actually is "I don't care about the
> consecutiveness". The "only" semantics is missing in the parameter name.
> 
> Maybe rename it to "consecutive" and invert the logic?  I.e. "consecutive ==
> true" means BDRV_BLOCK_OFFSET_VALID is wanted.

Reasonable idea; other [shorter] names I've been toying with:
strict
mapping
precise

any of which, if true (set true by bdrv_get_block_status), means that I
care more about BDRV_BLOCK_OFFSET_VALID and validity for learning host
offsets, if false  it means I'm okay getting a larger *pnum even if it
extends over disjoint host offsets; or:

fast

which if true (set true by bdrv_is_allocated) means I want a larger
*pnum even if I have to sacrifice accuracy by omitting
BDRV_BLOCK_OFFSET_VALID, because I'm trying to reduce effort spent.

> 
> Sorry for bikeshedding.

Not a problem, I also had some double-takes in writing my own code
trying to remember which way I wanted the 'allocation' boolean to be
set, so coming up with a more intuitive name/default state in order to
help legibility is worth it.  Do any of my above suggestions sound better?

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2017-07-05 11:56 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03 22:14 [Qemu-devel] [PATCH v2 00/15] make bdrv_get_block_status byte-based Eric Blake
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 01/15] block: add default implementations for bdrv_co_get_block_status() Eric Blake
2017-07-04  7:33   ` Fam Zheng
2017-07-05 22:00   ` Eric Blake
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 02/15] block: Allow NULL file for bdrv_get_block_status() Eric Blake
2017-07-04  7:33   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 03/15] block: Add flag to avoid wasted work in bdrv_is_allocated() Eric Blake
2017-07-04  7:06   ` Fam Zheng
2017-07-05 11:56     ` Eric Blake [this message]
2017-07-05 12:07       ` Fam Zheng
2017-07-05 14:01         ` Eric Blake
2017-07-05 14:21           ` Fam Zheng
2017-07-06  2:35   ` Eric Blake
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 04/15] block: Make bdrv_round_to_clusters() signature more useful Eric Blake
2017-07-04  7:34   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 05/15] qcow2: Switch is_zero_sectors() to byte-based Eric Blake
2017-07-04  7:34   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 06/15] block: Switch bdrv_make_zero() " Eric Blake
2017-07-04  7:35   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 07/15] qemu-img: Switch get_block_status() " Eric Blake
2017-07-04  7:40   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 08/15] block: Convert bdrv_get_block_status() to bytes Eric Blake
2017-07-04  8:40   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 09/15] block: Switch bdrv_co_get_block_status() to byte-based Eric Blake
2017-07-04  8:59   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 10/15] block: Switch BdrvCoGetBlockStatusData " Eric Blake
2017-07-04  9:00   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 11/15] block: Switch bdrv_common_block_status_above() " Eric Blake
2017-07-04  9:02   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 12/15] block: Switch bdrv_co_get_block_status_above() " Eric Blake
2017-07-04  9:28   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 13/15] block: Convert bdrv_get_block_status_above() to bytes Eric Blake
2017-07-04  9:32   ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 14/15] block: Align block status requests Eric Blake
2017-07-04  9:44   ` Fam Zheng
2017-07-05 12:01     ` Eric Blake
2017-07-05 12:12       ` Fam Zheng
2017-07-03 22:14 ` [Qemu-devel] [PATCH v2 15/15] qemu-io: Relax 'alloc' now that block-status doesn't assert Eric Blake
2017-07-04  9:50   ` Fam Zheng
2017-07-03 22:20 ` [Qemu-devel] [RFC PATCH v2 16/15] block: Add .bdrv_co_block_status() callback Eric Blake
2017-07-04 11:30   ` Fam Zheng

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=6aafcf61-7923-23c1-496d-6f2c195149d1@redhat.com \
    --to=eblake@redhat.com \
    --cc=el13635@mail.ntua.gr \
    --cc=famz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.