[Devel] [PATCH RH7 02/12] blk-wbt: move disable check into get_limit()

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Sep 29 14:30:02 MSK 2022


From: Jens Axboe <axboe at kernel.dk>

Check it in one place, instead of in multiple places.

Tested-by: Anchal Agarwal <anchalag at amazon.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>

https://jira.sw.ru/browse/PSBM-141883
(cherry picked from commit ffa358dcaae1f2f00926484e712e06daa8953cb4)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 block/blk-wbt.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 600046a47ed8..c178c06c3276 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -482,6 +482,13 @@ static inline unsigned int get_limit(struct rq_wb *rwb, unsigned long rw)
 {
 	unsigned int limit;
 
+	/*
+	 * If we got disabled, just return UINT_MAX. This ensures that
+	 * we'll properly inc a new IO, and dec+wakeup at the end.
+	 */
+	if (!rwb_enabled(rwb))
+		return UINT_MAX;
+
 	/*
 	 * At this point we know it's a buffered write. If this is
 	 * kswapd trying to free memory, or REQ_SYNC is set, set, then
@@ -513,16 +520,6 @@ static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
 	struct rq_wait *rqw = get_rq_wait(rwb, current_is_kswapd());
 	DECLARE_WAITQUEUE(wait, current);
 
-	/*
-	* inc it here even if disabled, since we'll dec it at completion.
-	* this only happens if the task was sleeping in __wbt_wait(),
-	* and someone turned it off at the same time.
-	*/
-	if (!rwb_enabled(rwb)) {
-		atomic_inc(&rqw->inflight);
-		return;
-	}
-
 	if (!waitqueue_active(&rqw->wait)
 		&& rq_wait_inc_below(rqw, get_limit(rwb, rw)))
 		return;
@@ -531,11 +528,6 @@ static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
 	do {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 
-		if (!rwb_enabled(rwb)) {
-			atomic_inc(&rqw->inflight);
-			break;
-		}
-
 		if (rq_wait_inc_below(rqw, get_limit(rwb, rw)))
 			break;
 
-- 
2.37.1



More information about the Devel mailing list