blk-wbt: add wbt_any_inflight()
Some callsites care about the specific number of writes inflight,
others only care if any writes are inflight or not. In preparation
for increasing the number of wait buckets, add wbt_any_inflight()
to avoid iterating and checking more buckets than we need.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 1345935..2512442 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -277,6 +277,27 @@ enum {
LAT_EXCEEDED,
};
+static bool wbt_any_inflight(struct rq_wb *rwb)
+{
+ unsigned int i;
+
+ for (i = 0; i < WBT_NUM_RWQ; i++)
+ if (atomic_read(&rwb->rq_wait[i].inflight))
+ return true;
+
+ return false;
+}
+
+static unsigned int wbt_inflight(struct rq_wb *rwb)
+{
+ unsigned int i, ret = 0;
+
+ for (i = 0; i < WBT_NUM_RWQ; i++)
+ ret += atomic_read(&rwb->rq_wait[i].inflight);
+
+ return ret;
+}
+
static int latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)
{
struct backing_dev_info *bdi = rwb->queue->backing_dev_info;
@@ -309,7 +330,7 @@ static int latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)
* just writes as well.
*/
if (stat[WRITE].nr_samples || wb_recent_wait(rwb) ||
- wbt_inflight(rwb))
+ wbt_any_inflight(rwb))
return LAT_UNKNOWN_WRITES;
return LAT_UNKNOWN;
}
diff --git a/block/blk-wbt.h b/block/blk-wbt.h
index df6de50..e7c0863 100644
--- a/block/blk-wbt.h
+++ b/block/blk-wbt.h
@@ -96,16 +96,6 @@ struct rq_wb {
struct rq_wait rq_wait[WBT_NUM_RWQ];
};
-static inline unsigned int wbt_inflight(struct rq_wb *rwb)
-{
- unsigned int i, ret = 0;
-
- for (i = 0; i < WBT_NUM_RWQ; i++)
- ret += atomic_read(&rwb->rq_wait[i].inflight);
-
- return ret;
-}
-
#ifdef CONFIG_BLK_WBT
void __wbt_done(struct rq_wb *, enum wbt_flags);