[09/11] blk-throttle: remove unnecessary check for validation of limit index

Message ID 20221123060401.20392-10-shikemeng@huawei.com
State New
Headers
Series A few bugfix and cleanup patches for blk-throttle |

Commit Message

Kemeng Shi Nov. 23, 2022, 6:03 a.m. UTC
  We always keep limit index valid as following:
Max limit is always valid and low limit can only be invalidated in
blk_throtl_update_limit_valid. Each time low limit may become invalid
after blk_throtl_update_limit_valid is called, we will check and make
sure current limit index is valid.

It's reasonable to always keep limit index valid, so we can remove this
check.

Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
---
 block/blk-throttle.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Tejun Heo Nov. 23, 2022, 6:31 p.m. UTC | #1
On Wed, Nov 23, 2022 at 02:03:59PM +0800, Kemeng Shi wrote:
> We always keep limit index valid as following:
> Max limit is always valid and low limit can only be invalidated in
> blk_throtl_update_limit_valid. Each time low limit may become invalid
> after blk_throtl_update_limit_valid is called, we will check and make
> sure current limit index is valid.
> 
> It's reasonable to always keep limit index valid, so we can remove this
> check.

It's not obvious to me that it's correct and I'm not sure what we're gaining
by removing this while risking subtle breakages.
  
Kemeng Shi Nov. 24, 2022, 12:58 p.m. UTC | #2
on 11/24/2022 2:31 AM, Tejun Heo wrote:
> On Wed, Nov 23, 2022 at 02:03:59PM +0800, Kemeng Shi wrote:
>> We always keep limit index valid as following:
>> Max limit is always valid and low limit can only be invalidated in
>> blk_throtl_update_limit_valid. Each time low limit may become invalid
>> after blk_throtl_update_limit_valid is called, we will check and make
>> sure current limit index is valid.
>>
>> It's reasonable to always keep limit index valid, so we can remove this
>> check.
> 
> It's not obvious to me that it's correct and I'm not sure what we're gaining
> by removing this while risking subtle breakages.
I will remove this patch in next version.
  

Patch

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 3eccc7af4368..6f509cadd92b 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -418,12 +418,10 @@  static void tg_update_has_rules(struct throtl_grp *tg)
 	for (rw = READ; rw <= WRITE; rw++) {
 		tg->has_rules_iops[rw] =
 			(parent_tg && parent_tg->has_rules_iops[rw]) ||
-			(td->limit_valid[td->limit_index] &&
-			  tg_iops_limit(tg, rw) != UINT_MAX);
+			  (tg_iops_limit(tg, rw) != UINT_MAX);
 		tg->has_rules_bps[rw] =
 			(parent_tg && parent_tg->has_rules_bps[rw]) ||
-			(td->limit_valid[td->limit_index] &&
-			 (tg_bps_limit(tg, rw) != U64_MAX));
+			 (tg_bps_limit(tg, rw) != U64_MAX);
 	}
 }