[PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister

Manjong Lee
2021-10-21T07:23:14Z

Initialize min_ratio if it is set when bdi unregister.
It can prevent problems that may occur 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 sdcard is removed, bdi_min_ratio value will remain.
Currently, the only way to reset bdi_ min_ratio is to reboot.

Signed-off-by: Manjong Lee <mj0123.lee@samsung.com>
---
mm/backing-dev.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 4a9d4e27d0d9..ca53807be188 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -947,6 +947,11 @@ void bdi_unregister(struct backing_dev_info *bdi)
wb_shutdown(&bdi->wb);
cgwb_bdi_unregister(bdi);

+ /* if min ratio doesn't 0, it has to set 0 before unregister */
+ if (bdi->min_ratio) {
+ bdi_set_min_ratio(bdi, 0);
+ }
+
if (bdi->dev) {
bdi_debug_unregister(bdi);
device_unregister(bdi->dev);
--
2.32.0