From nobody Sat May 4 06:37:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516776738785532.3402943475177; Tue, 23 Jan 2018 22:52:18 -0800 (PST) Received: from localhost ([::1]:56713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeEuq-0005f1-7o for importer@patchew.org; Wed, 24 Jan 2018 01:52:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeEtz-0005Mi-VF for qemu-devel@nongnu.org; Wed, 24 Jan 2018 01:51:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeEtz-0004O0-22 for qemu-devel@nongnu.org; Wed, 24 Jan 2018 01:51:20 -0500 Received: from mx2.didichuxing.com ([36.110.17.22]:25584 helo=BJEXMBX012.didichuxing.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eeEtu-0004Av-75; Wed, 24 Jan 2018 01:51:14 -0500 Received: from localhost (172.25.16.23) by BJSGEXMBX03.didichuxing.com (172.20.15.133) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 24 Jan 2018 14:17:39 +0800 Date: Wed, 24 Jan 2018 14:17:29 +0800 From: Liang Li To: Jeff Cody , Kevin Wolf , Max Reitz , Paolo Bonzini , Huaitong Han Message-ID: <20180124061728.GA99621@localhost> Mail-Followup-To: Jeff Cody , Kevin Wolf , Max Reitz , Paolo Bonzini , Huaitong Han , qemu-block@nongnu.org, qemu-devel@nongnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.2 (2016-11-26) X-Originating-IP: [172.25.16.23] X-ClientProxiedBy: BJEXCAS003.didichuxing.com (172.20.1.43) To BJSGEXMBX03.didichuxing.com (172.20.15.133) X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 36.110.17.22 Subject: [Qemu-devel] [PATCH] block/mirror: fix fail to cancel when VM has heavy BLK IO 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: qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We found that when doing drive mirror to a low speed shared storage, if there was heavy BLK IO write workload in VM after the 'ready' event, drive mirror block job can't be canceled immediately, it would keep running until the heavy BLK IO workload stopped in the VM. This patch fixed this issue. Cc: Paolo Bonzini Cc: Jeff Cody Cc: Kevin Wolf Cc: Max Reitz Signed-off-by: Huaitong Han Signed-off-by: Liang Li --- block/mirror.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index c9badc1..3bc49a5 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -869,11 +869,9 @@ static void coroutine_fn mirror_run(void *opaque) =20 ret =3D 0; trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); - if (!s->synced) { - block_job_sleep_ns(&s->common, delay_ns); - if (block_job_is_cancelled(&s->common)) { - break; - } + + if (block_job_is_cancelled(&s->common)) { + break; } else if (!should_complete) { delay_ns =3D (s->in_flight =3D=3D 0 && cnt =3D=3D 0 ? SLICE_TI= ME : 0); block_job_sleep_ns(&s->common, delay_ns); @@ -887,7 +885,7 @@ immediate_exit: * or it was cancelled prematurely so that we do not guarantee that * the target is a copy of the source. */ - assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common= ))); + assert(ret < 0 || block_job_is_cancelled(&s->common)); assert(need_drain); mirror_wait_for_all_io(s); } --=20 1.8.3.1