From patchwork Thu Jun 16 06:58:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 636223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rVZ4h1xd6z9t0G for ; Thu, 16 Jun 2016 16:59:32 +1000 (AEST) Received: from localhost ([::1]:46816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDRH0-0001UB-An for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2016 02:59:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDRG8-0000sn-Mm for qemu-devel@nongnu.org; Thu, 16 Jun 2016 02:58:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDRG3-0004KV-2C for qemu-devel@nongnu.org; Thu, 16 Jun 2016 02:58:35 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:6430 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDRG2-0004HS-M4 for qemu-devel@nongnu.org; Thu, 16 Jun 2016 02:58:31 -0400 Received: from hades.sw.ru ([10.30.8.132]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id u5G6w7b2009916; Thu, 16 Jun 2016 09:58:13 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 16 Jun 2016 09:58:06 +0300 Message-Id: <1466060287-31514-3-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466060287-31514-1-git-send-email-den@openvz.org> References: <1466060287-31514-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 2/3] block: fix race in bdrv_co_discard with drive-mirror X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Fam Zheng , Max Reitz , Stefan Hajnoczi , den@openvz.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 dirty area there in mirror_iteration. Signed-off-by: Denis V. Lunev CC: Vladimir Sementsov-Ogievskiy CC: Stefan Hajnoczi CC: Fam Zheng CC: Kevin Wolf CC: Max Reitz Reviewed-by: Fam Zheng --- block/io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index b51f681..513bd99 100644 --- a/block/io.c +++ b/block/io.c @@ -2265,7 +2265,6 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, tracked_request_begin(&req, bs, NULL, 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) { @@ -2314,6 +2313,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; }