[PATCH 2/2] lsblk: add columns of zoned parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Several parameters for zoned devices are missing from lsblk's columns. This
commit introduces them as following.

 ZONE-SIZE    zone size
 ZONE-WGRAN   zone write granularity
 ZONE-APPEND  zone append max bytes
 ZONES-NR     number of zones
 ZONES-OMAX   max open zones
 ZONES-AMAX   max active zones

Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx>
---
 misc-utils/lsblk.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 775a6d832076..6f1c5dc67060 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -123,6 +123,12 @@ enum {
 	COL_WSAME,
 	COL_WWN,
 	COL_ZONED,
+	COL_ZONESIZE,
+	COL_ZONEWRITEGRAN,
+	COL_ZONEAPPEND,
+	COL_ZONES_NR,
+	COL_ZONES_OMAX,
+	COL_ZONES_AMAX,
 };
 
 /* basic table settings */
@@ -213,6 +219,12 @@ static struct colinfo infos[] = {
 	[COL_WSAME] = { "WSAME", 6, SCOLS_FL_RIGHT, N_("write same max bytes"), COLTYPE_SIZE },
 	[COL_WWN] = { "WWN", 18, 0, N_("unique storage identifier") },
 	[COL_ZONED] = { "ZONED", 0.3, 0, N_("zone model") },
+	[COL_ZONESIZE] = { "ZONE-SIZE", 9, SCOLS_FL_RIGHT, N_("zone size"), COLTYPE_NUM },
+	[COL_ZONEWRITEGRAN] = { "ZONE-WGRAN", 10, SCOLS_FL_RIGHT, N_("zone write granularity"), COLTYPE_NUM },
+	[COL_ZONEAPPEND] = { "ZONE-APPEND", 11, SCOLS_FL_RIGHT, N_("zone append max bytes"), COLTYPE_NUM },
+	[COL_ZONES_NR] = { "ZONES-NR", 8, SCOLS_FL_RIGHT, N_("number of zones"), COLTYPE_NUM },
+	[COL_ZONES_OMAX] = { "ZONES-OMAX", 10, SCOLS_FL_RIGHT, N_("max open zones"), COLTYPE_NUM },
+	[COL_ZONES_AMAX] = { "ZONES-AMAX", 10, SCOLS_FL_RIGHT, N_("max active zones"), COLTYPE_NUM },
 };
 
 struct lsblk *lsblk;	/* global handler */
@@ -1067,6 +1079,46 @@ static char *device_get_data(
 	case COL_ZONED:
 		ul_path_read_string(dev->sysfs, &str, "queue/zoned");
 		break;
+	case COL_ZONESIZE:
+	{
+		uint64_t x;
+
+		if (ul_path_read_u64(dev->sysfs, &x, "queue/chunk_sectors") == 0) {
+			x <<= 9;
+			if (lsblk->bytes)
+				xasprintf(&str, "%ju", x);
+			else
+				str = size_to_human_string(SIZE_SUFFIX_1LETTER, x);
+			if (sortdata)
+				*sortdata = x;
+		}
+		break;
+	}
+	case COL_ZONEWRITEGRAN:
+		device_read_bytes(dev, "queue/zone_write_granularity", &str, sortdata);
+		break;
+	case COL_ZONEAPPEND:
+		device_read_bytes(dev, "queue/zone_append_max_bytes", &str, sortdata);
+		break;
+	case COL_ZONES_NR:
+		ul_path_read_string(dev->sysfs, &str, "queue/nr_zones");
+		if (sortdata)
+			str2u64(str, sortdata);
+		break;
+	case COL_ZONES_OMAX:
+		ul_path_read_string(dev->sysfs, &str, "queue/max_open_zones");
+		if (!str)
+			str = xstrdup("0");
+		if (sortdata)
+			str2u64(str, sortdata);
+		break;
+	case COL_ZONES_AMAX:
+		ul_path_read_string(dev->sysfs, &str, "queue/max_active_zones");
+		if (!str)
+			str = xstrdup("0");
+		if (sortdata)
+			str2u64(str, sortdata);
+		break;
 	case COL_DAX:
 		ul_path_read_string(dev->sysfs, &str, "queue/dax");
 		break;
-- 
2.33.0




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux