From nobody Mon Feb 9 20:54:48 2026 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; dkim=fail; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516187240000602.2678745015611; Wed, 17 Jan 2018 03:07:20 -0800 (PST) Received: from localhost ([::1]:55394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eblYt-0006EH-4i for importer@patchew.org; Wed, 17 Jan 2018 06:07:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eblTB-0001eW-VI for qemu-devel@nongnu.org; Wed, 17 Jan 2018 06:01:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eblT6-0003T7-3N for qemu-devel@nongnu.org; Wed, 17 Jan 2018 06:01:26 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:37570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eblT5-0003S9-SY; Wed, 17 Jan 2018 06:01:20 -0500 Received: by mail-wr0-x243.google.com with SMTP id f11so7906574wre.4; Wed, 17 Jan 2018 03:01:19 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id o12sm3996897wrf.81.2018.01.17.03.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2018 03:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QmURZG1y+gTB/C9JXVxccmDWFWmU2/nD/YEkTymeXgk=; b=BgluGnD8QsN5cGAHrRQ/xjRD6Q47Mmd/kgzfZo8nqHs4ntuaXcaAh++ux/KsqXpYWH XUTBbWB3TN/Vs0BbR9XC1XelVfKq/ULwYpAJOZh2bLqEoB5p81eB48Repka0TfYU6OJV vlS964uv0H5MxCYTAScgUMTC7ipyhA4T93Aoe9yckv0FwEEk37HBip/BnFrAIbYH1K1S y2qJjwkyEHF/m22o9d3p1NXoq/uRXHwWZ7cARStEfm0SeR44K8ARIROvwyc7zEAs/7Be 8lkT9vg3fPUnSKqlJj6v0FlDvh2rY1coTG+22dsYIusyfKnDvnHuY6UQWzY6YL0lyCIY 1U7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QmURZG1y+gTB/C9JXVxccmDWFWmU2/nD/YEkTymeXgk=; b=Puy8IKPa8veefWZLhfZ0dJRrmxNJxgRQSkGWG//iZ+SSCq0q8ATss6StwSkZlHz0en zaEEVsImqYx8nq1XNSjmmhDogjx1TElO8ozS09Q72U6MHdxuZtDVghS7fTZxTH7v+5QS fWiy2kIa7GD/MM17AnP8hPXW+ak5MS5ym72FZHBAo4CwQBLN+FVKBnwSxeDsgVfDloO8 I9WBtTK1E7BnrYehe74gYg3OTeKHvJ0eeQ0gqf0ZXd4GSFf9tSuxhqo2VfxNh9jJDgP2 6NGaAvN5NUpIaXwFM7HF7/c7xvChZttl1yyZyXvrZyOGJXpAn+JWVMRLs0e3saWPNzr9 djtQ== X-Gm-Message-State: AKwxytflQyt4icWT3gYS9S+VJusTnO2aTEufkjpEaqbP3tiEuuYOOOpU gxVfpnLI4DuuH3863WlZjGGN9uIm X-Google-Smtp-Source: ACJfBotG31gFF8YSjjw5UKku4rj8ioy3Z10vJtjIQdko2TTL4x31EiglXvA/OirYf00+zt65kJ+EKA== X-Received: by 10.223.164.86 with SMTP id e22mr2171036wra.19.1516186878400; Wed, 17 Jan 2018 03:01:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 17 Jan 2018 12:00:50 +0100 Message-Id: <1516186851-23896-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516186851-23896-1-git-send-email-pbonzini@redhat.com> References: <1516186851-23896-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH 6/7] qcow2: introduce qcow2_write_caches and qcow2_flush_caches 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: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Avoid recursively taking s->lock during bdrv_check. Signed-off-by: Paolo Bonzini --- block/qcow2-refcount.c | 28 ++++++++++++++++++++++++++++ block/qcow2.c | 20 ++++---------------- block/qcow2.h | 2 ++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 3de1ab5..e0d9dc1 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1172,7 +1172,35 @@ void qcow2_free_any_clusters(BlockDriverState *bs, u= int64_t l2_entry, } } =20 +int coroutine_fn qcow2_write_caches(BlockDriverState *bs) +{ + BDRVQcow2State *s =3D bs->opaque; + int ret; =20 + ret =3D qcow2_cache_write(bs, s->l2_table_cache); + if (ret < 0) { + return ret; + } + + if (qcow2_need_accurate_refcounts(s)) { + ret =3D qcow2_cache_write(bs, s->refcount_block_cache); + if (ret < 0) { + return ret; + } + } + + return 0; +} + +int coroutine_fn qcow2_flush_caches(BlockDriverState *bs) +{ + int ret =3D qcow2_write_caches(bs); + if (ret < 0) { + return ret; + } + + return bdrv_flush(bs->file->bs); +} =20 /*********************************************************/ /* snapshots and image creation */ diff --git a/block/qcow2.c b/block/qcow2.c index e886a44..4a10b55 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -492,7 +492,7 @@ static int qcow2_mark_clean(BlockDriverState *bs) =20 s->incompatible_features &=3D ~QCOW2_INCOMPAT_DIRTY; =20 - ret =3D bdrv_flush(bs); + ret =3D qcow2_flush_caches(bs); if (ret < 0) { return ret; } @@ -522,7 +522,7 @@ int qcow2_mark_consistent(BlockDriverState *bs) BDRVQcow2State *s =3D bs->opaque; =20 if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { - int ret =3D bdrv_flush(bs); + int ret =3D qcow2_flush_caches(bs); if (ret < 0) { return ret; } @@ -3653,22 +3653,10 @@ static coroutine_fn int qcow2_co_flush_to_os(BlockD= riverState *bs) int ret; =20 qemu_co_mutex_lock(&s->lock); - ret =3D qcow2_cache_write(bs, s->l2_table_cache); - if (ret < 0) { - qemu_co_mutex_unlock(&s->lock); - return ret; - } - - if (qcow2_need_accurate_refcounts(s)) { - ret =3D qcow2_cache_write(bs, s->refcount_block_cache); - if (ret < 0) { - qemu_co_mutex_unlock(&s->lock); - return ret; - } - } + ret =3D qcow2_write_caches(bs); qemu_co_mutex_unlock(&s->lock); =20 - return 0; + return ret; } =20 static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *i= n_bs, diff --git a/block/qcow2.h b/block/qcow2.h index 46c8cf4..25b50f8 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -570,6 +570,8 @@ void qcow2_free_any_clusters(BlockDriverState *bs, uint= 64_t l2_entry, int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend); =20 +int coroutine_fn qcow2_flush_caches(BlockDriverState *bs); +int coroutine_fn qcow2_write_caches(BlockDriverState *bs); int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); =20 --=20 1.8.3.1