diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 92dc765ef124513423148b6b0f257beba82fd73d..db7c0503bead064b8f7d0c4b47f02e160e9041a3 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -461,6 +461,9 @@ static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) if (!wbt_rq_qos(q)) return -EINVAL; + if (wbt_disabled(q)) + return sprintf(page, "0\n"); + return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); } diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 9ddd52355f3b57b213260b56121ff9a4a8262773..6a90d33e6f6a39c315aa1364f6b75011c485642b 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -419,6 +419,14 @@ static void wbt_update_limits(struct rq_wb *rwb) rwb_wake_all(rwb); } +bool wbt_disabled(struct request_queue *q) +{ + struct rq_qos *rqos = wbt_rq_qos(q); + + return !rqos || RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT || + RQWB(rqos)->enable_state == WBT_STATE_OFF_MANUAL; +} + u64 wbt_get_min_lat(struct request_queue *q) { struct rq_qos *rqos = wbt_rq_qos(q); diff --git a/block/blk-wbt.h b/block/blk-wbt.h index c4d365b9f7b02a033472f6d07427e3954b583442..824047c395fff93952fd9032a80b4f68578a5710 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -96,6 +96,7 @@ void wbt_enable_default(struct request_queue *); u64 wbt_get_min_lat(struct request_queue *q); void wbt_set_min_lat(struct request_queue *q, u64 val); +bool wbt_disabled(struct request_queue *); void wbt_set_write_cache(struct request_queue *, bool); @@ -130,6 +131,10 @@ static inline u64 wbt_default_latency_nsec(struct request_queue *q) { return 0; } +static inline bool wbt_disabled(struct request_queue *q) +{ + return true; +} #endif /* CONFIG_BLK_WBT */