All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blkzone: Fix zone condition strings handling
@ 2017-04-12  9:20 Damien Le Moal
  2017-04-18  9:34 ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2017-04-12  9:20 UTC (permalink / raw)
  To: util-linux, Karel Zak, Benno Schulenberg; +Cc: Bart Van Assche, Damien Le Moal

Fixed the condition strings for implicit open and explicit open to
match the man page defined strings ("oi" and "oe"). Also while at it,
correct the condition_str array entries adding the reserved "xC" case
so that the read_only, full and offline conditions match the condition
codes. This increases the array size to 16, so also fix the condition
code masking when displaying the result.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 sys-utils/blkzone.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c
index 1457225..7713ff3 100644
--- a/sys-utils/blkzone.c
+++ b/sys-utils/blkzone.c
@@ -151,10 +151,10 @@ static const char *type_text[] = {
 static const char *condition_str[] = {
 	"nw", /* Not write pointer */
 	"em", /* Empty */
-	"io", /* Implicitly opened */
-	"eo", /* Explicitly opened */
+	"oi", /* Implicitly opened */
+	"oe", /* Explicitly opened */
 	"cl", /* Closed */
-	"x5", "x6", "x7", "x8", "x9", "xA", "xB", /* xN: reserved */
+	"x5", "x6", "x7", "x8", "x9", "xA", "xB", "xC", /* xN: reserved */
 	"ro", /* Read only */
 	"fu", /* Full */
 	"of"  /* Offline */
@@ -220,7 +220,7 @@ static int blkzone_report(struct blkzone_control *ctl)
 			 	" reset:%u non-seq:%u, zcond:%2u(%s) [type: %u(%s)]\n"),
 				start, len, (type == 0x1) ? 0 : wp - start,
 				entry->reset, entry->non_seq,
-				cond, condition_str[cond & ARRAY_SIZE(condition_str)],
+				cond, condition_str[cond & (ARRAY_SIZE(condition_str) - 1)],
 				type, type_text[type]);
 
 			nr_zones--;
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blkzone: Fix zone condition strings handling
  2017-04-12  9:20 [PATCH] blkzone: Fix zone condition strings handling Damien Le Moal
@ 2017-04-18  9:34 ` Karel Zak
  2017-04-18 10:59   ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2017-04-18  9:34 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: util-linux, Benno Schulenberg, Bart Van Assche

On Wed, Apr 12, 2017 at 06:20:32PM +0900, Damien Le Moal wrote:
> Fixed the condition strings for implicit open and explicit open to
> match the man page defined strings ("oi" and "oe"). Also while at it,
> correct the condition_str array entries adding the reserved "xC" case
> so that the read_only, full and offline conditions match the condition
> codes. This increases the array size to 16, so also fix the condition
> code masking when displaying the result.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  sys-utils/blkzone.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

Damien, what about to add ZONED column to the lsblk(8) command (also
from util-linux)? 

It would be nice to have zone model there. All lsblk is based on /sys,
so add the string from /sys/block/<disk>/queue/zoned should be easy
(just add COL_ZONED with sysfs_strdup() to set_scols_data()).

 lsblk -o+ZONED

will do all the magic for end users. Can you try it? I have no way to
test it.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blkzone: Fix zone condition strings handling
  2017-04-18  9:34 ` Karel Zak
