On Tue, Jun 10, 2025 at 09:21:48AM +0100, Al Viro wrote: > Simplify the rules for mount refcounts. Current rules include: > * being a namespace root => +1 > * being someone's child => +1 > * being someone's child => +1 to parent's refcount, unless you've > already been through umount_tree(). > > The last part is not needed at all. It makes for more places where need > to decrement refcounts and it creates an asymmetry between the situations > for something that has never been a part of a namespace and something that > left one, both for no good reason. > > If mount's refcount has additions from its children, we know that > * it's either someone's child itself (and will remain so > until umount_tree(), at which point contributions from children > will disappear), or > * or is the root of namespace (and will remain such until > it either becomes someone's child in another namespace or goes through > umount_tree()), or > * it is the root of some tree copy, and is currently pinned > by the caller of copy_tree() (and remains such until it either gets > into namespace, or goes to umount_tree()). > In all cases we already have contribution(s) to refcount that will last > as long as the contribution from children remains. In other words, the > lifetime is not affected by refcount contributions from children. > > It might be useful for "is it busy" checks, but those are actually > no harder to express without it. > > NB: propagate_mnt_busy() part is an equivalent transformation, ugly as it > is; the current logics is actually wrong and may give false negatives, > but fixing that is for a separate patch (probably earlier in the queue). > > Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx> > --- Reviewed-by: Christian Brauner <brauner@xxxxxxxxxx>