Message ID | 20220930031906.4164306-5-yukuai1@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | blk-wbt: simple improvment to enable wbt correctly | expand |
> static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) > { > + u64 lat; > + > if (!wbt_rq_qos(q)) > return -EINVAL; > > - return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); > + lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000); > + > + return sprintf(page, "%llu\n", lat); if (wbt_disabled(q)) return sprintf(page, "0\n"); return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); but otherwise the patch looks fine: Reviewed-by: Christoph Hellwig <hch@lst.de>
Hi, 在 2022/10/18 23:49, Christoph Hellwig 写道: >> static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) >> { >> + u64 lat; >> + >> if (!wbt_rq_qos(q)) >> return -EINVAL; >> >> - return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); >> + lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000); >> + >> + return sprintf(page, "%llu\n", lat); > > if (wbt_disabled(q)) > return sprintf(page, "0\n"); > return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); > > but otherwise the patch looks fine: > > Reviewed-by: Christoph Hellwig <hch@lst.de> > . > Thanks for the review, I'll send a new version. Kuai
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index e71b3b43927c..5a6950b4ff69 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -467,10 +467,14 @@ static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page, static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) { + u64 lat; + if (!wbt_rq_qos(q)) return -EINVAL; - return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); + lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000); + + return sprintf(page, "%llu\n", lat); } static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page, diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 9cac54569ff1..1852ef223c68 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -422,6 +422,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 7fe98638fff5..e3ea6e7e2900 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); @@ -127,6 +128,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 */