@ 2017-04-18 10:59   ` Damien Le Moal
  0 siblings, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2017-04-18 10:59 UTC (permalink / raw)
  To: kzak; +Cc: Bart Van Assche, util-linux, bensberg

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

On Tue, 2017-04-18 at 11:34 +0200, Karel Zak wrote:
> On Wed, Apr 12, 2017 at 06:20:32PM +0900, Damien Le Moal wrote:
> > Fixed the condition strings for implicit open and explicit open to
> > match the man page defined strings ("oi" and "oe"). Also while at it,
> > correct the condition_str array entries adding the reserved "xC" case
> > so that the read_only, full and offline conditions match the condition
> > codes. This increases the array size to 16, so also fix the condition
> > code masking when displaying the result.
> > 
> > Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> > ---
> >  sys-utils/blkzone.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Applied, thanks.
> 
> Damien, what about to add ZONED column to the lsblk(8) command (also
> from util-linux)? 
> 
> It would be nice to have zone model there. All lsblk is based on /sys,
> so add the string from /sys/block/<disk>/queue/zoned should be easy
> (just add COL_ZONED with sysfs_strdup() to set_scols_data()).
> 
>  lsblk -o+ZONED
> 
> will do all the magic for end users. Can you try it? I have no way to
> test it.

Very good idea. Patch attached.
(Sorry for not being able to send that the usual way. I am having problem with
office365 account and git send-email)

Best regards.

-- 
Damien Le Moal
Western Digital

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lsblk-add-ZONED-column.patch --]
[-- Type: text/x-patch; name="0001-lsblk-add-ZONED-column.patch", Size: 4239 bytes --]

From b3768342e0ffd18d843650125be29117c280c724 Mon Sep 17 00:00:00 2001
From: Damien Le Moal <damien.lemoal@wdc.com>
Date: Tue, 18 Apr 2017 19:37:58 +0900
Subject: [PATCH 1/1] lsblk: add ZONED column
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add the column "ZONED" to the output to display a block device zone
model.

Example output:

> lsblk -o+ZONED
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT ZONED
sda      8:0    0 111.8G  0 disk            none
├─sda1   8:1    0   500M  0 part /boot      none
├─sda2   8:2    0  87.3G  0 part /          none
└─sda3   8:3    0    24G  0 part [SWAP]     none
sdb      8:16   0  12.8T  0 disk            host-managed
sdc      8:32   0   5.5T  0 disk            host-managed

or:

> lsblk --zone
NAME   ZONED
sda    none
├─sda1 none
├─sda2 none
└─sda3 none
sdb    host-managed
sdc    host-managed

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 misc-utils/lsblk.8 |  3 +++
 misc-utils/lsblk.c | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
index ee1d873..d9fc1c0 100644
--- a/misc-utils/lsblk.8
+++ b/misc-utils/lsblk.8
@@ -49,6 +49,9 @@ Print the SIZE column in bytes rather than in a human-readable format.
 .BR \-D , " \-\-discard"
 Print information about the discarding capabilities (TRIM, UNMAP) for each device.
 .TP
+.BR \-z , " \-\-zoned"
+Print the zone model for each device.
+.TP
 .BR \-d , " \-\-nodeps"
 Do not print holder devices or slaves.  For example, \fBlsblk --nodeps /dev/sda\fR prints
 information about the sda device only.
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 4742a4d..23bfc46 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -124,7 +124,8 @@ enum {
 	COL_TRANSPORT,
 	COL_SUBSYS,
 	COL_REV,
-	COL_VENDOR
+	COL_VENDOR,
+	COL_ZONED,
 };
 
 /* basic table settings */
@@ -200,6 +201,7 @@ static struct colinfo infos[] = {
 	[COL_SUBSYS] = { "SUBSYSTEMS", 0.1, SCOLS_FL_NOEXTREMES, N_("de-duplicated chain of subsystems") },
 	[COL_REV]    = { "REV",   4, SCOLS_FL_RIGHT, N_("device revision") },
 	[COL_VENDOR] = { "VENDOR", 0.1, SCOLS_FL_TRUNC, N_("device vendor") },
+	[COL_ZONED]  = { "ZONED", 0.3, 0, N_("zone model") },
 };
 
 struct lsblk {
@@ -1148,6 +1150,9 @@ static void set_scols_data(struct blkdev_cxt *cxt, int col, int id, struct libsc
 		if (!str)
 			str = xstrdup("0");
 		break;
+	case COL_ZONED:
+		str = sysfs_strdup(&cxt->sysfs, "queue/zoned");
+		break;
 	};
 
 	if (str)
@@ -1626,6 +1631,7 @@ static void __attribute__((__noreturn__)) help(FILE *out)
 	fputs(_(" -b, --bytes          print SIZE in bytes rather than in human readable format\n"), out);
 	fputs(_(" -d, --nodeps         don't print slaves or holders\n"), out);
 	fputs(_(" -D, --discard        print discard capabilities\n"), out);
+	fputs(_(" -z, --zone           print zone model\n"), out);
 	fputs(_(" -e, --exclude <list> exclude devices by major number (default: RAM disks)\n"), out);
 	fputs(_(" -f, --fs             output info about filesystems\n"), out);
 	fputs(_(" -i, --ascii          use ascii characters only\n"), out);
@@ -1676,6 +1682,7 @@ int main(int argc, char *argv[])
 		{ "bytes",      no_argument,       NULL, 'b' },
 		{ "nodeps",     no_argument,       NULL, 'd' },
 		{ "discard",    no_argument,       NULL, 'D' },
+		{ "zoned",      no_argument,       NULL, 'z' },
 		{ "help",	no_argument,       NULL, 'h' },
 		{ "json",       no_argument,       NULL, 'J' },
 		{ "output",     required_argument, NULL, 'o' },
@@ -1721,7 +1728,7 @@ int main(int argc, char *argv[])
 	lsblk_init_debug();
 
 	while((c = getopt_long(argc, argv,
-			       "abdDe:fhJlnmo:OpPiI:rstVSx:", longopts, NULL)) != -1) {
+			       "abdDze:fhJlnmo:OpPiI:rstVSx:", longopts, NULL)) != -1) {
 
 		err_exclusive_options(c, longopts, excl, excl_st);
 
@@ -1742,6 +1749,10 @@ int main(int argc, char *argv[])
 			add_column(columns, ncolumns++, COL_DMAX);
 			add_column(columns, ncolumns++, COL_DZERO);
 			break;
+		case 'z':
+			add_column(columns, ncolumns++, COL_NAME);
+			add_column(columns, ncolumns++, COL_ZONED);
+			break;
 		case 'e':
 			parse_excludes(optarg);
 			break;
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-18 10:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12  9:20 [PATCH] blkzone: Fix zone condition strings handling Damien Le Moal
2017-04-18  9:34 ` Karel Zak
2017-04-18 10:59   ` Damien Le Moal

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.