All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] block: add io timeout to sysfs
@ 2018-11-28 16:04 Weiping Zhang
  2018-11-28 16:08 ` Jens Axboe
  2018-11-29 16:01 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Weiping Zhang @ 2018-11-28 16:04 UTC (permalink / raw)
  To: axboe; +Cc: linux-block

Give a interface to adjust io timeout(ms) by device.

Signed-off-by: Weiping Zhang <zhangweiping@didiglobal.com>
---

Changes since v2:
* use msecs_to_jiffies and jiffies_to_msecs

Changes since v1:
* make sure timeout > 0

 block/blk-sysfs.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 80eef48fddc8..9f0cb370b39b 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -417,6 +417,26 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
 	return ret;
 }
 
+static ssize_t queue_io_timeout_show(struct request_queue *q, char *page)
+{
+	return sprintf(page, "%u\n", jiffies_to_msecs(q->rq_timeout));
+}
+
+static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
+				  size_t count)
+{
+	unsigned int val;
+	int err;
+
+	err = kstrtou32(page, 10, &val);
+	if (err || val == 0)
+		return -EINVAL;
+
+	blk_queue_rq_timeout(q, msecs_to_jiffies(val));
+
+	return count;
+}
+
 static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
 {
 	if (!wbt_rq_qos(q))
@@ -685,6 +705,12 @@ static struct queue_sysfs_entry queue_dax_entry = {
 	.show = queue_dax_show,
 };
 
+static struct queue_sysfs_entry queue_io_timeout_entry = {
+	.attr = {.name = "io_timeout", .mode = 0644 },
+	.show = queue_io_timeout_show,
+	.store = queue_io_timeout_store,
+};
+
 static struct queue_sysfs_entry queue_wb_lat_entry = {
 	.attr = {.name = "wbt_lat_usec", .mode = 0644 },
 	.show = queue_wb_lat_show,
@@ -734,6 +760,7 @@ static struct attribute *default_attrs[] = {
 	&queue_dax_entry.attr,
 	&queue_wb_lat_entry.attr,
 	&queue_poll_delay_entry.attr,
+	&queue_io_timeout_entry.attr,
 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW
 	&throtl_sample_time_entry.attr,
 #endif
-- 
2.14.1


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

* Re: [PATCH v3] block: add io timeout to sysfs
  2018-11-28 16:04 [PATCH v3] block: add io timeout to sysfs Weiping Zhang
@ 2018-11-28 16:08 ` Jens Axboe
  2018-11-29 16:01 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-11-28 16:08 UTC (permalink / raw)
  To: linux-block

On 11/28/18 9:04 AM, Weiping Zhang wrote:
> Give a interface to adjust io timeout(ms) by device.

Looks good, applied.

-- 
Jens Axboe


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

* Re: [PATCH v3] block: add io timeout to sysfs
  2018-11-28 16:04 [PATCH v3] block: add io timeout to sysfs Weiping Zhang
  2018-11-28 16:08 ` Jens Axboe
@ 2018-11-29 16:01 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-11-29 16:01 UTC (permalink / raw)
  To: axboe, linux-block

I think we need a check for the presence of a timeout method and
only show this attribute if the driver actually supports block level
timeouts.

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

end of thread, other threads:[~2018-11-29 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28 16:04 [PATCH v3] block: add io timeout to sysfs Weiping Zhang
2018-11-28 16:08 ` Jens Axboe
2018-11-29 16:01 ` Christoph Hellwig

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.