Skip to contentSkip to conversation

null_blk: fix race and oops at removing device with bandwidth limit

PATCH New Konstantin Khlebnikov 1 participant 1 message Apr 1, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 null_blk: fix race and oops at removing device with bandwidth limit

Function null_del_dev should disable throttling before canceling timer, otherwise timer could be restarted by null_handle_cmd().

Remove bump of cur_bytes - without NULLB_DEV_FL_THROTTLED it has no effect.

Fixes eff2c4f10873 ("nullb: bandwidth control")
---
 drivers/block/null_blk_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk_main.c +1 -1
index 417a9f15c116..757b58e0fec7 100644
@@ -1383,8 +1383,8 @@ static void null_del_dev(struct nullb *nullb)
 	del_gendisk(nullb->disk);
 
 	if (test_bit(NULLB_DEV_FL_THROTTLED, &nullb->dev->flags)) {
+		clear_bit(NULLB_DEV_FL_THROTTLED, &nullb->dev->flags);
 		hrtimer_cancel(&nullb->bw_timer);
-		atomic_long_set(&nullb->cur_bytes, LONG_MAX);
 		null_restart_queue_async(nullb);
 	}