diff mbox series

[-next,5/6] blk-wbt: cleanup rwb_enabled() and wbt_disabled()

Message ID 20230511014509.679482-6-yukuai1@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series blk-wbt: minor fix and cleanup | expand

Commit Message

Yu Kuai May 11, 2023, 1:45 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com>

The code is redundant, reuse rwb_enabled() for wbt_disabled().

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-wbt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig May 11, 2023, 3:23 p.m. UTC | #1
On Thu, May 11, 2023 at 09:45:08AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> The code is redundant, reuse rwb_enabled() for wbt_disabled().

This also changes how rwb_enabled is implemented.
Yu Kuai May 12, 2023, 7:07 a.m. UTC | #2
Hi,

在 2023/05/11 23:23, Christoph Hellwig 写道:
> On Thu, May 11, 2023 at 09:45:08AM +0800, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> The code is redundant, reuse rwb_enabled() for wbt_disabled().
> 
> This also changes how rwb_enabled is implemented.
> 

'rwb->wb_normal == 0' should be the same as 'rwb->enable_state ==
WBT_STATE_OFF_MANUAL', I'll explain in detail in v2.

Thanks,
Kuai
diff mbox series

Patch

diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 7a9a30da8650..7066fc2c1e5d 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -146,7 +146,7 @@  enum {
 static inline bool rwb_enabled(struct rq_wb *rwb)
 {
 	return rwb && rwb->enable_state != WBT_STATE_OFF_DEFAULT &&
-		      rwb->wb_normal != 0;
+		      rwb->enable_state != WBT_STATE_OFF_MANUAL;
 }
 
 static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
@@ -494,8 +494,7 @@  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;
+	return !rqos || !rwb_enabled(RQWB(rqos));
 }
 
 u64 wbt_get_min_lat(struct request_queue *q)