qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite reques


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite requests
Date: Thu, 31 Jul 2014 09:41:57 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

The Wednesday 30 Jul 2014 à 09:53:30 (+0100), Stefan Hajnoczi wrote :
> When request A is a strict superset of request B:
> 
>   AAAAAAAA
>     BBBB
> 
> multiwrite_merge() merges them as follows:
> 
>   AABBBB
> 
> The tail of request A should have been included:
> 
>   AABBBBAA
> 
> This patch fixes data loss but this code path is probably rare.  Since
> guests cannot assume ordering between in-flight requests, few
> applications submit overlapping write requests.
> 
> Reported-by: Slava Pestov <address@hidden>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
>  block.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 8cf519b..0a3ac43 100644
> --- a/block.c
> +++ b/block.c
> @@ -4498,6 +4498,12 @@ static int multiwrite_merge(BlockDriverState *bs, 
> BlockRequest *reqs,
>              // Add the second request
>              qemu_iovec_concat(qiov, reqs[i].qiov, 0, reqs[i].qiov->size);
>  
> +            // Add tail of first request, if necessary
> +            if (qiov->size < reqs[outidx].qiov->size) {
> +                qemu_iovec_concat(qiov, reqs[outidx].qiov, qiov->size,
> +                                  reqs[outidx].qiov->size - qiov->size);
> +            }
> +
>              reqs[outidx].nb_sectors = qiov->size >> 9;
>              reqs[outidx].qiov = qiov;
>  
> -- 
> 1.9.3
> 
> 

Seems to make sense.

Reviewed-by: Benoit Canet <address@hidden>



reply via email to

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