qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Denis V. Lunev" <den@openvz.org>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/3] parallels: drop check that bdrv_truncate() is working
Date: Fri, 4 Aug 2017 14:32:07 -0500	[thread overview]
Message-ID: <d3c51c4e-ba65-1d1e-dbce-dbc15fff3522@redhat.com> (raw)
In-Reply-To: <20170804151013.13057-4-den@openvz.org>

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

On 08/04/2017 10:10 AM, Denis V. Lunev wrote:
> This would be actually strange and error prone. If truncate() nowadays
> will fail, there is something fatally wrong. Let's check for that during
> the actual work.
> 
> The only fallback case is when the file is not zero initialized. In this
> case we should switch to preallocation via fallocate().

I got confused by the commit message.  Here's my attempt an an
alternative, to see if I'm understanding the point of this patch:

The code was trying to truncate a file to its current length, as an
optimization to help decide whether an alternative prealloc mode was
useful.  But it forgot to check whether bdrv_getlength() succeeded, and
dealing with that failure just complicates what was supposed to be a
no-op probe for optimizing later operation.  We will still properly fail
later when an actual truncation attempt is made and the device can't
support it.  So when deciding how to set prealloc_mode while opening the
device, all we really need is to check just the one condition that
matters - knowing whether the device is zero initialized.

> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block/parallels.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

The code change makes sense at first glance, but I'm a bit reluctant to
give R-b, since the commit message threw me off and I'm not familiar
with the parallels code in the first place.

> 
> diff --git a/block/parallels.c b/block/parallels.c
> index 6794e53c0b..e1e06d23cc 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -703,9 +703,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
>          goto fail_options;
>      }
>  
> -    if (!(flags & BDRV_O_RESIZE) || !bdrv_has_zero_init(bs->file->bs) ||
> -            bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs),
> -                          PREALLOC_MODE_OFF, NULL) != 0) {
> +    if (!bdrv_has_zero_init(bs->file->bs)) {
>          s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
>      }
>  
> 

-- 
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: 619 bytes --]

  reply	other threads:[~2017-08-04 19:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 15:10 [Qemu-devel] [PATCH 0/3] respect bdrv_getlength() error code Denis V. Lunev
2017-08-04 15:10 ` [Qemu-devel] [PATCH 1/3] block: respect error code from bdrv_getlength in handle_aiocb_write_zeroes Denis V. Lunev
2017-08-04 19:08   ` Eric Blake
2017-08-04 15:10 ` [Qemu-devel] [PATCH 2/3] parallels: respect error code of bdrv_getlength() in allocate_clusters() Denis V. Lunev
2017-08-04 19:09   ` Eric Blake
2017-08-04 15:10 ` [Qemu-devel] [PATCH 3/3] parallels: drop check that bdrv_truncate() is working Denis V. Lunev
2017-08-04 19:32   ` Eric Blake [this message]
2017-08-04 19:45     ` Denis V. Lunev
2017-08-07 16:11 ` [Qemu-devel] [PATCH 0/3] respect bdrv_getlength() error code 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=d3c51c4e-ba65-1d1e-dbce-dbc15fff3522@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --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 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).