public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: util-linux@vger.kernel.org
Cc: Milan Broz <mbroz@redhat.com>
Subject: [PATCH] lsblk: Add write-same attribute to topology info
Date: Thu, 20 Dec 2012 12:42:23 +0100	[thread overview]
Message-ID: <1356003743-8013-1-git-send-email-mbroz@redhat.com> (raw)


Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 misc-utils/lsblk.8 |    2 +-
 misc-utils/lsblk.c |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
index 77e5b74..9152062 100644
--- a/misc-utils/lsblk.8
+++ b/misc-utils/lsblk.8
@@ -74,7 +74,7 @@ Use the raw output format. All potentially unsafe characters are hex-escaped
 Print dependencies in inverse order.
 .IP "\fB\-t, \-\-topology\fP"
 Output info about block device topology.
-This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE".
+This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,WRITE_SAME".
 .IP "\fB\-S, \-\-scsi\fP"
 Output info about SCSI devices only. All partitions, slaves and holders devices are ignored.
 .IP "\fB\-V, \-\-version\fP"
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 5a63b6b..8c4bfc0 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -95,6 +95,7 @@ enum {
 	COL_DGRAN,
 	COL_DMAX,
 	COL_DZERO,
+	COL_WSAME,
 	COL_WWN,
 	COL_RAND,
 	COL_PKNAME,
@@ -149,6 +150,7 @@ static struct colinfo infos[] = {
 	[COL_DGRAN]  = { "DISC-GRAN", 6, TT_FL_RIGHT, N_("discard granularity") },
 	[COL_DMAX]   = { "DISC-MAX", 6, TT_FL_RIGHT, N_("discard max bytes") },
 	[COL_DZERO]  = { "DISC-ZERO", 1, TT_FL_RIGHT, N_("discard zeroes data") },
+	[COL_WSAME]  = { "WRITE-SAME", 6, TT_FL_RIGHT, N_("write same max bytes") },
 	[COL_WWN]    = { "WWN",     18, 0, N_("unique storage identifier") },
 	[COL_HCTL]   = { "HCTL", 10, 0, N_("Host:Channel:Target:Lun for SCSI") },
 	[COL_TRANSPORT] = { "TRAN", 6, 0, N_("device transport type") },
@@ -900,6 +902,22 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
 		else
 			tt_line_set_data(ln, col, "0");
 		break;
+	case COL_WSAME:
+		if (lsblk->bytes)
+			p = sysfs_strdup(&cxt->sysfs, "queue/write_same_max_bytes");
+		else {
+			uint64_t x;
+
+			if (sysfs_read_u64(&cxt->sysfs,
+					   "queue/write_same_max_bytes", &x) == 0)
+				p = size_to_human_string(SIZE_SUFFIX_1LETTER, x);
+		}
+		if (p)
+			tt_line_set_data(ln, col, p);
+		else
+			tt_line_set_data(ln, col, "0");
+
+		break;
 	};
 }
 
@@ -1478,6 +1496,7 @@ int main(int argc, char *argv[])
 			columns[ncolumns++] = COL_SCHED;
 			columns[ncolumns++] = COL_RQ_SIZE;
 			columns[ncolumns++] = COL_RA;
+			columns[ncolumns++] = COL_WSAME;
 			break;
 		case 'S':
 			lsblk->nodeps = 1;
-- 
1.7.10.4


             reply	other threads:[~2012-12-20 11:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-20 11:42 Milan Broz [this message]
2013-01-07 17:12 ` [PATCH] lsblk: Add write-same attribute to topology info Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1356003743-8013-1-git-send-email-mbroz@redhat.com \
    --to=mbroz@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox