qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v2 2/6] block: Convert .bdrv_truncate callback t


From: Stefan Hajnoczi
Subject: Re: [Qemu-block] [PATCH v2 2/6] block: Convert .bdrv_truncate callback to coroutine_fn
Date: Wed, 27 Jun 2018 12:54:58 +0100
User-agent: Mutt/1.10.0 (2018-05-17)

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 <address@hidden>
> ---
>  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 <address@hidden>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]