[SRU][linux-aws-xenial][PATCH 2/2] block: don't show io_timeout if driver has no timeout handler
Kamal Mostafa
kamal at canonical.com
Mon Aug 26 18:47:53 UTC 2019
From: Weiping Zhang <zhangweiping at didiglobal.com>
BugLink: https://bugs.launchpad.net/bugs/1841461
If the low level driver has no timeout handler, the
/sys/block/<disk>/queue/io_timeout will not be displayed.
Reviewed-by: Bart Van Assche <bvanassche at acm.org>
Signed-off-by: Weiping Zhang <zhangweiping at didiglobal.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>
(backported from commit 4d25339e32a1b6e1f490bb78b1e5b0fa9eb3e073)
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
block/blk-sysfs.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 5da33f8d1d53..0507c1d25134 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -505,7 +505,7 @@ static struct queue_sysfs_entry queue_io_timeout_entry = {
.store = queue_io_timeout_store,
};
-static struct attribute *default_attrs[] = {
+static struct attribute *queue_attrs[] = {
&queue_requests_entry.attr,
&queue_ra_entry.attr,
&queue_max_hw_sectors_entry.attr,
@@ -534,6 +534,25 @@ static struct attribute *default_attrs[] = {
NULL,
};
+static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
+ int n)
+{
+ struct request_queue *q =
+ container_of(kobj, struct request_queue, kobj);
+
+ if (attr == &queue_io_timeout_entry.attr &&
+ (!q->mq_ops || !q->mq_ops->timeout))
+ return 0;
+
+ return attr->mode;
+}
+
+static struct attribute_group queue_attr_group = {
+ .attrs = queue_attrs,
+ .is_visible = queue_attr_visible,
+};
+
+
#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)
static ssize_t
@@ -641,7 +660,6 @@ static const struct sysfs_ops queue_sysfs_ops = {
struct kobj_type blk_queue_ktype = {
.sysfs_ops = &queue_sysfs_ops,
- .default_attrs = default_attrs,
.release = blk_release_queue,
};
@@ -679,6 +697,14 @@ int blk_register_queue(struct gendisk *disk)
return ret;
}
+ ret = sysfs_create_group(&q->kobj, &queue_attr_group);
+ if (ret) {
+ blk_trace_remove_sysfs(dev);
+ kobject_del(&q->kobj);
+ kobject_put(&dev->kobj);
+ return ret;
+ }
+
kobject_uevent(&q->kobj, KOBJ_ADD);
if (q->mq_ops)
--
2.17.1
More information about the kernel-team
mailing list