Re: [PATCH 2/4] bdi: Add bdi->id
From: Matthew Wilcox
Date: Sat Aug 03 2019 - 12:18:07 EST
On Sat, Aug 03, 2019 at 08:53:49AM -0700, Tejun Heo wrote:
> Hey, Matthew.
>
> On Sat, Aug 03, 2019 at 08:39:08AM -0700, Matthew Wilcox wrote:
> > On Sat, Aug 03, 2019 at 07:01:53AM -0700, Tejun Heo wrote:
> > > There currently is no way to universally identify and lookup a bdi
> > > without holding a reference and pointer to it. This patch adds an
> > > non-recycling bdi->id and implements bdi_get_by_id() which looks up
> > > bdis by their ids. This will be used by memcg foreign inode flushing.
> > >
> > > I left bdi_list alone for simplicity and because while rb_tree does
> > > support rcu assignment it doesn't seem to guarantee lossless walk when
> > > walk is racing aginst tree rebalance operations.
> >
> > This would seem like the perfect use for an allocating xarray. That
> > does guarantee lossless walk under the RCU lock. You could get rid of the
> > bdi_list too.
>
> It definitely came to mind but there's a bunch of downsides to
> recycling IDs or using radix tree for non-compacting allocations.
Ah, I wasn't sure what would happen if you recycled an ID. I agree, the
radix tree is pretty horrid for monotonically increasing IDs. I'm still
working on the maple tree to replace it, but that's going slower than
I would like, so I can't in good conscience ask you to wait for it to
be ready.