[-next,1/6] blk-wbt: fix that wbt can't be disabled by default

Message ID 20230511014509.679482-2-yukuai1@huaweicloud.com
State New
Headers
Series blk-wbt: minor fix and cleanup |

Commit Message

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

commit b11d31ae01e6 ("blk-wbt: remove unnecessary check in
wbt_enable_default()") removes the checking of CONFIG_BLK_WBT_MQ by
mistake, which is used to control enable or disable wbt by default.

Fix the problem by adding back the checking.

Fixes: b11d31ae01e6 ("blk-wbt: remove unnecessary check in wbt_enable_default()")
Reported-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/lkml/CAKXUXMzfKq_J9nKHGyr5P5rvUETY4B-fxoQD4sO+NYjFOfVtZA@mail.gmail.com/t/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-wbt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Christoph Hellwig May 11, 2023, 3:19 p.m. UTC | #1
On Thu, May 11, 2023 at 09:45:04AM +0800, Yu Kuai wrote:
> @@ -730,8 +730,9 @@ void wbt_enable_default(struct gendisk *disk)
>  {
>  	struct request_queue *q = disk->queue;
>  	struct rq_qos *rqos;
> -	bool disable_flag = q->elevator &&
> -		    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags);
> +	bool disable_flag = (q->elevator &&
> +		    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags)) ||
> +		    !IS_ENABLED(CONFIG_BLK_WBT_MQ);

Not really new in your patch, but I find the logic here very confusing.
First the disable_flag really should be enable instead, as that's how
it's actually checked, and then spelling out the conditions a bit more
would really help readability.  E.g.

	bool enabled = IS_ENABLED(CONFIG_BLK_WBT_MQ);

	if (q->elevator &&
	    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags))
		enable = false;
  
Yu Kuai May 12, 2023, 7:03 a.m. UTC | #2
Hi,

在 2023/05/11 23:19, Christoph Hellwig 写道:
> On Thu, May 11, 2023 at 09:45:04AM +0800, Yu Kuai wrote:
>> @@ -730,8 +730,9 @@ void wbt_enable_default(struct gendisk *disk)
>>   {
>>   	struct request_queue *q = disk->queue;
>>   	struct rq_qos *rqos;
>> -	bool disable_flag = q->elevator &&
>> -		    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags);
>> +	bool disable_flag = (q->elevator &&
>> +		    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags)) ||
>> +		    !IS_ENABLED(CONFIG_BLK_WBT_MQ);
> 
> Not really new in your patch, but I find the logic here very confusing.
> First the disable_flag really should be enable instead, as that's how
> it's actually checked, and then spelling out the conditions a bit more
> would really help readability.  E.g.
> 
> 	bool enabled = IS_ENABLED(CONFIG_BLK_WBT_MQ);
> 
> 	if (q->elevator &&
> 	    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags))
> 		enable = false;

Of course, this looks better, I'll do this in v2.

Thanks,
Kuai
> 
> 
> .
>
  

Patch

diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index e49a48684532..b1ab4688eb5c 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -730,8 +730,9 @@  void wbt_enable_default(struct gendisk *disk)
 {
 	struct request_queue *q = disk->queue;
 	struct rq_qos *rqos;
-	bool disable_flag = q->elevator &&
-		    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags);
+	bool disable_flag = (q->elevator &&
+		    test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags)) ||
+		    !IS_ENABLED(CONFIG_BLK_WBT_MQ);
 
 	/* Throttling already enabled? */
 	rqos = wbt_rq_qos(q);