From nobody Mon Feb 9 16:19:31 2026 Delivered-To: importer@patchew.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676637137338393.03805513547195; Fri, 17 Feb 2023 04:32:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSzWs-0005DU-0X; Fri, 17 Feb 2023 07:07:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSzWp-0005BU-Dw; Fri, 17 Feb 2023 07:07:51 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSzWn-0003Pv-S0; Fri, 17 Feb 2023 07:07:51 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2028F5C0129; Fri, 17 Feb 2023 07:07:49 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 17 Feb 2023 07:07:49 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 17 Feb 2023 07:07:46 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=defmacro.it; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1676635669; x=1676722069; bh=yN qkIi9DTxLm3SgOgUDJlmyKa+80oFSROj6j8Gdhsfo=; b=NL5hE+cP6j0ka1K4cd sr3iKY7YTEyBOD+V/NLYbaTTI4JR0y/Mb4weRm9YpHeQGs0w70u3ctlaJp5mlfl0 qPBrdZi3OgwuGFezupdD/A1DVKZy+cOGnnyn+5/R0P0TvuE9/8TQxPTOm2cH5tgx 8VZkVLErHWhl/TqznQfVQeefAL5sZCG6SSWIFKfyLCIrkxjz1Xn6mwAEayOyJvsL 5aqLTOKWYF+HWEUXZhoni3TbkvMrPczrAXvxfVvhu1KcjBRH+ZIRM7Y53nvC4ajx pKb++pZblk+SH7oFCEJMd23zSlHmsABvbfaN73r4O75pIZuLrcUmP9F7yXORzqMS +/qQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1676635669; x=1676722069; bh=yNqkIi9DTxLm3 SgOgUDJlmyKa+80oFSROj6j8Gdhsfo=; b=iA2G2mqJFExJ9Fd1gPW78Zc+MTQug TReKcGwKG7VHFNo5umXixID92cqZLpEdMiHYTJ9dt5DBKZ9ZzLb8r0Nkul/PJLfU bkg8cN4m1zOYQzIKOgN5xh8Ux10GbyqEZELlHXBb8x5zRlyy10rCpJk9QjE2ZDMw Mjx2aFAJ94p5/16liEYtUgBP9C+HTDNmTOanA8l3aODtGROk1/Ox2wh98enijXnK agpbuEJpsD62+sYorHvf3Giqw/wRJXfMfYFamQJ8Liv1h7tcaZFVzmQSIREKQdWr 5MFk3YtKIL1/9FhSMhENXrye+LrkeK518dXKhX1A+mPFRf5BE+oyDVEYw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeiledgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheplfgvshhp vghrucffvghvrghnthhivghruceojhifugesuggvfhhmrggtrhhordhitheqnecuggftrf grthhtvghrnhepvddvtefhtdeugfetfeeukedtfeeitddugfffleehkeelveektdevteef leduueevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epjhifugesuggvfhhmrggtrhhordhith X-ME-Proxy: Feedback-ID: i0f41475f:Fastmail From: Jesper Devantier To: qemu-devel@nongnu.org, jwd@defmacro.it Cc: Stefan Hajnoczi , Hanna Reitz , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , qemu-block@nongnu.org, Keith Busch , Fam Zheng , Joel Granados , Klaus Jensen Subject: [PATCH v2 1/5] hw/nvme: move adjustment of data_units{read,written} Date: Fri, 17 Feb 2023 13:07:39 +0100 Message-Id: <20230217120743.308632-2-jwd@defmacro.it> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230217120743.308632-1-jwd@defmacro.it> References: <20230217120743.308632-1-jwd@defmacro.it> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=66.111.4.29; envelope-from=jwd@defmacro.it; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1676637139012100003 Content-Type: text/plain; charset="utf-8" From: Joel Granados In order to return the units_{read/written} required by the SMART log we need to shift the number of bytes value by BDRV_SECTORS_BITS and multiply by 1000. This is a prep patch that moves this adjustment to where the SMART log is calculated in order to use the stats struct for calculating OCP extended smart log values. Reviewed-by: Klaus Jensen Signed-off-by: Joel Granados Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f25cc2c235..99b92ff20b 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4386,8 +4386,8 @@ static void nvme_set_blk_stats(NvmeNamespace *ns, str= uct nvme_stats *stats) { BlockAcctStats *s =3D blk_get_stats(ns->blkconf.blk); =20 - stats->units_read +=3D s->nr_bytes[BLOCK_ACCT_READ] >> BDRV_SECTOR_BIT= S; - stats->units_written +=3D s->nr_bytes[BLOCK_ACCT_WRITE] >> BDRV_SECTOR= _BITS; + stats->units_read +=3D s->nr_bytes[BLOCK_ACCT_READ]; + stats->units_written +=3D s->nr_bytes[BLOCK_ACCT_WRITE]; stats->read_commands +=3D s->nr_ops[BLOCK_ACCT_READ]; stats->write_commands +=3D s->nr_ops[BLOCK_ACCT_WRITE]; } @@ -4401,6 +4401,7 @@ static uint16_t nvme_smart_info(NvmeCtrl *n, uint8_t = rae, uint32_t buf_len, uint32_t trans_len; NvmeNamespace *ns; time_t current_ms; + uint64_t u_read, u_written; =20 if (off >=3D sizeof(smart)) { return NVME_INVALID_FIELD | NVME_DNR; @@ -4427,10 +4428,11 @@ static uint16_t nvme_smart_info(NvmeCtrl *n, uint8_= t rae, uint32_t buf_len, trans_len =3D MIN(sizeof(smart) - off, buf_len); smart.critical_warning =3D n->smart_critical_warning; =20 - smart.data_units_read[0] =3D cpu_to_le64(DIV_ROUND_UP(stats.units_read, - 1000)); - smart.data_units_written[0] =3D cpu_to_le64(DIV_ROUND_UP(stats.units_w= ritten, - 1000)); + u_read =3D DIV_ROUND_UP(stats.units_read >> BDRV_SECTOR_BITS, 1000); + u_written =3D DIV_ROUND_UP(stats.units_written >> BDRV_SECTOR_BITS, 10= 00); + + smart.data_units_read[0] =3D cpu_to_le64(u_read); + smart.data_units_written[0] =3D cpu_to_le64(u_written); smart.host_read_commands[0] =3D cpu_to_le64(stats.read_commands); smart.host_write_commands[0] =3D cpu_to_le64(stats.write_commands); =20 --=20 2.39.1