[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block: fix write with zero flag set and iovecto
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] block: fix write with zero flag set and iovector provided |
Date: |
Tue, 6 Feb 2018 16:11:41 +0000 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Thu, Feb 01, 2018 at 05:16:31PM +0300, Anton Nefedov wrote:
> The normal bdrv_co_pwritev() use is either
> - BDRV_REQ_ZERO_WRITE reset and iovector provided
> - BDRV_REQ_ZERO_WRITE set and iovector == NULL
>
> while
> - the flag reset and iovector == NULL is an assertion failure
> in bdrv_co_do_zero_pwritev()
> - the flag set and iovector provided is in fact allowed
> (the flag prevails and zeroes are written)
>
> However the alignment logic does not support the latter case so the padding
> areas get overwritten with zeroes.
Please include a test case. Berto mentioned that bdrv_pwrite_zeroes()
hits this issue, that might be one way to test it.
> Solution could be to forbid such case or just use bdrv_co_do_zero_pwritev()
> alignment for it which also makes the code a bit more obvious anyway.
>
> Signed-off-by: Anton Nefedov <address@hidden>
> ---
> block/io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/io.c b/block/io.c
> index 7ea4023..cf63fd0 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -1701,7 +1701,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
> */
> tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_WRITE);
>
> - if (!qiov) {
> + if (flags & BDRV_REQ_ZERO_WRITE) {
> ret = bdrv_co_do_zero_pwritev(child, offset, bytes, flags, &req);
> goto out;
> }
Looks good.
signature.asc
Description: PGP signature