All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Lukas Czerner <lczerner@redhat.com>, Karel Zak <kzak@redhat.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	device-mapper development <dm-devel@redhat.com>,
	Alasdair G Kergon <agk@redhat.com>,
	sandeen@redhat.com, Mike Snitzer <snitzer@redhat.com>,
	DarkNovaNick@gmail.com, linux-lvm@redhat.com,
	linux-ext4@vger.kernel.org
Subject: Re: [dm-devel] do not disable ext4 discards on first discard failure? [was: Re: dm snapshot: ignore discards issued to the snapshot-origin target]
Date: Wed, 04 May 2011 11:16:05 -0400	[thread overview]
Message-ID: <yq1sjsuzebu.fsf@sermon.lab.mkp.net> (raw)
In-Reply-To: <alpine.LFD.2.00.1105031036090.4250@dhcp-27-109.brq.redhat.com> (Lukas Czerner's message of "Tue, 3 May 2011 10:57:19 +0200 (CEST)")

>>>>> "Lukas" == Lukas Czerner <lczerner@redhat.com> writes:

I got tired of poking around in sysfs to find the discard topology.
Here's a patch against lsblk that adds a -D option to present this
information in a human-readable form:

# lsblk -D
NAME                  DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                          0        0B       0B         0
└─sda1                       0        0B       0B         0
sdb                          0      512B       2G         1
└─sdb1                       0      512B       2G         1


Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
index 38ff48f..d7d7aa8 100644
--- a/misc-utils/lsblk.8
+++ b/misc-utils/lsblk.8
@@ -29,6 +29,8 @@ Print the SIZE column in bytes rather than in human-readable format.
 .IP "\fB\-d, \-\-nodeps\fP"
 Don't print device holders or slaves.  For example "lsblk --nodeps /dev/sda" prints
 information about the sda device only.
+.IP "\fB\-D, \-\-discard\fP"
+Print information about the discard (TRIM, UNMAP) capabilities for each device.
 .IP "\fB\-e, \-\-exclude \fIlist\fP
 Exclude the devices specified by a comma-separated \fIlist\fR of major device numbers.
 Note that RAM disks (major=1) are excluded by default.
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 38326d0..671e690 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -77,6 +77,10 @@ enum {
 	COL_ROTA,
 	COL_SCHED,
 	COL_TYPE,
+	COL_DALIGN,
+	COL_DGRAN,
+	COL_DMAX,
+	COL_DZERO,
 
 	__NCOLUMNS
 };
@@ -112,8 +116,11 @@ static struct colinfo infos[__NCOLUMNS] = {
 	[COL_PHYSEC] = { "PHY-SEC", 7, TT_FL_RIGHT, N_("physical sector size") },
 	[COL_LOGSEC] = { "LOG-SEC", 7, TT_FL_RIGHT, N_("logical sector size") },
 	[COL_SCHED]  = { "SCHED",   0.1, 0, N_("I/O scheduler name") },
-	[COL_TYPE]   = { "TYPE",    4, 0, N_("device type") }
-
+	[COL_TYPE]   = { "TYPE",    4, 0, N_("device type") },
+	[COL_DALIGN] = { "DISC-ALN", 6, TT_FL_RIGHT, N_("discard alignment offset") },
+	[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") },
 };
 
 struct lsblk {
@@ -702,6 +709,33 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
 		if (p)
 			tt_line_set_data(ln, col, p);
 		break;
+	case COL_DALIGN:
+		p = sysfs_strdup(cxt, "discard_alignment");
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
+	case COL_DGRAN:
+		p = sysfs_strdup(cxt, "queue/discard_granularity");
+		if (!lsblk->bytes)
+			p = size_to_human_string(atoi(p));
+
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
+	case COL_DMAX:
+		p = sysfs_strdup(cxt, "queue/discard_max_bytes");
+
+		if (!lsblk->bytes)
+			p = size_to_human_string(atoi(p));
+
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
+	case COL_DZERO:
+		p = sysfs_strdup(cxt, "queue/discard_zeroes_data");
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
 	};
 }
 
@@ -930,6 +964,7 @@ static void __attribute__((__noreturn__)) help(FILE *out)
 		" -a, --all            print all devices\n"
 		" -b, --bytes          print SIZE in bytes rather than in human readable format\n"
 		" -d, --nodeps         don't print slaves or holders\n"
+		" -D, --discard        print discard capabilities\n"
 		" -e, --exclude <list> exclude devices by major number (default: RAM disks)\n"
 		" -f, --fs             output info about filesystems\n"
 		" -h, --help           usage information (this)\n"
@@ -967,6 +1002,7 @@ int main(int argc, char *argv[])
 		{ "all",	0, 0, 'a' },
 		{ "bytes",      0, 0, 'b' },
 		{ "nodeps",     0, 0, 'd' },
+		{ "discard",    0, 0, 'D' },
 		{ "help",	0, 0, 'h' },
 		{ "output",     1, 0, 'o' },
 		{ "perms",      0, 0, 'm' },
@@ -987,7 +1023,7 @@ int main(int argc, char *argv[])
 	lsblk = &_ls;
 	memset(lsblk, 0, sizeof(*lsblk));
 
-	while((c = getopt_long(argc, argv, "abde:fhlnmo:irt", longopts, NULL)) != -1) {
+	while((c = getopt_long(argc, argv, "abdDe:fhlnmo:irt", longopts, NULL)) != -1) {
 		switch(c) {
 		case 'a':
 			lsblk->all_devices = 1;
@@ -998,6 +1034,13 @@ int main(int argc, char *argv[])
 		case 'd':
 			lsblk->nodeps = 1;
 			break;
+		case 'D':
+			columns[ncolumns++] = COL_NAME;
+			columns[ncolumns++] = COL_DALIGN;
+			columns[ncolumns++] = COL_DGRAN;
+			columns[ncolumns++] = COL_DMAX;
+			columns[ncolumns++] = COL_DZERO;
+			break;
 		case 'e':
 			parse_excludes(optarg);
 			break;
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Lukas Czerner <lczerner@redhat.com>, Karel Zak <kzak@redhat.com>
Cc: sandeen@redhat.com,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Mike Snitzer <snitzer@redhat.com>,
	Christoph Hellwig <hch@infradead.org>,
	device-mapper development <dm-devel@redhat.com>,
	DarkNovaNick@gmail.com, linux-lvm@redhat.com,
	linux-ext4@vger.kernel.org, Alasdair G Kergon <agk@redhat.com>
Subject: Re: [linux-lvm] [dm-devel] do not disable ext4 discards on first discard failure? [was: Re: dm snapshot: ignore discards issued to the snapshot-origin target]
Date: Wed, 04 May 2011 11:16:05 -0400	[thread overview]
Message-ID: <yq1sjsuzebu.fsf@sermon.lab.mkp.net> (raw)
In-Reply-To: <alpine.LFD.2.00.1105031036090.4250@dhcp-27-109.brq.redhat.com> (Lukas Czerner's message of "Tue, 3 May 2011 10:57:19 +0200 (CEST)")

>>>>> "Lukas" == Lukas Czerner <lczerner@redhat.com> writes:

I got tired of poking around in sysfs to find the discard topology.
Here's a patch against lsblk that adds a -D option to present this
information in a human-readable form:

# lsblk -D
NAME                  DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                          0        0B       0B         0
└─sda1                       0        0B       0B         0
sdb                          0      512B       2G         1
└─sdb1                       0      512B       2G         1


Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
index 38ff48f..d7d7aa8 100644
--- a/misc-utils/lsblk.8
+++ b/misc-utils/lsblk.8
@@ -29,6 +29,8 @@ Print the SIZE column in bytes rather than in human-readable format.
 .IP "\fB\-d, \-\-nodeps\fP"
 Don't print device holders or slaves.  For example "lsblk --nodeps /dev/sda" prints
 information about the sda device only.
+.IP "\fB\-D, \-\-discard\fP"
+Print information about the discard (TRIM, UNMAP) capabilities for each device.
 .IP "\fB\-e, \-\-exclude \fIlist\fP
 Exclude the devices specified by a comma-separated \fIlist\fR of major device numbers.
 Note that RAM disks (major=1) are excluded by default.
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 38326d0..671e690 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -77,6 +77,10 @@ enum {
 	COL_ROTA,
 	COL_SCHED,
 	COL_TYPE,
+	COL_DALIGN,
+	COL_DGRAN,
+	COL_DMAX,
+	COL_DZERO,
 
 	__NCOLUMNS
 };
@@ -112,8 +116,11 @@ static struct colinfo infos[__NCOLUMNS] = {
 	[COL_PHYSEC] = { "PHY-SEC", 7, TT_FL_RIGHT, N_("physical sector size") },
 	[COL_LOGSEC] = { "LOG-SEC", 7, TT_FL_RIGHT, N_("logical sector size") },
 	[COL_SCHED]  = { "SCHED",   0.1, 0, N_("I/O scheduler name") },
-	[COL_TYPE]   = { "TYPE",    4, 0, N_("device type") }
-
+	[COL_TYPE]   = { "TYPE",    4, 0, N_("device type") },
+	[COL_DALIGN] = { "DISC-ALN", 6, TT_FL_RIGHT, N_("discard alignment offset") },
+	[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") },
 };
 
 struct lsblk {
@@ -702,6 +709,33 @@ static void set_tt_data(struct blkdev_cxt *cxt, int col, int id, struct tt_line
 		if (p)
 			tt_line_set_data(ln, col, p);
 		break;
+	case COL_DALIGN:
+		p = sysfs_strdup(cxt, "discard_alignment");
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
+	case COL_DGRAN:
+		p = sysfs_strdup(cxt, "queue/discard_granularity");
+		if (!lsblk->bytes)
+			p = size_to_human_string(atoi(p));
+
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
+	case COL_DMAX:
+		p = sysfs_strdup(cxt, "queue/discard_max_bytes");
+
+		if (!lsblk->bytes)
+			p = size_to_human_string(atoi(p));
+
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
+	case COL_DZERO:
+		p = sysfs_strdup(cxt, "queue/discard_zeroes_data");
+		if (p)
+			tt_line_set_data(ln, col, p);
+		break;
 	};
 }
 
@@ -930,6 +964,7 @@ static void __attribute__((__noreturn__)) help(FILE *out)
 		" -a, --all            print all devices\n"
 		" -b, --bytes          print SIZE in bytes rather than in human readable format\n"
 		" -d, --nodeps         don't print slaves or holders\n"
+		" -D, --discard        print discard capabilities\n"
 		" -e, --exclude <list> exclude devices by major number (default: RAM disks)\n"
 		" -f, --fs             output info about filesystems\n"
 		" -h, --help           usage information (this)\n"
@@ -967,6 +1002,7 @@ int main(int argc, char *argv[])
 		{ "all",	0, 0, 'a' },
 		{ "bytes",      0, 0, 'b' },
 		{ "nodeps",     0, 0, 'd' },
+		{ "discard",    0, 0, 'D' },
 		{ "help",	0, 0, 'h' },
 		{ "output",     1, 0, 'o' },
 		{ "perms",      0, 0, 'm' },
@@ -987,7 +1023,7 @@ int main(int argc, char *argv[])
 	lsblk = &_ls;
 	memset(lsblk, 0, sizeof(*lsblk));
 
-	while((c = getopt_long(argc, argv, "abde:fhlnmo:irt", longopts, NULL)) != -1) {
+	while((c = getopt_long(argc, argv, "abdDe:fhlnmo:irt", longopts, NULL)) != -1) {
 		switch(c) {
 		case 'a':
 			lsblk->all_devices = 1;
@@ -998,6 +1034,13 @@ int main(int argc, char *argv[])
 		case 'd':
 			lsblk->nodeps = 1;
 			break;
+		case 'D':
+			columns[ncolumns++] = COL_NAME;
+			columns[ncolumns++] = COL_DALIGN;
+			columns[ncolumns++] = COL_DGRAN;
+			columns[ncolumns++] = COL_DMAX;
+			columns[ncolumns++] = COL_DZERO;
+			break;
 		case 'e':
 			parse_excludes(optarg);
 			break;

  parent reply	other threads:[~2011-05-04 15:16 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 14:59 [linux-lvm] Testing TRIM with LVM DarkNovaNick
2011-04-12 23:47 ` Mike Snitzer
2011-04-13  1:47   ` DarkNovaNick
2011-04-13  8:41     ` Zdenek Kabelac
2011-04-13 15:38       ` DarkNovaNick
2011-04-13 22:40     ` [PATCH] dm snapshot: add discard support to the snapshot-origin target [was: Re: Testing TRIM with LVM] Mike Snitzer
2011-04-13 22:40       ` [linux-lvm] " Mike Snitzer
2011-04-13 23:48       ` Mike Snitzer
2011-04-13 23:48         ` [linux-lvm] " Mike Snitzer
2011-04-26 17:32         ` Mike Snitzer
2011-04-26 17:32           ` [linux-lvm] " Mike Snitzer
2011-04-28  0:19           ` [PATCH] dm snapshot: ignore discards issued to the snapshot-origin target Mike Snitzer
2011-04-28  0:19             ` [linux-lvm] " Mike Snitzer
2011-04-28  7:53             ` Christoph Hellwig
2011-04-28  7:53               ` [linux-lvm] [dm-devel] " Christoph Hellwig
2011-04-28 20:59               ` do not disable ext4 discards on first discard failure? [was: Re: dm snapshot: ignore discards issued to the snapshot-origin target] Mike Snitzer
2011-04-28 20:59                 ` [linux-lvm] " Mike Snitzer
2011-04-28 21:28                 ` Eric Sandeen
2011-04-28 21:28                   ` [linux-lvm] " Eric Sandeen
2011-04-28 22:59                   ` Alasdair G Kergon
2011-04-28 22:59                     ` Alasdair G Kergon
2011-04-28 23:01                     ` Eric Sandeen
2011-04-28 23:01                       ` Eric Sandeen
2011-04-28 23:11                       ` Alasdair G Kergon
2011-04-28 23:11                         ` Alasdair G Kergon
2011-04-29  1:12                 ` Andreas Dilger
2011-04-29  1:12                   ` [linux-lvm] " Andreas Dilger
2011-04-29 13:55                   ` Mike Snitzer
2011-04-29 13:55                     ` [linux-lvm] " Mike Snitzer
2011-04-29  9:30                 ` Lukas Czerner
2011-04-29  9:30                   ` [linux-lvm] " Lukas Czerner
2011-04-29 12:24                   ` [dm-devel] " Alasdair G Kergon
2011-04-29 12:24                     ` [linux-lvm] " Alasdair G Kergon
2011-04-29 12:29                     ` Christoph Hellwig
2011-04-29 12:29                       ` [linux-lvm] " Christoph Hellwig
2011-04-29 14:28                       ` Eric Sandeen
2011-04-29 14:28                         ` [linux-lvm] " Eric Sandeen
2011-04-29 15:13                         ` Ray Morris
2011-04-29 15:13                           ` Ray Morris
2011-05-04 16:33                         ` Ted Ts'o
2011-05-04 16:33                           ` [linux-lvm] " Ted Ts'o
2011-05-04 16:51                           ` Eric Sandeen
2011-05-04 16:57                             ` Lukas Czerner
2011-05-04 17:02                           ` Lukas Czerner
2011-05-04 17:02                             ` [linux-lvm] " Lukas Czerner
2011-05-02  7:16                     ` Lukas Czerner
2011-05-02  7:16                       ` [linux-lvm] " Lukas Czerner
2011-05-02  8:13                       ` Alasdair G Kergon
2011-05-02  8:13                         ` [linux-lvm] " Alasdair G Kergon
2011-05-02  8:19                         ` Christoph Hellwig
2011-05-02  8:19                           ` [linux-lvm] " Christoph Hellwig
2011-05-02 10:24                           ` Lukas Czerner
2011-05-02 10:24                             ` [linux-lvm] " Lukas Czerner
2011-05-02 12:48                             ` Mike Snitzer
2011-05-02 12:48                               ` [linux-lvm] " Mike Snitzer
2011-05-02 13:05                               ` Lukas Czerner
2011-05-02 13:05                                 ` [linux-lvm] " Lukas Czerner
2011-05-02 14:47                                 ` Eric Sandeen
2011-05-02 14:47                                   ` [linux-lvm] " Eric Sandeen
2011-05-02 14:48                                   ` Christoph Hellwig
2011-05-02 14:48                                     ` [linux-lvm] " Christoph Hellwig
2011-05-02 14:58                                   ` Lukas Czerner
2011-05-02 14:58                                     ` [linux-lvm] " Lukas Czerner
2011-05-02 13:48                             ` [dm-devel] " Martin K. Petersen
2011-05-02 13:48                               ` [linux-lvm] " Martin K. Petersen
2011-05-02 14:20                             ` Martin K. Petersen
2011-05-02 14:20                               ` [linux-lvm] [dm-devel] " Martin K. Petersen
2011-05-02 14:39                               ` Lukas Czerner
2011-05-02 14:39                                 ` [linux-lvm] " Lukas Czerner
2011-05-02 14:50                                 ` Martin K. Petersen
2011-05-02 14:50                                   ` [linux-lvm] " Martin K. Petersen
2011-05-02 14:58                                 ` Mike Snitzer
2011-05-02 14:58                                   ` [linux-lvm] " Mike Snitzer
2011-05-02 16:58                                 ` [dm-devel] " Martin K. Petersen
2011-05-02 16:58                                   ` [linux-lvm] " Martin K. Petersen
2011-05-03  8:57                                   ` Lukas Czerner
2011-05-03  8:57                                     ` [linux-lvm] " Lukas Czerner
2011-05-04 15:10                                     ` Martin K. Petersen
2011-05-04 15:10                                       ` [linux-lvm] " Martin K. Petersen
2011-05-04 16:02                                       ` Mike Snitzer
2011-05-04 16:02                                         ` [linux-lvm] " Mike Snitzer
2011-05-04 16:50                                         ` Martin K. Petersen
2011-05-04 16:50                                           ` [linux-lvm] " Martin K. Petersen
2011-05-04 18:03                                           ` Mike Snitzer
2011-05-04 18:03                                             ` [linux-lvm] " Mike Snitzer
2011-05-04 17:10                                       ` [dm-devel] " Lukas Czerner
2011-05-04 17:10                                         ` [linux-lvm] " Lukas Czerner
2011-05-04 17:32                                         ` Martin K. Petersen
2011-05-04 17:32                                           ` [linux-lvm] " Martin K. Petersen
2011-05-04 17:35                                           ` Lukas Czerner
2011-05-04 17:35                                             ` [linux-lvm] " Lukas Czerner
2011-05-18 12:16                                       ` Mike Snitzer
2011-05-18 12:16                                         ` [linux-lvm] " Mike Snitzer
2011-05-18 12:52                                         ` Mike Snitzer
2011-05-18 12:52                                           ` [linux-lvm] " Mike Snitzer
2011-05-04 15:16                                     ` Martin K. Petersen [this message]
2011-05-04 15:16                                       ` [linux-lvm] [dm-devel] " Martin K. Petersen
2011-05-04 16:12                                       ` Lukas Czerner
2011-05-04 16:12                                         ` [linux-lvm] " Lukas Czerner
2011-05-05  8:33                                       ` Karel Zak
2011-05-05  8:33                                         ` [linux-lvm] " Karel Zak
2011-05-05 10:48                                         ` Lukas Czerner
2011-05-05 10:48                                           ` [linux-lvm] " Lukas Czerner
2011-04-14 15:31       ` [linux-lvm] [PATCH] dm snapshot: add discard support to the snapshot-origin target [was: Re: Testing TRIM wi DarkNovaNick

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=yq1sjsuzebu.fsf@sermon.lab.mkp.net \
    --to=martin.petersen@oracle.com \
    --cc=DarkNovaNick@gmail.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=kzak@redhat.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-lvm@redhat.com \
    --cc=sandeen@redhat.com \
    --cc=snitzer@redhat.com \
    /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 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.