Skip to content

Commit

Permalink
mm: bdi: initialize bdi_min_ratio when bdi is unregistered
Browse files Browse the repository at this point in the history
Initialize min_ratio if it is set during bdi unregistration.  This can
prevent problems that may occur a when bdi is removed without resetting
min_ratio.

For example.
1) insert external sdcard
2) set external sdcard's min_ratio 70
3) remove external sdcard without setting min_ratio 0
4) insert external sdcard
5) set external sdcard's min_ratio 70 << error occur(can't set)

Because when an sdcard is removed, the present bdi_min_ratio value will
remain.  Currently, the only way to reset bdi_min_ratio is to reboot.

[[email protected]: tweak comment and coding style]

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Manjong Lee <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Changheun Lee <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Manjong Lee authored and torvalds committed Dec 11, 2021
1 parent 4178158 commit 3c376df
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,13 @@ void bdi_unregister(struct backing_dev_info *bdi)
wb_shutdown(&bdi->wb);
cgwb_bdi_unregister(bdi);

/*
* If this BDI's min ratio has been set, use bdi_set_min_ratio() to
* update the global bdi_min_ratio.
*/
if (bdi->min_ratio)
bdi_set_min_ratio(bdi, 0);

if (bdi->dev) {
bdi_debug_unregister(bdi);
device_unregister(bdi->dev);
Expand Down

0 comments on commit 3c376df

Please sign in to comment.