Skip to contentSkip to conversation

block: add documentation for io_timeout

PATCH Superseded Weiping Zhang 4 participants 8 messages Dec 5, 2018 – Dec 26, 2018

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 block: add documentation for io_timeout

Add documentation for /sys/block/<disk>/queue/io_timeout.

---
 Documentation/ABI/testing/sysfs-block | 10 ++++++++++
 Documentation/block/queue-sysfs.txt   |  7 +++++++
 2 files changed, 17 insertions(+)
Documentation/ABI/testing/sysfs-block +10 -0
index dea212db9df3..f254a374710a 100644
@@ -271,3 +271,13 @@ Description:
 		size of 512B sectors of the zones of the device, with
 		the eventual exception of the last zone of the device
 		which may be smaller.
+
+What:		/sys/block/<disk>/queue/io_timeout
+Date:		November 2018
+Contact:	Weiping Zhang <[email protected]>
+Description:
+		io_timeout is a request’s timeouts at block layer in
+		milliseconds. When the underlying driver starts processing
+		a request, the generic block layer will start a timer, if
+		this request cannot be completed in io_timeout milliseconds,
+		a timeout event will occur.
Documentation/block/queue-sysfs.txt +7 -0
index 2c1e67058fd3..f0c9bbce73fd 100644
@@ -67,6 +67,13 @@ If set to a value larger than 0, the kernel will put the process issuing
 IO to sleep for this amont of microseconds before entering classic
 polling.
 
+io_timeout (RW)
+---------------
+This is a request’s timeouts at block layer in milliseconds. When the
+underlying driver starts processing a request, the generic block layer
+will start a timer, if this request cannot be completed in io_timeout
+milliseconds, a timeout event will occur.
+
 iostats (RW)
 -------------
 This file is used to control (on/off) the iostats accounting of the
Signature · 1 line
2.14.1
#1 lore raw

Can you please also send a patch to not show this attribute for drivers without a timeout handler? Thanks!

Quoted 47 lines · Weiping Zhang

Add documentation for /sys/block/<disk>/queue/io_timeout.

---
 Documentation/ABI/testing/sysfs-block | 10 ++++++++++
 Documentation/block/queue-sysfs.txt   |  7 +++++++
 2 files changed, 17 insertions(+)
Documentation/ABI/testing/sysfs-block +10 -0
index dea212db9df3..f254a374710a 100644
@@ -271,3 +271,13 @@ Description:
 		size of 512B sectors of the zones of the device, with
 		the eventual exception of the last zone of the device
 		which may be smaller.
+
+What:		/sys/block/<disk>/queue/io_timeout
+Date:		November 2018
+Contact:	Weiping Zhang <[email protected]>
+Description:
+		io_timeout is a request’s timeouts at block layer in
+		milliseconds. When the underlying driver starts processing
+		a request, the generic block layer will start a timer, if
+		this request cannot be completed in io_timeout milliseconds,
+		a timeout event will occur.
Documentation/block/queue-sysfs.txt +7 -0
index 2c1e67058fd3..f0c9bbce73fd 100644
@@ -67,6 +67,13 @@ If set to a value larger than 0, the kernel will put the process issuing
 IO to sleep for this amont of microseconds before entering classic
 polling.
 
+io_timeout (RW)
+---------------
+This is a request’s timeouts at block layer in milliseconds. When the
+underlying driver starts processing a request, the generic block layer
+will start a timer, if this request cannot be completed in io_timeout
+milliseconds, a timeout event will occur.
+
 iostats (RW)
 -------------
 This file is used to control (on/off) the iostats accounting of the
Signature · 1 line
2.14.1

---end quoted text---

#2 lore raw
Quoted 4 lines · Christoph Hellwig <[email protected]> 于2018年12月5日周三 下午10:40写道:

Can you please also send a patch to not show this attribute for drivers without a timeout handler? Thanks!

Do you means checking q->mq_ops->timeout is NULL or not ?

static void blk_mq_rq_timed_out(struct request *req, bool reserved)

{
        req->rq_flags |= RQF_TIMED_OUT;

If it's NULL, only re-start a timer for this request in blk_add_timer. Is there some defect ? if show this attribute and the driver doesn't support timeout handler ?

        if (req->q->mq_ops->timeout) {
                enum blk_eh_timer_return ret;

                ret = req->q->mq_ops->timeout(req, reserved);
                if (ret == BLK_EH_DONE)
                        return;
                WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER);
        }

        blk_add_timer(req);
}
Quoted 49 lines · Weiping Zhang
Quoted 45 lines

