* [PATCH 0/2] add columns for zoned parameters
@ 2021-08-24 1:17 Naohiro Aota
2021-08-24 1:17 ` [PATCH 1/2] lsblk: factor out function to read sysfs param as bytes Naohiro Aota
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Naohiro Aota @ 2021-08-24 1:17 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Naohiro Aota
Several parameters for zoned devices are missing from lsblk's columns. This
series introduces them as following.
Column Name Description Sysfs path
---------------------------------------------------------------------
ZONE-SIZE zone size queue/chunk_sectors
ZONE-WGRAN zone write granularity queue/zone_write_granularity
ZONE-APPEND zone append max bytes queue/zone_append_max_bytes
ZONES-NR number of zones queue/nr_zones
ZONES-OMAX max open zones queue/max_open_zones
ZONES-AMAX max active zones queue/max_active_zones
Sample output:
$ lsblk -o NAME,ZONED,ZONE-SIZE,ZONE-WGRAN,ZONE-APPEND,ZONES-NR,ZONES-OMAX,ZONES-AMAX -i
NAME ZONED ZONE-SIZE ZONE-WGRAN ZONE-APPEND ZONES-NR ZONES-OMAX ZONES-AMAX
sda host-managed 256M 4K 672K 55880 128 0
sdb host-managed 256M 4K 672K 55880 128 0
zram0 none 0B 0B 0B 0 0 0
nvme2n1 none 0B 0B 0B 0 0 0
|-nvme2n1p1 none 0B 0B 0B 0 0 0
|-nvme2n1p2 none 0B 0B 0B 0 0 0
`-nvme2n1p3 none 0B 0B 0B 0 0 0
nvme0n1 none 0B 0B 0B 0 0 0
nvme1n1 none 0B 0B 0B 0 0 0
nvme0n2 host-managed 2G 4K 4M 1844 14 14
nvme1n2 host-managed 2G 4K 4M 1844 14 14
$ lsblk --help|grep -i zone
-z, --zoned print zone model
ZONED zone model
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
Naohiro Aota (2):
lsblk: factor out function to read sysfs param as bytes
lsblk: add columns of zoned parameters
misc-utils/lsblk.c | 95 ++++++++++++++++++++++++++++++++++------------
1 file changed, 71 insertions(+), 24 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] lsblk: factor out function to read sysfs param as bytes
2021-08-24 1:17 [PATCH 0/2] add columns for zoned parameters Naohiro Aota
@ 2021-08-24 1:17 ` Naohiro Aota
2021-08-24 1:17 ` [PATCH 2/2] lsblk: add columns of zoned parameters Naohiro Aota
2021-08-24 12:47 ` [PATCH 0/2] add columns for " Karel Zak
2 siblings, 0 replies; 7+ messages in thread
From: Naohiro Aota @ 2021-08-24 1:17 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Naohiro Aota
Factor out a new function device_read_bytes() to read a sysfs path as bytes
for a preparation for the next commit and to reduce the code duplication.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
misc-utils/lsblk.c | 45 ++++++++++++++++++++-------------------------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 100eba0779f8..775a6d832076 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -708,6 +708,24 @@ static uint64_t device_get_discard_granularity(struct lsblk_device *dev)
return dev->discard_granularity;
}
+static void device_read_bytes(struct lsblk_device *dev, char *path, char **str,
+ uint64_t *sortdata)
+{
+ if (lsblk->bytes) {
+ ul_path_read_string(dev->sysfs, str, path);
+ if (sortdata)
+ str2u64(*str, sortdata);
+ } else {
+ uint64_t x;
+
+ if (ul_path_read_u64(dev->sysfs, &x, path) == 0) {
+ *str = size_to_human_string(SIZE_SUFFIX_1LETTER, x);
+ if (sortdata)
+ *sortdata = x;
+ }
+ }
+}
+
/*
* Generates data (string) for column specified by column ID for specified device. If sortdata
* is not NULL then returns number usable to sort the column if the data are available for the
@@ -1033,18 +1051,7 @@ static char *device_get_data(
}
break;
case COL_DMAX:
- if (lsblk->bytes) {
- ul_path_read_string(dev->sysfs, &str, "queue/discard_max_bytes");
- if (sortdata)
- str2u64(str, sortdata);
- } else {
- uint64_t x;
- if (ul_path_read_u64(dev->sysfs, &x, "queue/discard_max_bytes") == 0) {
- str = size_to_human_string(SIZE_SUFFIX_1LETTER, x);
- if (sortdata)
- *sortdata = x;
- }
- }
+ device_read_bytes(dev, "queue/discard_max_bytes", &str, sortdata);
break;
case COL_DZERO:
if (device_get_discard_granularity(dev) > 0)
@@ -1053,19 +1060,7 @@ static char *device_get_data(
str = xstrdup("0");
break;
case COL_WSAME:
- if (lsblk->bytes) {
- ul_path_read_string(dev->sysfs, &str, "queue/write_same_max_bytes");
- if (sortdata)
- str2u64(str, sortdata);
- } else {
- uint64_t x;
-
- if (ul_path_read_u64(dev->sysfs, &x, "queue/write_same_max_bytes") == 0) {
- str = size_to_human_string(SIZE_SUFFIX_1LETTER, x);
- if (sortdata)
- *sortdata = x;
- }
- }
+ device_read_bytes(dev, "queue/write_same_max_bytes", &str, sortdata);
if (!str)
str = xstrdup("0");
break;
--
2.33.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] lsblk: add columns of zoned parameters
2021-08-24 1:17 [PATCH 0/2] add columns for zoned parameters Naohiro Aota
2021-08-24 1:17 ` [PATCH 1/2] lsblk: factor out function to read sysfs param as bytes Naohiro Aota
@ 2021-08-24 1:17 ` Naohiro Aota
2021-08-24 12:47 ` [PATCH 0/2] add columns for " Karel Zak
2 siblings, 0 replies; 7+ messages in thread
From: Naohiro Aota @ 2021-08-24 1:17 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Naohiro Aota
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@wdc.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] add columns for zoned parameters
2021-08-24 1:17 [PATCH 0/2] add columns for zoned parameters Naohiro Aota
2021-08-24 1:17 ` [PATCH 1/2] lsblk: factor out function to read sysfs param as bytes Naohiro Aota
2021-08-24 1:17 ` [PATCH 2/2] lsblk: add columns of zoned parameters Naohiro Aota
@ 2021-08-24 12:47 ` Karel Zak
2021-08-25 2:12 ` Naohiro Aota
2 siblings, 1 reply; 7+ messages in thread
From: Karel Zak @ 2021-08-24 12:47 UTC (permalink / raw)
To: Naohiro Aota; +Cc: util-linux
On Tue, Aug 24, 2021 at 10:17:16AM +0900, Naohiro Aota wrote:
> Several parameters for zoned devices are missing from lsblk's columns. This
> series introduces them as following.
Thanks! I thought about it a few weeks ago ;-)
>
> Column Name Description Sysfs path
> ---------------------------------------------------------------------
> ZONE-SIZE zone size queue/chunk_sectors
> ZONE-WGRAN zone write granularity queue/zone_write_granularity
> ZONE-APPEND zone append max bytes queue/zone_append_max_bytes
> ZONES-NR number of zones queue/nr_zones
> ZONES-OMAX max open zones queue/max_open_zones
> ZONES-AMAX max active zones queue/max_active_zones
>
> Sample output:
>
> $ lsblk -o NAME,ZONED,ZONE-SIZE,ZONE-WGRAN,ZONE-APPEND,ZONES-NR,ZONES-OMAX,ZONES-AMAX -i
What about to add all the columns to "--zoned" output too?
We do not keep backward compatibility for set of columns in outputs
like --zoned, so it's open for changes. I guess we can use --zoned as
a generic option for all zoned stuff and not for a model only.
> NAME ZONED ZONE-SIZE ZONE-WGRAN ZONE-APPEND ZONES-NR ZONES-OMAX ZONES-AMAX
> sda host-managed 256M 4K 672K 55880 128 0
> sdb host-managed 256M 4K 672K 55880 128 0
> zram0 none 0B 0B 0B 0 0 0
> nvme2n1 none 0B 0B 0B 0 0 0
> |-nvme2n1p1 none 0B 0B 0B 0 0 0
> |-nvme2n1p2 none 0B 0B 0B 0 0 0
> `-nvme2n1p3 none 0B 0B 0B 0 0 0
> nvme0n1 none 0B 0B 0B 0 0 0
> nvme1n1 none 0B 0B 0B 0 0 0
> nvme0n2 host-managed 2G 4K 4M 1844 14 14
> nvme1n2 host-managed 2G 4K 4M 1844 14 14
>
> $ lsblk --help|grep -i zone
> -z, --zoned print zone model
> ZONED zone model
> 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
It would be nice to have shorter column names, but I do not have any
sane suggestion (Z-SIZE or Z-APPEND seems strange).
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] add columns for zoned parameters
2021-08-24 12:47 ` [PATCH 0/2] add columns for " Karel Zak
@ 2021-08-25 2:12 ` Naohiro Aota
2021-08-25 2:49 ` Damien Le Moal
2021-08-25 10:03 ` Karel Zak
0 siblings, 2 replies; 7+ messages in thread
From: Naohiro Aota @ 2021-08-25 2:12 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux, Damien Le Moal
On Tue, Aug 24, 2021 at 02:47:29PM +0200, Karel Zak wrote:
> On Tue, Aug 24, 2021 at 10:17:16AM +0900, Naohiro Aota wrote:
> > Several parameters for zoned devices are missing from lsblk's columns. This
> > series introduces them as following.
>
> Thanks! I thought about it a few weeks ago ;-)
>
> >
> > Column Name Description Sysfs path
> > ---------------------------------------------------------------------
> > ZONE-SIZE zone size queue/chunk_sectors
> > ZONE-WGRAN zone write granularity queue/zone_write_granularity
> > ZONE-APPEND zone append max bytes queue/zone_append_max_bytes
> > ZONES-NR number of zones queue/nr_zones
> > ZONES-OMAX max open zones queue/max_open_zones
> > ZONES-AMAX max active zones queue/max_active_zones
> >
> > Sample output:
> >
> > $ lsblk -o NAME,ZONED,ZONE-SIZE,ZONE-WGRAN,ZONE-APPEND,ZONES-NR,ZONES-OMAX,ZONES-AMAX -i
>
> What about to add all the columns to "--zoned" output too?
>
> We do not keep backward compatibility for set of columns in outputs
> like --zoned, so it's open for changes. I guess we can use --zoned as
> a generic option for all zoned stuff and not for a model only.
Nice idea. I'll add a patch for that.
> > NAME ZONED ZONE-SIZE ZONE-WGRAN ZONE-APPEND ZONES-NR ZONES-OMAX ZONES-AMAX
> > sda host-managed 256M 4K 672K 55880 128 0
> > sdb host-managed 256M 4K 672K 55880 128 0
> > zram0 none 0B 0B 0B 0 0 0
> > nvme2n1 none 0B 0B 0B 0 0 0
> > |-nvme2n1p1 none 0B 0B 0B 0 0 0
> > |-nvme2n1p2 none 0B 0B 0B 0 0 0
> > `-nvme2n1p3 none 0B 0B 0B 0 0 0
> > nvme0n1 none 0B 0B 0B 0 0 0
> > nvme1n1 none 0B 0B 0B 0 0 0
> > nvme0n2 host-managed 2G 4K 4M 1844 14 14
> > nvme1n2 host-managed 2G 4K 4M 1844 14 14
> >
> > $ lsblk --help|grep -i zone
> > -z, --zoned print zone model
> > ZONED zone model
> > 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
>
> It would be nice to have shorter column names, but I do not have any
> sane suggestion (Z-SIZE or Z-APPEND seems strange).
Hmm, considering we already have DISC-{ALN,GRAN,MAX,ZERO}, how about
ZONE-{SZ,GRAN,APP,NR,OMAX,AMAX}?
> Karel
>
> --
> Karel Zak <kzak@redhat.com>
> http://karelzak.blogspot.com
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] add columns for zoned parameters
2021-08-25 2:12 ` Naohiro Aota
@ 2021-08-25 2:49 ` Damien Le Moal
2021-08-25 10:03 ` Karel Zak
1 sibling, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2021-08-25 2:49 UTC (permalink / raw)
To: Naohiro Aota, Karel Zak; +Cc: util-linux
On 2021/08/25 11:12, Naohiro Aota wrote:
> On Tue, Aug 24, 2021 at 02:47:29PM +0200, Karel Zak wrote:
>> On Tue, Aug 24, 2021 at 10:17:16AM +0900, Naohiro Aota wrote:
>>> Several parameters for zoned devices are missing from lsblk's columns. This
>>> series introduces them as following.
>>
>> Thanks! I thought about it a few weeks ago ;-)
>>
>>>
>>> Column Name Description Sysfs path
>>> ---------------------------------------------------------------------
>>> ZONE-SIZE zone size queue/chunk_sectors
>>> ZONE-WGRAN zone write granularity queue/zone_write_granularity
>>> ZONE-APPEND zone append max bytes queue/zone_append_max_bytes
>>> ZONES-NR number of zones queue/nr_zones
>>> ZONES-OMAX max open zones queue/max_open_zones
>>> ZONES-AMAX max active zones queue/max_active_zones
>>>
>>> Sample output:
>>>
>>> $ lsblk -o NAME,ZONED,ZONE-SIZE,ZONE-WGRAN,ZONE-APPEND,ZONES-NR,ZONES-OMAX,ZONES-AMAX -i
>>
>> What about to add all the columns to "--zoned" output too?
>>
>> We do not keep backward compatibility for set of columns in outputs
>> like --zoned, so it's open for changes. I guess we can use --zoned as
>> a generic option for all zoned stuff and not for a model only.
>
> Nice idea. I'll add a patch for that.
+1
>
>>> NAME ZONED ZONE-SIZE ZONE-WGRAN ZONE-APPEND ZONES-NR ZONES-OMAX ZONES-AMAX
>>> sda host-managed 256M 4K 672K 55880 128 0
>>> sdb host-managed 256M 4K 672K 55880 128 0
>>> zram0 none 0B 0B 0B 0 0 0
>>> nvme2n1 none 0B 0B 0B 0 0 0
>>> |-nvme2n1p1 none 0B 0B 0B 0 0 0
>>> |-nvme2n1p2 none 0B 0B 0B 0 0 0
>>> `-nvme2n1p3 none 0B 0B 0B 0 0 0
>>> nvme0n1 none 0B 0B 0B 0 0 0
>>> nvme1n1 none 0B 0B 0B 0 0 0
>>> nvme0n2 host-managed 2G 4K 4M 1844 14 14
>>> nvme1n2 host-managed 2G 4K 4M 1844 14 14
>>>
>>> $ lsblk --help|grep -i zone
>>> -z, --zoned print zone model
>>> ZONED zone model
>>> 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
>>
>> It would be nice to have shorter column names, but I do not have any
>> sane suggestion (Z-SIZE or Z-APPEND seems strange).
>
> Hmm, considering we already have DISC-{ALN,GRAN,MAX,ZERO}, how about
> ZONE-{SZ,GRAN,APP,NR,OMAX,AMAX}?
That work for me. One nit though: having the ZONE-NR and ZONE-SZ columns come
first would be nice since these are the 2 most important properties that users
will look at before digging into details of other limits.
I also wonder if we want to add max_zone_append_bytes here... We should only if
attributes such as max_sectors etc are listed too (I have not checked).
>
>> Karel
>>
>> --
>> Karel Zak <kzak@redhat.com>
>> http://karelzak.blogspot.com
>>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] add columns for zoned parameters
2021-08-25 2:12 ` Naohiro Aota
2021-08-25 2:49 ` Damien Le Moal
@ 2021-08-25 10:03 ` Karel Zak
1 sibling, 0 replies; 7+ messages in thread
From: Karel Zak @ 2021-08-25 10:03 UTC (permalink / raw)
To: Naohiro Aota; +Cc: util-linux, Damien Le Moal
On Wed, Aug 25, 2021 at 02:12:27AM +0000, Naohiro Aota wrote:
> > > $ lsblk --help|grep -i zone
> > > -z, --zoned print zone model
> > > ZONED zone model
> > > 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
> >
> > It would be nice to have shorter column names, but I do not have any
> > sane suggestion (Z-SIZE or Z-APPEND seems strange).
>
> Hmm, considering we already have DISC-{ALN,GRAN,MAX,ZERO}, how about
> ZONE-{SZ,GRAN,APP,NR,OMAX,AMAX}?
Sounds good.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-08-25 10:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 1:17 [PATCH 0/2] add columns for zoned parameters Naohiro Aota
2021-08-24 1:17 ` [PATCH 1/2] lsblk: factor out function to read sysfs param as bytes Naohiro Aota
2021-08-24 1:17 ` [PATCH 2/2] lsblk: add columns of zoned parameters Naohiro Aota
2021-08-24 12:47 ` [PATCH 0/2] add columns for " Karel Zak
2021-08-25 2:12 ` Naohiro Aota
2021-08-25 2:49 ` Damien Le Moal
2021-08-25 10:03 ` Karel Zak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.