The patch titled Subject: mm: bdi: initialize bdi_min_ratio when bdi is unregistered has been added to the -mm tree. Its filename is mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Manjong Lee <mj0123.lee@xxxxxxxxxxx> Subject: mm: bdi: initialize bdi_min_ratio when bdi is unregistered 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. Link: https://lkml.kernel.org/r/20211021161942.5983-1-mj0123.lee@xxxxxxxxxxx Signed-off-by: Manjong Lee <mj0123.lee@xxxxxxxxxxx> Cc: Changheun Lee <nanich.lee@xxxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: <seunghwan.hyun@xxxxxxxxxxx> Cc: <sookwan7.kim@xxxxxxxxxxx> Cc: <yt0928.kim@xxxxxxxxxxx> Cc: <junho89.kim@xxxxxxxxxxx> Cc: <jisoo2146.oh@xxxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/backing-dev.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/mm/backing-dev.c~mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister +++ a/mm/backing-dev.c @@ -947,6 +947,11 @@ void bdi_unregister(struct backing_dev_i 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); _ Patches currently in -mm which might be from mj0123.lee@xxxxxxxxxxx are mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister.patch