Add documentation for /sys/block/<disk>/queue/io_timeout.

---
 Documentation/ABI/testing/sysfs-block | 10 ++++++++++
 Documentation/block/queue-sysfs.txt   |  7 +++++++
 2 files changed, 17 insertions(+)
Documentation/ABI/testing/sysfs-block +10 -0
index dea212db9df3..f254a374710a 100644
@@ -271,3 +271,13 @@ Description:
              size of 512B sectors of the zones of the device, with
              the eventual exception of the last zone of the device
              which may be smaller.
+
+What:                /sys/block/<disk>/queue/io_timeout
+Date:                November 2018
+Contact:     Weiping Zhang <[email protected]>
+Description:
+             io_timeout is a request’s timeouts at block layer in
+             milliseconds. When the underlying driver starts processing
+             a request, the generic block layer will start a timer, if
+             this request cannot be completed in io_timeout milliseconds,
+             a timeout event will occur.
Documentation/block/queue-sysfs.txt +7 -1
index 2c1e67058fd3..f0c9bbce73fd 100644
@@ -67,6 +67,13 @@ If set to a value larger than 0, the kernel will put the process issuing
 IO to sleep for this amont of microseconds before entering classic
 polling.
 
+io_timeout (RW)
+---------------
+This is a request’s timeouts at block layer in milliseconds. When the
+underlying driver starts processing a request, the generic block layer
+will start a timer, if this request cannot be completed in io_timeout
+milliseconds, a timeout event will occur.
+
 iostats (RW)
 -------------
 This file is used to control (on/off) the iostats accounting of the
--
Quoted 2 lines

2.14.1

---end quoted text---

#3 lore raw
Quoted 6 lines · Weiping Zhang <[email protected]> 于2018年12月5日周三 下午10:49写道:
Quoted 4 lines · Christoph Hellwig <[email protected]> 于2018年12月5日周三 下午10:40写道:

Can you please also send a patch to not show this attribute for drivers without a timeout handler? Thanks!

Is there a simple way do that ?

Shall we return -ENOTSUPP when user read/write this attribute when driver has no timeout handler ?

Quoted 71 lines

Do you means checking q->mq_ops->timeout is NULL or not ?

static void blk_mq_rq_timed_out(struct request *req, bool reserved)

{
        req->rq_flags |= RQF_TIMED_OUT;

If it's NULL, only re-start a timer for this request in blk_add_timer. Is there some defect ? if show this attribute and the driver doesn't support timeout handler ?

        if (req->q->mq_ops->timeout) {
                enum blk_eh_timer_return ret;

                ret = req->q->mq_ops->timeout(req, reserved);
                if (ret == BLK_EH_DONE)
                        return;
                WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER);
        }

        blk_add_timer(req);
}
Quoted 49 lines · Weiping Zhang
Quoted 45 lines

Add documentation for /sys/block/<disk>/queue/io_timeout.

---
 Documentation/ABI/testing/sysfs-block | 10 ++++++++++
 Documentation/block/queue-sysfs.txt   |  7 +++++++
 2 files changed, 17 insertions(+)
Documentation/ABI/testing/sysfs-block +10 -0
index dea212db9df3..f254a374710a 100644
@@ -271,3 +271,13 @@ Description:
              size of 512B sectors of the zones of the device, with
              the eventual exception of the last zone of the device
              which may be smaller.
+
+What:                /sys/block/<disk>/queue/io_timeout
+Date:                November 2018
+Contact:     Weiping Zhang <[email protected]>
+Description:
+             io_timeout is a request’s timeouts at block layer in
+             milliseconds. When the underlying driver starts processing
+             a request, the generic block layer will start a timer, if
+             this request cannot be completed in io_timeout milliseconds,
+             a timeout event will occur.
Documentation/block/queue-sysfs.txt +7 -1
index 2c1e67058fd3..f0c9bbce73fd 100644
@@ -67,6 +67,13 @@ If set to a value larger than 0, the kernel will put the process issuing
 IO to sleep for this amont of microseconds before entering classic
 polling.
 
+io_timeout (RW)
+---------------
+This is a request’s timeouts at block layer in milliseconds. When the
+underlying driver starts processing a request, the generic block layer
+will start a timer, if this request cannot be completed in io_timeout
+milliseconds, a timeout event will occur.
+
 iostats (RW)
 -------------
 This file is used to control (on/off) the iostats accounting of the
