On Tue, Aug 26, 2025 at 06:17:45PM +0300, Askar Safin wrote: > Al Viro <viro@xxxxxxxxxxxxxxxxxx>: > > When the last reference to > > mount past the umount_tree() (i.e. already with NULL ->mnt_ns) goes away, anything > > subtree stuck to it will be detached from it and have its root unhashed and dropped. > > In other words, such tree (e.g. result of umount -l) decays from root to leaves - > > once all references to root are gone, it's cut off and all pieces are left > > to decay. That is done with mount_writer (has to be - there are mount hash changes > > and for those mount_writer is a hard requirement) and only after the final reference > > to root has been dropped. > > I'm unable to understand this. > > As well as I understand your text, when you unmount some directory /a using "umount -l /a", then /a and > all its children will stay as long as there are references to /a . This contradicts to reality. > > Consider this: > > # mount -t tmpfs tmpfs /a > # mkdir /a/b > # mount -t tmpfs tmpfs /a/b > # mkdir /a/b/c > # cd /a > # umount -l /a > > According to your text, both /a and /a/b will stay, because we have reference to /a (via our cwd). > > But in reality /a/b disappears immidiately (i. e. "ls b" shows nothing, as opposed to "c"). > > This happens even if I test with your patches applied. > > So, your explanation seems to be wrong. Take a look at disconnect_mount(). For example, if mount is locked (== propagated across the userns boundary), it will remain stuck to its parent.