summaryrefslogtreecommitdiff
path: root/block/blk-sysfs.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2016-11-28 19:40:34 +0300
committerJens Axboe <axboe@fb.com>2016-11-28 20:27:03 +0300
commitd62118b6dd99b8f64350206a6ea6996083b28c9a (patch)
tree18b3dfdeffa55da6509de99f565b789c29599b20 /block/blk-sysfs.c
parentfa224eed2b5e0f2f9a57281e9dc733c843d590ad (diff)
downloadlinux-d62118b6dd99b8f64350206a6ea6996083b28c9a.tar.xz
blk-wbt: allow wbt to be enabled always through sysfs
Currently there's no way to enable wbt if it's not enabled in the kernel config by default for a device. Allow a write to the 'wbt_lat_usec' queue sysfs file to enable wbt. This is useful for both the kernel config case, but also if the device is CFQ managed and it was turned off by default. Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r--block/blk-sysfs.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index f0ca569e276b..a97841491769 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -425,20 +425,30 @@ static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
ssize_t ret;
s64 val;
- rwb = q->rq_wb;
- if (!rwb)
- return -EINVAL;
-
ret = queue_var_store64(&val, page);
if (ret < 0)
return ret;
+ if (val < -1)
+ return -EINVAL;
+
+ rwb = q->rq_wb;
+ if (!rwb) {
+ ret = wbt_init(q);
+ if (ret)
+ return ret;
+
+ rwb = q->rq_wb;
+ if (!rwb)
+ return -EINVAL;
+ }
if (val == -1)
rwb->min_lat_nsec = wbt_default_latency_nsec(q);
else if (val >= 0)
rwb->min_lat_nsec = val * 1000ULL;
- else
- return -EINVAL;
+
+ if (rwb->enable_state == WBT_STATE_ON_DEFAULT)
+ rwb->enable_state = WBT_STATE_ON_MANUAL;
wbt_update_limits(rwb);
return count;