--
Quoted 2 lines

2.14.1

---end quoted text---

#4 lore raw
Quoted 3 lines · Weiping Zhang

Weiping Zhang <[email protected]>于2018年12月5日周三下午10:49写道:>>Christoph Hellwig <[email protected]>于2018年12月5日周三下午10:40写道:>>>Can you please also send a patch to not show this attribute for

Quoted 1 line
Quoted 1 line

drivers without a timeout handler? Thanks!>

Is there a simple way do that ?

How about checking the timeout member of struct blk_mq_ops for blk-mq and checking the rq_timed_out_fn member in struct request_queue for the legacy block layer?

Quoted 2 lines

Shall we return -ENOTSUPP when user read/write this attribute when driver has no timeout handler ?

A much more elegant solution is to introduce a sysfs attribute group for the io_timeout attribute and to make that group visible only if a timeout handler has been defined. See e.g. disk_attr_group in block/genhd.c for an example.

Bart.

#5 lore raw
Quoted 11 lines · Bart Van Assche
Quoted 6 lines · Weiping Zhang
Quoted 3 lines · Weiping Zhang <[email protected]> 于2018年12月5日周三 下午10:49写道:
Quoted 2 lines · Christoph Hellwig <[email protected]> 于2018年12月5日周三 下午10:40写道:

Can you please also send a patch to not show this attribute for drivers without a timeout handler? Thanks!

Is there a simple way do that ?

How about checking the timeout member of struct blk_mq_ops for blk-mq and checking the rq_timed_out_fn member in struct request_queue for the legacy block layer?

Just the former given that the legacy code is gone in for-next.

Quoted 6 lines
Quoted 2 lines

Shall we return -ENOTSUPP when user read/write this attribute when driver has no timeout handler ?

A much more elegant solution is to introduce a sysfs attribute group for the io_timeout attribute and to make that group visible only if a timeout handler has been defined. See e.g. disk_attr_group in block/genhd.c for an example.

Agreed, that is the way to go.

#6 lore raw
In reply to Weiping Zhang
Quoted 6 lines · Weiping Zhang
+-Description:
+-		io_timeout is a request’s timeouts at block layer in
+-		milliseconds. When the underlying driver starts processing
+-		a request, the generic block layer will start a timer, if
+-		this request cannot be completed in io_timeout milliseconds,
+-		a timeout event will occur.

Sorry but I think this description is still somewhat confusing. How about changing that description into the following?

io_timeout is the request timeout in milliseconds. If a request does not complete in this time then the block driver timeout handler is invoked. That timeout handler can decide to retry the request, to fail it or to start a device recovery strategy.

Bart.

#7 lore raw
Quoted 9 lines · Bart Van Assche <[email protected]> 于2018年12月7日周五 上午12:22写道:

Documentation/ABI/testing/sysfs-block Description: · line 283

Quoted 6 lines · Weiping Zhang
Documentation/ABI/testing/sysfs-block +6 -0
+Description:
+             io_timeout is a request’s timeouts at block layer in
+             milliseconds. When the underlying driver starts processing
+             a request, the generic block layer will start a timer, if
+             this request cannot be completed in io_timeout milliseconds,
+             a timeout event will occur.
Quoted 8 lines

Sorry but I think this description is still somewhat confusing. How about changing that description into the following?

io_timeout is the request timeout in milliseconds. If a request does not complete in this time then the block driver timeout handler is invoked. That timeout handler can decide to retry the request, to fail it or to start a device recovery strategy.

Sorry for late reply, thanks for your suggestion I'll post it in V4.

Quoted 10 lines

Bart.

Quoted 5 lines
Quoted 1 line

Is there a simple way do that ?

How about checking the timeout member of struct blk_mq_ops for blk-mq and checking the rq_timed_out_fn member in struct request_queue for the legacy block layer?

Just the former given that the legacy code is gone in for-next.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Shall we return -ENOTSUPP when user read/write this attribute when driver has no timeout handler ?

A much more elegant solution is to introduce a sysfs attribute group for the io_timeout attribute and to make that group visible only if a timeout handler has been defined. See e.g. disk_attr_group in block/genhd.c for an example.

Agreed, that is the way to go.

OK, I'll do that.

Thanks
Weiping