This is a note to let you know that I've just added the patch titled mm: bdi: initialize bdi_min_ratio when bdi is unregistered to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-bdi-initialize-bdi_min_ratio-when-bdi-is-unregistered.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 3c376dfafbf7a8ea0dea212d095ddd83e93280bb Mon Sep 17 00:00:00 2001 From: Manjong Lee <mj0123.lee@xxxxxxxxxxx> Date: Fri, 10 Dec 2021 14:47:11 -0800 Subject: mm: bdi: initialize bdi_min_ratio when bdi is unregistered From: Manjong Lee <mj0123.lee@xxxxxxxxxxx> commit 3c376dfafbf7a8ea0dea212d095ddd83e93280bb upstream. 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. [akpm@xxxxxxxxxxxxxxxxxxxx: tweak comment and coding style] Link: https://lkml.kernel.org/r/20211021161942.5983-1-mj0123.lee@xxxxxxxxxxx Signed-off-by: Manjong Lee <mj0123.lee@xxxxxxxxxxx> Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> 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> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/backing-dev.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -946,6 +946,13 @@ void bdi_unregister(struct backing_dev_i 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); Patches currently in stable-queue which might be from mj0123.lee@xxxxxxxxxxx are queue-4.19/mm-bdi-initialize-bdi_min_ratio-when-bdi-is-unregistered.patch