qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/6] block: Convert .bdrv_truncate callback to coroutine_fn
Date: Wed, 27 Jun 2018 12:54:58 +0100	[thread overview]
Message-ID: <20180627115458.GG5955@stefanha-x1.localdomain> (raw)
In-Reply-To: <20180626142434.22090-3-kwolf@redhat.com>

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

On Tue, Jun 26, 2018 at 04:24:30PM +0200, Kevin Wolf wrote:
> bdrv_truncate() is an operation that can block (even for a quite long
> time, depending on the PreallocMode) in I/O paths that shouldn't block.
> Convert it to a coroutine_fn so that we have the infrastructure for
> drivers to make their .bdrv_co_truncate implementation asynchronous.
> 
> This change could potentially introduce new race conditions because
> bdrv_truncate() isn't necessarily executed atomically any more. Whether
> this is a problem needs to be evaluated for each block driver that
> supports truncate:
> 
> * file-posix/win32, gluster, iscsi, nfs, rbd, ssh, sheepdog: The
>   protocol drivers are trivially safe because they don't actually yield
>   yet, so there is no change in behaviour.
> 
> * copy-on-read, crypto, raw-format: Essentially just filter drivers that
>   pass the request to a child node, no problem.
> 
> * qcow2: The implementation modifies metadata, so it needs to hold
>   s->lock to be safe with concurrent I/O requests. In order to avoid
>   double locking, this requires pulling the locking out into
>   preallocate_co() and using qcow2_write_caches() instead of
>   bdrv_flush().
> 
> * qed: Does a single header update, this is fine without locking.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/block/block.h     |  4 +++
>  include/block/block_int.h |  4 +--
>  block.c                   | 63 ++++++++++++++++++++++++++++++++++------
>  block/copy-on-read.c      |  8 +++---
>  block/crypto.c            |  9 +++---
>  block/file-posix.c        | 12 ++++----
>  block/file-win32.c        |  6 ++--
>  block/gluster.c           | 14 +++++----
>  block/iscsi.c             |  8 +++---
>  block/nfs.c               |  7 +++--
>  block/qcow2.c             | 73 ++++++++++++++++++++++++++++-------------------
>  block/qed.c               |  8 ++++--
>  block/raw-format.c        |  8 +++---
>  block/rbd.c               |  8 ++++--
>  block/sheepdog.c          | 12 ++++----
>  block/ssh.c               |  6 ++--
>  16 files changed, 161 insertions(+), 89 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2018-06-27 11:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26 14:24 [Qemu-devel] [PATCH v2 0/6] file-posix: Make truncate/preallocate asynchronous Kevin Wolf
2018-06-26 14:24 ` [Qemu-devel] [PATCH v2 1/6] qcow2: Fix qcow2_truncate() error return value Kevin Wolf
2018-06-27 11:51   ` Stefan Hajnoczi
2018-06-26 14:24 ` [Qemu-devel] [PATCH v2 2/6] block: Convert .bdrv_truncate callback to coroutine_fn Kevin Wolf
2018-06-27 11:54   ` Stefan Hajnoczi [this message]
2018-06-26 14:24 ` [Qemu-devel] [PATCH v2 3/6] qcow2: Remove coroutine trampoline for preallocate_co() Kevin Wolf
2018-06-27 11:55   ` Stefan Hajnoczi
2018-06-26 14:24 ` [Qemu-devel] [PATCH v2 4/6] block: Move bdrv_truncate() implementation to io.c Kevin Wolf
2018-06-27 11:56   ` Stefan Hajnoczi
2018-06-26 14:24 ` [Qemu-devel] [PATCH v2 5/6] block: Use tracked request for truncate Kevin Wolf
2018-06-27 11:57   ` Stefan Hajnoczi
2018-06-26 14:24 ` [Qemu-devel] [PATCH v2 6/6] file-posix: Make .bdrv_co_truncate asynchronous Kevin Wolf
2018-06-27 11:57   ` Stefan Hajnoczi
2018-06-27 11:58 ` [Qemu-devel] [PATCH v2 0/6] file-posix: Make truncate/preallocate asynchronous Stefan Hajnoczi
2018-06-27 12:42   ` 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=20180627115458.GG5955@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=kwolf@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 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).