* [PATCH v3 0/3] add columns for zoned parameters @ 2021-08-30 5:52 Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 1/3] lsblk: factor out function to read sysfs param as bytes Naohiro Aota ` (3 more replies) 0 siblings, 4 replies; 6+ messages in thread From: Naohiro Aota @ 2021-08-30 5:52 UTC (permalink / raw) To: Karel Zak; +Cc: util-linux, Damien.LeMoal, 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-SZ zone size queue/chunk_sectors ZONE-WGRAN zone write granularity queue/zone_write_granularity ZONE-APP zone append max bytes queue/zone_append_max_bytes ZONE-NR number of zones queue/nr_zones ZONE-OMAX maximum number of open zones queue/max_open_zones ZONE-AMAX maximum number of active zones queue/max_active_zones These columns are also added to the "-z" output. Sample output: $ lsblk -z -i NAME ZONED ZONE-SZ ZONE-NR ZONE-AMAX ZONE-OMAX ZONE-APP ZONE-WGRAN sda host-managed 256M 55880 0 128 672K 4K sdb host-managed 256M 55880 0 128 672K 4K zram0 none 0B 0 0 0 0B 0B nvme2n1 none 0B 0 0 0 0B 0B |-nvme2n1p1 none 0B 0 0 0 0B 0B |-nvme2n1p2 none 0B 0 0 0 0B 0B `-nvme2n1p3 none 0B 0 0 0 0B 0B nvme0n1 none 0B 0 0 0 0B 0B nvme1n1 none 0B 0 0 0 0B 0B nvme0n2 host-managed 2G 1844 14 14 4M 4K nvme1n2 host-managed 2G 1844 14 14 4M 4K $ lsblk --help|grep -i zone -z, --zoned print zone related information ZONED zone model ZONE-SZ zone size ZONE-WGRAN zone write granularity ZONE-APP zone append max bytes ZONE-NR number of zones ZONE-OMAX maximum number of open zones ZONE-AMAX maximum number of active zones Naohiro Aota (3): lsblk: factor out function to read sysfs param as bytes lsblk: add columns of zoned parameters lsblk: add zoned columns to "lsblk -z" bash-completion/lsblk | 3 +- misc-utils/lsblk.8.adoc | 2 +- misc-utils/lsblk.c | 104 ++++++++++++++++++++++++++++++---------- 3 files changed, 82 insertions(+), 27 deletions(-) -- 2.33.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/3] lsblk: factor out function to read sysfs param as bytes 2021-08-30 5:52 [PATCH v3 0/3] add columns for zoned parameters Naohiro Aota @ 2021-08-30 5:52 ` Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 2/3] lsblk: add columns of zoned parameters Naohiro Aota ` (2 subsequent siblings) 3 siblings, 0 replies; 6+ messages in thread From: Naohiro Aota @ 2021-08-30 5:52 UTC (permalink / raw) To: Karel Zak; +Cc: util-linux, Damien.LeMoal, Naohiro Aota, Damien Le Moal 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. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- misc-utils/lsblk.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 100eba0779f8..9c41e70adad7 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -708,6 +708,25 @@ 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) +{ + uint64_t x; + + if (lsblk->bytes) { + ul_path_read_string(dev->sysfs, str, path); + if (sortdata) + str2u64(*str, sortdata); + return; + } + + 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 +1052,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 +1061,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] 6+ messages in thread
* [PATCH v3 2/3] lsblk: add columns of zoned parameters 2021-08-30 5:52 [PATCH v3 0/3] add columns for zoned parameters Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 1/3] lsblk: factor out function to read sysfs param as bytes Naohiro Aota @ 2021-08-30 5:52 ` Naohiro Aota 2021-08-30 6:22 ` Damien Le Moal 2021-08-30 5:52 ` [PATCH v3 3/3] lsblk: add zoned columns to "lsblk -z" Naohiro Aota 2021-08-31 8:48 ` [PATCH v3 0/3] add columns for zoned parameters Karel Zak 3 siblings, 1 reply; 6+ messages in thread From: Naohiro Aota @ 2021-08-30 5:52 UTC (permalink / raw) To: Karel Zak; +Cc: util-linux, Damien.LeMoal, Naohiro Aota Several parameters for zoned devices are missing from lsblk's columns. This commit introduces them as following. ZONE-SZ zone size ZONE-WGRAN zone write granularity ZONE-APP zone append max bytes ZONE-NR number of zones ZONE-OMAX maximum number of open zones ZONE-AMAX maximum number of active zones Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- bash-completion/lsblk | 3 ++- misc-utils/lsblk.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/bash-completion/lsblk b/bash-completion/lsblk index 731ef3f4095d..ca0ad39d7345 100644 --- a/bash-completion/lsblk +++ b/bash-completion/lsblk @@ -10,7 +10,8 @@ _lsblk_module() LABEL UUID PTUUID PTTYPE PARTTYPE PARTTYPENAME PARTLABEL PARTUUID PARTFLAGS RA RO RM HOTPLUG MODEL SERIAL SIZE STATE OWNER GROUP MODE ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO - WSAME WWN RAND PKNAME HCTL TRAN SUBSYSTEMS REV VENDOR ZONED DAX + WSAME WWN RAND PKNAME HCTL TRAN SUBSYSTEMS REV VENDOR ZONED ZONE-SZ ZONE-WGRAN + ZONE-APP ZONE-NR ZONE-OMAX ZONE-AMAX DAX " case $prev in diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 9c41e70adad7..807ddcfea631 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -123,6 +123,12 @@ enum { COL_WSAME, COL_WWN, COL_ZONED, + COL_ZONE_SZ, + COL_ZONE_WGRAN, + COL_ZONE_APP, + COL_ZONE_NR, + COL_ZONE_OMAX, + COL_ZONE_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_ZONE_SZ] = { "ZONE-SZ", 9, SCOLS_FL_RIGHT, N_("zone size"), COLTYPE_NUM }, + [COL_ZONE_WGRAN] = { "ZONE-WGRAN", 10, SCOLS_FL_RIGHT, N_("zone write granularity"), COLTYPE_NUM }, + [COL_ZONE_APP] = { "ZONE-APP", 11, SCOLS_FL_RIGHT, N_("zone append max bytes"), COLTYPE_NUM }, + [COL_ZONE_NR] = { "ZONE-NR", 8, SCOLS_FL_RIGHT, N_("number of zones"), COLTYPE_NUM }, + [COL_ZONE_OMAX] = { "ZONE-OMAX", 10, SCOLS_FL_RIGHT, N_("maximum number of open zones"), COLTYPE_NUM }, + [COL_ZONE_AMAX] = { "ZONE-AMAX", 10, SCOLS_FL_RIGHT, N_("maximum number of active zones"), COLTYPE_NUM }, }; struct lsblk *lsblk; /* global handler */ @@ -1068,6 +1080,46 @@ static char *device_get_data( case COL_ZONED: ul_path_read_string(dev->sysfs, &str, "queue/zoned"); break; + case COL_ZONE_SZ: + { + 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_ZONE_WGRAN: + device_read_bytes(dev, "queue/zone_write_granularity", &str, sortdata); + break; + case COL_ZONE_APP: + device_read_bytes(dev, "queue/zone_append_max_bytes", &str, sortdata); + break; + case COL_ZONE_NR: + ul_path_read_string(dev->sysfs, &str, "queue/nr_zones"); + if (sortdata) + str2u64(str, sortdata); + break; + case COL_ZONE_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_ZONE_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] 6+ messages in thread
* Re: [PATCH v3 2/3] lsblk: add columns of zoned parameters 2021-08-30 5:52 ` [PATCH v3 2/3] lsblk: add columns of zoned parameters Naohiro Aota @ 2021-08-30 6:22 ` Damien Le Moal 0 siblings, 0 replies; 6+ messages in thread From: Damien Le Moal @ 2021-08-30 6:22 UTC (permalink / raw) To: Naohiro Aota, Karel Zak; +Cc: util-linux On 2021/08/30 14:53, Naohiro Aota wrote: > Several parameters for zoned devices are missing from lsblk's columns. This > commit introduces them as following. > > ZONE-SZ zone size > ZONE-WGRAN zone write granularity > ZONE-APP zone append max bytes > ZONE-NR number of zones > ZONE-OMAX maximum number of open zones > ZONE-AMAX maximum number of active zones > > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > --- > bash-completion/lsblk | 3 ++- > misc-utils/lsblk.c | 52 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 54 insertions(+), 1 deletion(-) > > diff --git a/bash-completion/lsblk b/bash-completion/lsblk > index 731ef3f4095d..ca0ad39d7345 100644 > --- a/bash-completion/lsblk > +++ b/bash-completion/lsblk > @@ -10,7 +10,8 @@ _lsblk_module() > LABEL UUID PTUUID PTTYPE PARTTYPE PARTTYPENAME PARTLABEL PARTUUID PARTFLAGS RA > RO RM HOTPLUG MODEL SERIAL SIZE STATE OWNER GROUP MODE ALIGNMENT MIN-IO OPT-IO > PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO > - WSAME WWN RAND PKNAME HCTL TRAN SUBSYSTEMS REV VENDOR ZONED DAX > + WSAME WWN RAND PKNAME HCTL TRAN SUBSYSTEMS REV VENDOR ZONED ZONE-SZ ZONE-WGRAN > + ZONE-APP ZONE-NR ZONE-OMAX ZONE-AMAX DAX > " > > case $prev in > diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c > index 9c41e70adad7..807ddcfea631 100644 > --- a/misc-utils/lsblk.c > +++ b/misc-utils/lsblk.c > @@ -123,6 +123,12 @@ enum { > COL_WSAME, > COL_WWN, > COL_ZONED, > + COL_ZONE_SZ, > + COL_ZONE_WGRAN, > + COL_ZONE_APP, > + COL_ZONE_NR, > + COL_ZONE_OMAX, > + COL_ZONE_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_ZONE_SZ] = { "ZONE-SZ", 9, SCOLS_FL_RIGHT, N_("zone size"), COLTYPE_NUM }, > + [COL_ZONE_WGRAN] = { "ZONE-WGRAN", 10, SCOLS_FL_RIGHT, N_("zone write granularity"), COLTYPE_NUM }, > + [COL_ZONE_APP] = { "ZONE-APP", 11, SCOLS_FL_RIGHT, N_("zone append max bytes"), COLTYPE_NUM }, > + [COL_ZONE_NR] = { "ZONE-NR", 8, SCOLS_FL_RIGHT, N_("number of zones"), COLTYPE_NUM }, > + [COL_ZONE_OMAX] = { "ZONE-OMAX", 10, SCOLS_FL_RIGHT, N_("maximum number of open zones"), COLTYPE_NUM }, > + [COL_ZONE_AMAX] = { "ZONE-AMAX", 10, SCOLS_FL_RIGHT, N_("maximum number of active zones"), COLTYPE_NUM }, > }; > > struct lsblk *lsblk; /* global handler */ > @@ -1068,6 +1080,46 @@ static char *device_get_data( > case COL_ZONED: > ul_path_read_string(dev->sysfs, &str, "queue/zoned"); > break; > + case COL_ZONE_SZ: > + { > + 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_ZONE_WGRAN: > + device_read_bytes(dev, "queue/zone_write_granularity", &str, sortdata); > + break; > + case COL_ZONE_APP: > + device_read_bytes(dev, "queue/zone_append_max_bytes", &str, sortdata); > + break; > + case COL_ZONE_NR: > + ul_path_read_string(dev->sysfs, &str, "queue/nr_zones"); > + if (sortdata) > + str2u64(str, sortdata); > + break; > + case COL_ZONE_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_ZONE_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; > Looks good to me. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] lsblk: add zoned columns to "lsblk -z" 2021-08-30 5:52 [PATCH v3 0/3] add columns for zoned parameters Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 1/3] lsblk: factor out function to read sysfs param as bytes Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 2/3] lsblk: add columns of zoned parameters Naohiro Aota @ 2021-08-30 5:52 ` Naohiro Aota 2021-08-31 8:48 ` [PATCH v3 0/3] add columns for zoned parameters Karel Zak 3 siblings, 0 replies; 6+ messages in thread From: Naohiro Aota @ 2021-08-30 5:52 UTC (permalink / raw) To: Karel Zak; +Cc: util-linux, Damien.LeMoal, Naohiro Aota, Damien Le Moal Add zoned columns to the "-z" option as follow. $ lsblk -z -i NAME ZONED ZONE-SZ ZONE-NR ZONE-AMAX ZONE-OMAX ZONE-APP ZONE-WGRAN sda host-managed 256M 55880 0 128 672K 4K sdb host-managed 256M 55880 0 128 672K 4K zram0 none 0B 0 0 0 0B 0B nvme2n1 none 0B 0 0 0 0B 0B |-nvme2n1p1 none 0B 0 0 0 0B 0B |-nvme2n1p2 none 0B 0 0 0 0B 0B `-nvme2n1p3 none 0B 0 0 0 0B 0B nvme0n1 none 0B 0 0 0 0B 0B nvme1n1 none 0B 0 0 0 0B 0B nvme0n2 host-managed 2G 1844 14 14 4M 4K nvme1n2 host-managed 2G 1844 14 14 4M 4K Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- misc-utils/lsblk.8.adoc | 2 +- misc-utils/lsblk.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/misc-utils/lsblk.8.adoc b/misc-utils/lsblk.8.adoc index 7356976403a7..9e68a847ce0c 100644 --- a/misc-utils/lsblk.8.adoc +++ b/misc-utils/lsblk.8.adoc @@ -116,7 +116,7 @@ Specifies output width as a number of characters. The default is the number of t Sort output lines by _column_. This option enables *--list* output format by default. It is possible to use the option *--tree* to force tree-like output and than the tree branches are sorted by the _column_. *-z*, *--zoned*:: -Print the zone model for each device. +Print the zone related information for each device. *--sysroot* _directory_:: Gather data for a Linux instance other than the instance from which the *lsblk* command is issued. The specified directory is the system root of the Linux instance to be inspected. The real device nodes in the target directory can be replaced by text files with udev attributes. diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 807ddcfea631..b4696f5ec5c9 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -1920,7 +1920,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -t, --topology output info about topology\n"), out); fputs(_(" -w, --width <num> specifies output width as number of characters\n"), out); fputs(_(" -x, --sort <column> sort output by <column>\n"), out); - fputs(_(" -z, --zoned print zone model\n"), out); + fputs(_(" -z, --zoned print zone related information\n"), out); fputs(_(" --sysroot <dir> use specified directory as system root\n"), out); fputs(USAGE_SEPARATOR, out); printf(USAGE_HELP_OPTIONS(22)); @@ -2042,6 +2042,12 @@ int main(int argc, char *argv[]) case 'z': add_uniq_column(COL_NAME); add_uniq_column(COL_ZONED); + add_uniq_column(COL_ZONE_SZ); + add_uniq_column(COL_ZONE_NR); + add_uniq_column(COL_ZONE_AMAX); + add_uniq_column(COL_ZONE_OMAX); + add_uniq_column(COL_ZONE_APP); + add_uniq_column(COL_ZONE_WGRAN); break; case 'e': parse_excludes(optarg); -- 2.33.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/3] add columns for zoned parameters 2021-08-30 5:52 [PATCH v3 0/3] add columns for zoned parameters Naohiro Aota ` (2 preceding siblings ...) 2021-08-30 5:52 ` [PATCH v3 3/3] lsblk: add zoned columns to "lsblk -z" Naohiro Aota @ 2021-08-31 8:48 ` Karel Zak 3 siblings, 0 replies; 6+ messages in thread From: Karel Zak @ 2021-08-31 8:48 UTC (permalink / raw) To: Naohiro Aota; +Cc: util-linux, Damien.LeMoal On Mon, Aug 30, 2021 at 02:52:54PM +0900, Naohiro Aota wrote: > Naohiro Aota (3): > lsblk: factor out function to read sysfs param as bytes > lsblk: add columns of zoned parameters > lsblk: add zoned columns to "lsblk -z" > > bash-completion/lsblk | 3 +- > misc-utils/lsblk.8.adoc | 2 +- > misc-utils/lsblk.c | 104 ++++++++++++++++++++++++++++++---------- > 3 files changed, 82 insertions(+), 27 deletions(-) Applied, thanks! Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-31 8:48 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-30 5:52 [PATCH v3 0/3] add columns for zoned parameters Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 1/3] lsblk: factor out function to read sysfs param as bytes Naohiro Aota 2021-08-30 5:52 ` [PATCH v3 2/3] lsblk: add columns of zoned parameters Naohiro Aota 2021-08-30 6:22 ` Damien Le Moal 2021-08-30 5:52 ` [PATCH v3 3/3] lsblk: add zoned columns to "lsblk -z" Naohiro Aota 2021-08-31 8:48 ` [PATCH v3 0/3] add columns for zoned parameters Karel Zak
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).