]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkzone: don't show wptr when zones are full
authorWilfred Mallawa <wilfred.mallawa@wdc.com>
Thu, 12 Feb 2026 03:02:03 +0000 (13:02 +1000)
committerWilfred Mallawa <wilfred.mallawa@wdc.com>
Thu, 12 Feb 2026 03:15:15 +0000 (13:15 +1000)
blkzone report displays the write pointer when zones are full, however, the
writepointer value is not accurate for full zones as all zone LBAs have been
written. Instead, fix this so that we show "N/A" for the writepointer field
if the zone condition is full.

While we are at it, extend this behavior for convetional zones instead
of displaying 0 for the writepointer.

Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
sys-utils/blkzone.c

index 7e9ae6e71b4b82807b82a463396b409c6808a2a8..9de77195818bfcb587b7c31b089c020d8fad5f64 100644 (file)
@@ -275,6 +275,7 @@ static int blkzone_report(struct blkzone_control *ctl)
                        unsigned int type = entry.type;
                        uint64_t start = entry.start;
                        uint64_t wp = entry.wp;
+                       char wp_str[32] = {0};
                        uint8_t cond = entry.cond;
                        uint64_t len = entry.len;
                        uint64_t cap;
@@ -289,21 +290,28 @@ static int blkzone_report(struct blkzone_control *ctl)
                        else
                                cap = entry.len;
 
+                       if (type == BLK_ZONE_TYPE_CONVENTIONAL ||
+                           cond == BLK_ZONE_COND_FULL)
+                               snprintf(wp_str, sizeof(wp_str), "N/A");
+                       else
+                               snprintf(wp_str, sizeof(wp_str),
+                                        "0x%06" PRIx64, wp - start);
+
                        if (only_capacity_sum) {
                                capacity_sum += cap;
                        } else if (has_zone_capacity(zi)) {
                                printf(_("  start: 0x%09"PRIx64", len 0x%06"PRIx64
-                                       ", cap 0x%06"PRIx64", wptr 0x%06"PRIx64
+                                       ", cap 0x%06"PRIx64", wptr %s"
                                        " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
-                                       start, len, cap, (type == 0x1) ? 0 : wp - start,
+                                       start, len, cap, wp_str,
                                        entry.reset, entry.non_seq,
                                        cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
                                        type, type_text[type]);
                        } else {
                                printf(_("  start: 0x%09"PRIx64", len 0x%06"PRIx64
-                                       ", wptr 0x%06"PRIx64
+                                       ", wptr %s"
                                        " reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
-                                       start, len, (type == 0x1) ? 0 : wp - start,
+                                       start, len, wp_str,
                                        entry.reset, entry.non_seq,
                                        cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
                                        type, type_text[type]);