From: Milan Broz Date: Thu, 20 Dec 2012 11:42:23 +0000 (+0100) Subject: lsblk: Add write-same attribute to topology info X-Git-Tag: v2.23-rc1~383 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2adb1a44c213c151ca4c7a7e4fb13276ecd74973;p=thirdparty%2Futil-linux.git lsblk: Add write-same attribute to topology info Signed-off-by: Milan Broz Signed-off-by: Karel Zak --- diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8 index 77e5b74707..3a9c2d4142 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,WSAME". .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 5a63b6b814..8ee69748f1 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, @@ -126,7 +127,7 @@ static struct colinfo infos[] = { [COL_PARTLABEL] = { "PARTLABEL", 0.1, 0, N_("partition LABEL") }, [COL_PARTUUID] = { "PARTUUID", 36, 0, N_("partition UUID") }, - [COL_RA] = { "RA", 4, TT_FL_RIGHT, N_("read-ahead of the device") }, + [COL_RA] = { "RA", 3, TT_FL_RIGHT, N_("read-ahead of the device") }, [COL_RO] = { "RO", 1, TT_FL_RIGHT, N_("read-only device") }, [COL_RM] = { "RM", 1, TT_FL_RIGHT, N_("removable device") }, [COL_ROTA] = { "ROTA", 1, TT_FL_RIGHT, N_("rotational device") }, @@ -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] = { "WSAME", 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,18 @@ 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); + } + tt_line_set_data(ln, col, p ? p : "0"); + break; }; } @@ -1478,6 +1492,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;