linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sys/block: Add discard_support entry
@ 2011-05-02 11:25 Lukas Czerner
  2011-05-02 13:43 ` Martin K. Petersen
  2011-05-02 17:36 ` Greg KH
  0 siblings, 2 replies; 9+ messages in thread
From: Lukas Czerner @ 2011-05-02 11:25 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Lukas Czerner, Jens Axboe, Jeff Moyer

Currently there is no convenient way how to get the information from
userspace whether or not the block device supports discard other
than try to call BLKDISCARD ioctl and check the result, which is not
really good way to do it.

We already have BLKDISCARDZEROES ioctl and
/sys/block/sda/queue/discard_zeroes_data to tell whether  subsequent
reads after discard returns all zeroes. This commit adds at least sysfs
interface /sys/block/sda/queue/discard_support to tell whether device
support discard.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Cc: Jens Axboe <jaxboe@fusionio.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
---
 block/blk-sysfs.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index bd23631..96f1cca 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -160,6 +160,11 @@ static ssize_t queue_discard_zeroes_data_show(struct request_queue *q, char *pag
 	return queue_var_show(queue_discard_zeroes_data(q), page);
 }
 
+static ssize_t queue_discard_support_show(struct request_queue *q, char *page)
+{
+	return queue_var_show(blk_queue_discard(q), page);
+}
+
 static ssize_t
 queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
 {
@@ -349,6 +354,11 @@ static struct queue_sysfs_entry queue_discard_zeroes_data_entry = {
 	.show = queue_discard_zeroes_data_show,
 };
 
+static struct queue_sysfs_entry queue_discard_support_entry = {
+	.attr = {.name = "discard_support", .mode = S_IRUGO },
+	.show = queue_discard_support_show,
+};
+
 static struct queue_sysfs_entry queue_nonrot_entry = {
 	.attr = {.name = "rotational", .mode = S_IRUGO | S_IWUSR },
 	.show = queue_show_nonrot,
@@ -396,6 +406,7 @@ static struct attribute *default_attrs[] = {
 	&queue_discard_granularity_entry.attr,
 	&queue_discard_max_entry.attr,
 	&queue_discard_zeroes_data_entry.attr,
+	&queue_discard_support_entry.attr,
 	&queue_nonrot_entry.attr,
 	&queue_nomerges_entry.attr,
 	&queue_rq_affinity_entry.attr,
-- 
1.7.4.4


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

end of thread, other threads:[~2011-05-03 11:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 11:25 [PATCH] sys/block: Add discard_support entry Lukas Czerner
2011-05-02 13:43 ` Martin K. Petersen
2011-05-02 13:58   ` Lukas Czerner
2011-05-02 14:18     ` Martin K. Petersen
2011-05-02 14:46       ` Lukas Czerner
2011-05-02 15:18         ` Martin K. Petersen
2011-05-03 11:33           ` Lukas Czerner
2011-05-02 17:36 ` Greg KH
2011-05-03 11:36   ` Lukas Czerner

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).