qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: fix write with zero flag set and iovector provided
@ 2018-02-01 14:16 Anton Nefedov
  2018-02-01 14:29 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Anton Nefedov @ 2018-02-01 14:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, kwolf, mreitz, stefanha, famz, Anton Nefedov

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.

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 <anton.nefedov@virtuozzo.com>
---
 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;
     }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-06 16:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-01 14:16 [Qemu-devel] [PATCH] block: fix write with zero flag set and iovector provided Anton Nefedov
2018-02-01 14:29 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-02-01 14:38   ` Anton Nefedov
2018-02-01 14:36 ` [Qemu-devel] " Eric Blake
2018-02-01 14:40   ` [Qemu-devel] [Qemu-block] " Eric Blake
2018-02-01 15:19     ` Alberto Garcia
2018-02-06 16:11 ` [Qemu-devel] " Stefan Hajnoczi

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).