Util-Linux Archive on lore.kernel.org
 help / color / Atom feed
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Karel Zak <kzak@redhat.com>, util-linux@vger.kernel.org
Cc: Hans Holmberg <hans.holmberg@wdc.com>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: [PATCH RFC] blkzone: add capacity field to zone report
Date: Fri, 26 Jun 2020 21:12:25 +0900
Message-ID: <20200626121225.428611-1-shinichiro.kawasaki@wdc.com> (raw)

NVMe ZNS specification defines zone capacity. To support it in the
report zone interface, Linux kernel side patch review is ongoing. [1]
Expose it in report zone by blkzone command.

[1] https://www.spinics.net/lists/linux-block/msg55494.html

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 configure.ac        |  4 ++++
 sys-utils/blkzone.8 |  1 +
 sys-utils/blkzone.c | 20 ++++++++++++++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index e31dc3767..f3e9f5d0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,6 +322,10 @@ AC_CHECK_HEADERS([security/pam_misc.h],
 
 AC_CHECK_HEADERS([linux/blkzoned.h])
 
+AC_CHECK_DECLS([BLK_ZONE_REP_CAPACITY], [], [], [
+	#include <linux/blkzoned.h>
+])
+
 AC_CHECK_HEADERS([security/openpam.h], [], [], [
 #ifdef HAVE_SECURITY_PAM_APPL_H
 #include <security/pam_appl.h>
diff --git a/sys-utils/blkzone.8 b/sys-utils/blkzone.8
index 64ad23bb3..043bc96e2 100644
--- a/sys-utils/blkzone.8
+++ b/sys-utils/blkzone.8
@@ -29,6 +29,7 @@ tab(:);
 l l.
 start:Zone start sector
 len:Zone length in number of sectors
+cap:Zone capacity in number of sectors
 wptr:Zone write pointer position
 reset:Reset write pointer recommended
 non-seq:Non-sequential write resources active
diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c
index 11e90fb0e..0f62ca395 100644
--- a/sys-utils/blkzone.c
+++ b/sys-utils/blkzone.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <getopt.h>
@@ -189,6 +190,14 @@ done:
 	return rc == 0 ? sz : 0;
 }
 
+#if HAVE_DECL_BLK_ZONE_REP_CAPACITY
+#define has_zone_capacity(zi)	((zi)->flags & BLK_ZONE_REP_CAPACITY)
+#define zone_capacity(z)	(z)->capacity
+#else
+#define has_zone_capacity(zi)	(false)
+#define zone_capacity(z)	(z)->len
+#endif
+
 /*
  * blkzone report
  */
@@ -262,15 +271,22 @@ static int blkzone_report(struct blkzone_control *ctl)
 			uint64_t wp = entry->wp;
 			uint8_t cond = entry->cond;
 			uint64_t len = entry->len;
+			uint64_t cap;
 
 			if (!len) {
 				nr_zones = 0;
 				break;
 			}
 
-			printf(_("  start: 0x%09"PRIx64", len 0x%06"PRIx64", wptr 0x%06"PRIx64
+			if (has_zone_capacity(zi))
+				cap = zone_capacity(entry);
+			else
+				cap = entry->len;
+
+			printf(_("  start: 0x%09"PRIx64", len 0x%06"PRIx64
+				", cap 0x%06"PRIx64", wptr 0x%06"PRIx64
 				" reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
-				start, len, (type == 0x1) ? 0 : wp - start,
+				start, len, cap, (type == 0x1) ? 0 : wp - start,
 				entry->reset, entry->non_seq,
 				cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
 				type, type_text[type]);
-- 
2.26.2


             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 12:12 Shin'ichiro Kawasaki [this message]
2020-06-29 11:11 ` Karel Zak
2020-07-01 11:32   ` Shinichiro Kawasaki
2020-07-01 11:58     ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200626121225.428611-1-shinichiro.kawasaki@wdc.com \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=hans.holmberg@wdc.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org
	public-inbox-index util-linux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git