From nobody Wed Nov 5 16:38:15 2025 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.zoho.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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496923887621881.7067775280565; Thu, 8 Jun 2017 05:11:27 -0700 (PDT) Received: from localhost ([::1]:48887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIwHd-00077f-VJ for importer@patchew.org; Thu, 08 Jun 2017 08:11:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIw49-00024b-N5 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 07:57:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIw48-00021Q-Na for qemu-devel@nongnu.org; Thu, 08 Jun 2017 07:57:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIw48-00020v-Ef for qemu-devel@nongnu.org; Thu, 08 Jun 2017 07:57:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68C9261D12; Thu, 8 Jun 2017 11:57:27 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-24.pek2.redhat.com [10.72.12.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26D7E17DC9; Thu, 8 Jun 2017 11:57:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 68C9261D12 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 68C9261D12 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 8 Jun 2017 19:56:42 +0800 Message-Id: <20170608115643.18859-23-famz@redhat.com> In-Reply-To: <20170608115643.18859-1-famz@redhat.com> References: <20170608115643.18859-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Jun 2017 11:57:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v3 22/23] block: split BlockAcctStats creation and setup 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: peter.maydell@linaro.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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini block_acct_destroy is called unconditionally in blk_delete, but there is no BlockAcctStats function that is called unconditionally in blk_new. Split block_acct_init in two, so that it will be possible to create a QemuMutex in block_acct_init and destroy it in block_acct_cleanup. Cc: Alberto Garcia Signed-off-by: Paolo Bonzini Message-Id: <20170605123908.18777-19-pbonzini@redhat.com> Reviewed-by: Alberto Garcia Signed-off-by: Fam Zheng --- block/accounting.c | 13 ++++++++----- block/block-backend.c | 1 + blockdev.c | 2 +- include/block/accounting.h | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/block/accounting.c b/block/accounting.c index a279e0b..ce6dbf7 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -32,17 +32,20 @@ static QEMUClockType clock_type =3D QEMU_CLOCK_REALTIME; static const int qtest_latency_ns =3D NANOSECONDS_PER_SECOND / 1000; =20 -void block_acct_init(BlockAcctStats *stats, bool account_invalid, - bool account_failed) +void block_acct_init(BlockAcctStats *stats) { - stats->account_invalid =3D account_invalid; - stats->account_failed =3D account_failed; - if (qtest_enabled()) { clock_type =3D QEMU_CLOCK_VIRTUAL; } } =20 +void block_acct_setup(BlockAcctStats *stats, bool account_invalid, + bool account_failed) +{ + stats->account_invalid =3D account_invalid; + stats->account_failed =3D account_failed; +} + void block_acct_cleanup(BlockAcctStats *stats) { BlockAcctTimedStats *s, *next; diff --git a/block/block-backend.c b/block/block-backend.c index be2ddf1..828497e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -219,6 +219,7 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_pe= rm) qemu_co_mutex_init(&blk->public.throttled_reqs_lock); qemu_co_queue_init(&blk->public.throttled_reqs[0]); qemu_co_queue_init(&blk->public.throttled_reqs[1]); + block_acct_init(&blk->stats); =20 notifier_list_init(&blk->remove_bs_notifiers); notifier_list_init(&blk->insert_bs_notifiers); diff --git a/blockdev.c b/blockdev.c index 6e7c8a6..0fa2e7e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -595,7 +595,7 @@ static BlockBackend *blockdev_init(const char *file, QD= ict *bs_opts, autostart =3D 0; } =20 - block_acct_init(blk_get_stats(blk), account_invalid, account_faile= d); + block_acct_setup(blk_get_stats(blk), account_invalid, account_fail= ed); =20 if (!parse_stats_intervals(blk_get_stats(blk), interval_list, errp= )) { blk_unref(blk); diff --git a/include/block/accounting.h b/include/block/accounting.h index 2089163..55cb06f 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -61,7 +61,8 @@ typedef struct BlockAcctCookie { enum BlockAcctType type; } BlockAcctCookie; =20 -void block_acct_init(BlockAcctStats *stats, bool account_invalid, +void block_acct_init(BlockAcctStats *stats); +void block_acct_setup(BlockAcctStats *stats, bool account_invalid, bool account_failed); void block_acct_cleanup(BlockAcctStats *stats); void block_acct_add_interval(BlockAcctStats *stats, unsigned interval_leng= th); --=20 2.9.4