All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: vsementsov@virtuozzo.com, qemu-devel@nongnu.org,
	stefanha@redhat.com, mreitz@redhat.com
Subject: Re: [PATCH v3 2/8] block: Add no_fallback parameter to bdrv_co_truncate()
Date: Fri, 22 Nov 2019 10:48:20 -0600	[thread overview]
Message-ID: <eef2c246-fd82-e66e-c757-00fe4eee4607@redhat.com> (raw)
In-Reply-To: <20191122160511.8377-3-kwolf@redhat.com>

On 11/22/19 10:05 AM, Kevin Wolf wrote:
> This adds a no_fallback parameter to bdrv_co_truncate(), bdrv_truncate()
> and blk_truncate() in preparation for a fix that potentially needs to
> zero-write the new area. no_fallback will use BDRV_REQ_NO_FALLBACK for
> this operation and lets the truncate fail if an efficient zero write
> isn't possible.
> 
> Only qmp_block_resize() passes true for this parameter because it is a
> blocking monitor command, so we don't want to add more potentially slow
> I/O operations to it than we already have.
> 
> All other users will accept even a slow fallback to avoid failure.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---

> +++ b/include/block/block.h
> @@ -347,9 +347,10 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
>   void bdrv_refresh_filename(BlockDriverState *bs);
>   
>   int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
> -                                  PreallocMode prealloc, Error **errp);
> +                                  PreallocMode prealloc, bool no_fallback,
> +                                  Error **errp);
>   int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact,
> -                  PreallocMode prealloc, Error **errp);
> +                  PreallocMode prealloc, bool no_fallback, Error **errp);
>   

New signature, most of the changes are mechanical to pass the new 
parameter...

> +++ b/block/io.c
> @@ -3313,9 +3313,15 @@ static void bdrv_parent_cb_resize(BlockDriverState *bs)
>    * If 'exact' is true, the file must be resized to exactly the given
>    * 'offset'.  Otherwise, it is sufficient for the node to be at least
>    * 'offset' bytes in length.
> + *
> + * If 'no_fallback' is true, a possibly needed writte_zeroes operation to avoid

write

> + * making a longer backing file visible will use BDRV_REQ_NO_FALLBACK. If the
> + * zero write is necessary and this flag is set, bdrv_co_truncate() will fail
> + * if efficient zero writes cannot be provided.
>    */

> +++ b/qemu-img.c
> @@ -3836,7 +3836,7 @@ static int img_resize(int argc, char **argv)
>        * resizing, so pass @exact=true.  It is of no use to report
>        * success when the image has not actually been resized.
>        */
> -    ret = blk_truncate(blk, total_size, true, prealloc, &err);
> +    ret = blk_truncate(blk, total_size, true, prealloc, false, &err);
>       if (!ret) {
>           qprintf(quiet, "Image resized.\n");
>       } else {

Hmm - thought for a future patch (not this one): are there situations 
where it may be faster to perform bulk pre-zeroing of the tail of a file 
by performing two truncates (smaller and then larger) because we know 
that just-added bytes from a truncate will read as zero?  This may be 
true for some file systems (but is not true for block devices, nor for 
things like NBD that lack resize).  Anyway, unrelated to this patch.

With the typo fixed,

Reviewed-by: Eric Blake <eblake@redhat.com>

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



  reply	other threads:[~2019-11-22 17:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 16:05 [PATCH for-4.2? v3 0/8] block: Fix resize (extending) of short overlays Kevin Wolf
2019-11-22 16:05 ` [PATCH v3 1/8] block: bdrv_co_do_pwrite_zeroes: 64 bit 'bytes' parameter Kevin Wolf
2019-11-22 16:05 ` [PATCH v3 2/8] block: Add no_fallback parameter to bdrv_co_truncate() Kevin Wolf
2019-11-22 16:48   ` Eric Blake [this message]
2019-11-25 12:00   ` Max Reitz
2019-11-25 15:06   ` Alberto Garcia
2019-11-25 16:05     ` Kevin Wolf
2019-11-22 16:05 ` [PATCH v3 3/8] qcow2: Declare BDRV_REQ_NO_FALLBACK supported Kevin Wolf
2019-11-22 18:03   ` Eric Blake
2019-11-25 12:02   ` Max Reitz
2019-11-25 14:53   ` Alberto Garcia
2019-11-22 16:05 ` [PATCH v3 4/8] block: truncate: Don't make backing file data visible Kevin Wolf
2019-11-22 18:06   ` Eric Blake
2019-11-25 12:08   ` Max Reitz
2019-11-22 16:05 ` [PATCH v3 5/8] iotests: Add qemu_io_log() Kevin Wolf
2019-11-22 16:05 ` [PATCH v3 6/8] iotests: Fix timeout in run_job() Kevin Wolf
2019-11-22 16:05 ` [PATCH v3 7/8] iotests: Support job-complete " Kevin Wolf
2019-11-22 16:05 ` [PATCH v3 8/8] iotests: Test committing to short backing file Kevin Wolf
2019-11-22 18:09   ` Eric Blake
2019-11-25  9:56   ` Vladimir Sementsov-Ogievskiy
2019-11-25 12:19   ` Max Reitz
2019-11-22 16:17 ` [PATCH for-4.2? v3 0/8] block: Fix resize (extending) of short overlays Peter Maydell
2019-11-22 16:41   ` Eric Blake
2019-11-25 12:21     ` Max Reitz
2019-11-25 12:24 ` Max Reitz
2019-12-10 17:46 ` Kevin Wolf
2019-12-11  7:09   ` Max Reitz
2019-12-19  9:24   ` Vladimir Sementsov-Ogievskiy
2019-12-19 10:13     ` Kevin Wolf
2019-12-19 10:20       ` Vladimir Sementsov-Ogievskiy
2020-02-05 13:43         ` Vladimir Sementsov-Ogievskiy

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=eef2c246-fd82-e66e-c757-00fe4eee4607@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.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.