Skip to content

Commit 65cd1d1

Browse files
Weiping Zhangaxboe
authored andcommitted
block: add io timeout to sysfs
Give a interface to adjust io timeout(ms) by device. Signed-off-by: Weiping Zhang <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 94a2c3a commit 65cd1d1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

block/blk-sysfs.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,26 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
417417
return ret;
418418
}
419419

420+
static ssize_t queue_io_timeout_show(struct request_queue *q, char *page)
421+
{
422+
return sprintf(page, "%u\n", jiffies_to_msecs(q->rq_timeout));
423+
}
424+
425+
static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
426+
size_t count)
427+
{
428+
unsigned int val;
429+
int err;
430+
431+
err = kstrtou32(page, 10, &val);
432+
if (err || val == 0)
433+
return -EINVAL;
434+
435+
blk_queue_rq_timeout(q, msecs_to_jiffies(val));
436+
437+
return count;
438+
}
439+
420440
static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
421441
{
422442
if (!wbt_rq_qos(q))
@@ -685,6 +705,12 @@ static struct queue_sysfs_entry queue_dax_entry = {
685705
.show = queue_dax_show,
686706
};
687707

708+
static struct queue_sysfs_entry queue_io_timeout_entry = {
709+
.attr = {.name = "io_timeout", .mode = 0644 },
710+
.show = queue_io_timeout_show,
711+
.store = queue_io_timeout_store,
712+
};
713+
688714
static struct queue_sysfs_entry queue_wb_lat_entry = {
689715
.attr = {.name = "wbt_lat_usec", .mode = 0644 },
690716
.show = queue_wb_lat_show,
@@ -734,6 +760,7 @@ static struct attribute *default_attrs[] = {
734760
&queue_dax_entry.attr,
735761
&queue_wb_lat_entry.attr,
736762
&queue_poll_delay_entry.attr,
763+
&queue_io_timeout_entry.attr,
737764
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
738765
&throtl_sample_time_entry.attr,
739766
#endif

0 commit comments

Comments
 (0)