qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: den@openvz.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] block: fix race in bdrv_co_discard with drive-mirror
Date: Thu, 16 Jun 2016 19:09:40 +0300	[thread overview]
Message-ID: <1466093381-6120-3-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1466093381-6120-1-git-send-email-den@openvz.org>

Actually we must set dirty bitmap dirty after we have written all our
zeroes for correct processing in drive mirror code. In the other case
we can face not zeroes in this area in mirror_iteration.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy<vsementsov@virtuozzo.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
---
 block/io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/io.c b/block/io.c
index aca175e..11fcfcb 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2263,7 +2263,6 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
 
     tracked_request_begin(&req, bs, sector_num << BDRV_SECTOR_BITS,
                           nb_sectors << BDRV_SECTOR_BITS, BDRV_TRACKED_DISCARD);
-    bdrv_set_dirty(bs, sector_num, nb_sectors);
 
     max_discard = MIN_NON_ZERO(bs->bl.max_discard, BDRV_REQUEST_MAX_SECTORS);
     while (nb_sectors > 0) {
@@ -2312,6 +2311,8 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
     }
     ret = 0;
 out:
+    bdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,
+                   req.bytes >> BDRV_SECTOR_BITS);
     tracked_request_end(&req);
     return ret;
 }
-- 
2.1.4

  parent reply	other threads:[~2016-06-16 16:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 16:09 [Qemu-devel] [PATCH v2 0/3] potentially broken drive-mirror/drive-backup in bdrv_co_discard Denis V. Lunev
2016-06-16 16:09 ` [Qemu-devel] [PATCH 1/3] block: fixed BdrvTrackedRequest filling " Denis V. Lunev
2016-06-16 17:39   ` Eric Blake
2016-06-16 16:09 ` Denis V. Lunev [this message]
2016-06-16 16:09 ` [Qemu-devel] [PATCH 3/3] block: process before_write_notifiers " Denis V. Lunev
2016-06-17 10:33 ` [Qemu-devel] [Qemu-block] [PATCH v2 0/3] potentially broken drive-mirror/drive-backup " Stefan Hajnoczi
2016-06-17 11:25 ` [Qemu-devel] " Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2016-06-16  6:58 [Qemu-devel] [PATCH " Denis V. Lunev
2016-06-16  6:58 ` [Qemu-devel] [PATCH 2/3] block: fix race in bdrv_co_discard with drive-mirror Denis V. Lunev
2016-06-16  7:38   ` Fam Zheng
2016-06-16  9:34   ` Vladimir Sementsov-Ogievskiy
2016-06-16  9:39     ` Denis V. Lunev

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=1466093381-6120-3-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).