Re: [PATCH 4/4] btrfs: free anon_dev earlier to prevent exhausting anonymous block device pool

David Sterba
2020-06-16T22:48:54Z

On Tue, Jun 16, 2020 at 03:23:03PM -0400, Josef Bacik wrote:
> > By freeing it earlier we reclaim the anon_dev quicker, hopefully to
> > reduce the chance of exhausting the pool.
>
> Why isn't this happening as part of the root teardown once all the references to
> it are gone? Thanks,

This is where it happens now and is correct. The problem is that deleted
subvolumes keep the id allocated until they are cleaned up, ie. all the
dead roots consume the id though we don't need it anymore. Creating and
deleting snapshots at large will produce a long list of dead subvolumes.
THis patch will return the ids at the earlies possible moment so they
can get reused.