From nobody Sun Feb 8 21:29:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1583922743; cv=none; d=zohomail.com; s=zohoarc; b=DzoteyxCuksmDH+kZmHS7tLigV8K5A1RD7RL9K45JJLT8cZtb0v4JurjNvNiHKUgU4N1OJfya2ucmUwh2JdfnKsnmRhObHeBPjqhy1XcEP+i9AiwcwZvzJ5cIKHz0T/W8yQDhTm7N5mpKoDafvARwfE6PfopzgtIq8QfxoPB4vA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583922743; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=glRqmaS7VfTuhf4QZ1U+wywglHR6f0bEtkjyOfysbcQ=; b=YZ0JLsK7EK+IA9CZu8AWI0iZf1TQ+L0GmIKHsuNY69bWXsO/5uKxl70Swp4yrY2BgcotE5dni3kwH+7RcuSUwQUyV32dlN1LU8kEn0h5ch5QQ1HtFEIfW6E1fmnu+CzQ5wOqgpJhrTdCi5lJJ9J/8EKV87OiekKRfu0Fx3AimQc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583922743899511.69462394524544; Wed, 11 Mar 2020 03:32:23 -0700 (PDT) Received: from localhost ([::1]:49314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jByez-0005NP-Ls for importer@patchew.org; Wed, 11 Mar 2020 06:32:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43546) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jByd7-0002tg-SB for qemu-devel@nongnu.org; Wed, 11 Mar 2020 06:30:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jByd6-0001Wu-Sw for qemu-devel@nongnu.org; Wed, 11 Mar 2020 06:30:25 -0400 Received: from relay.sw.ru ([185.231.240.75]:33052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jByd3-0001Ra-I9; Wed, 11 Mar 2020 06:30:21 -0400 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jBycy-0005cJ-Kf; Wed, 11 Mar 2020 13:30:16 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 5/9] block/block-copy: factor out find_conflicting_inflight_req Date: Wed, 11 Mar 2020 13:30:00 +0300 Message-Id: <20200311103004.7649-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200311103004.7649-1-vsementsov@virtuozzo.com> References: <20200311103004.7649-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, andrey.shinkevich@virtuozzo.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Split find_conflicting_inflight_req to be used separately. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Andrey Shinkevich Reviewed-by: Max Reitz --- block/block-copy.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index b075dba206..251d415a2c 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -24,23 +24,30 @@ #define BLOCK_COPY_MAX_BUFFER (1 * MiB) #define BLOCK_COPY_MAX_MEM (128 * MiB) =20 +static BlockCopyInFlightReq *find_conflicting_inflight_req(BlockCopyState = *s, + int64_t start, + int64_t end) +{ + BlockCopyInFlightReq *req; + + QLIST_FOREACH(req, &s->inflight_reqs, list) { + if (end > req->start_byte && start < req->end_byte) { + return req; + } + } + + return NULL; +} + static void coroutine_fn block_copy_wait_inflight_reqs(BlockCopyState *s, int64_t start, int64_t end) { BlockCopyInFlightReq *req; - bool waited; - - do { - waited =3D false; - QLIST_FOREACH(req, &s->inflight_reqs, list) { - if (end > req->start_byte && start < req->end_byte) { - qemu_co_queue_wait(&req->wait_queue, NULL); - waited =3D true; - break; - } - } - } while (waited); + + while ((req =3D find_conflicting_inflight_req(s, start, end))) { + qemu_co_queue_wait(&req->wait_queue, NULL); + } } =20 static void block_copy_inflight_req_begin(BlockCopyState *s, --=20 2.21.0