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

Peter Zijlstra
2021-12-10T21:36:57Z

On Thu, Oct 21, 2021 at 07:45:30PM -0700, Andrew Morton wrote:
> On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>
> > On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
> > > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> > > > Because when sdcard is removed, bdi_min_ratio value will remain.
> > > > Currently, the only way to reset bdi_ min_ratio is to reboot.
> > >
> > > But bdis that are unregistered are never re-registered. What is
> > > the problem you're trying to solve?
> >
> > The global bdi_min_ratio needs to be adjusted. See
> > bdi_set_min_ratio() in mm/page-writeback.c.
>
> I added cc:stable to this and tweaked the comment & coding style a bit:

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

> --- a/mm/backing-dev.c~mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister-fix
> +++ a/mm/backing-dev.c
> @@ -947,10 +947,12 @@ 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) {
> + /*
> + * 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);
> _
>