]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkzone: add capacity field to zone report
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 1 Jul 2020 11:33:26 +0000 (20:33 +0900)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Jul 2020 10:23:56 +0000 (12:23 +0200)
NVMe ZNS specification defines zone capacity. The report zone interface
of Linux kernel supports it. Expose it in report zone by blkzone command.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
configure.ac
sys-utils/blkzone.8
sys-utils/blkzone.c

index f1659ae89adf158673d15320db950c12ae9b627a..97f404f929b5ee109814c866761629c0b2735bc4 100644 (file)
@@ -344,6 +344,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>
index 64ad23bb3145812b38840cd2a36b94e147d93b8d..043bc96e23ac2a69289b3b6005e41487a98b59ea 100644 (file)
@@ -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
index ed5e68df74cea3c557f5f57c4232984fa6a27df4..67eaf1a02430d826879ccc25f39374e47d494e72 100644 (file)
@@ -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
  */
@@ -269,15 +278,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]);