Re: [PATCHES v2][RFC][CFR] mount-related stuff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/6/25 18:58, Ian Kent wrote:
On 25/6/25 15:57, Al Viro wrote:
On Tue, Jun 24, 2025 at 02:48:53PM +0800, Ian Kent wrote:

+    for (p = mnt; p; p = next_mnt(p, mnt)) {
+        unsigned int f = 0;
+
+        if (p->mnt_mountpoint != mnt->mnt.mnt_root) {
???  The loop goes over everything mounted on mnt, no matter how
deep it is.  Do you mean "p is mounted on the root of its parent",
or is it "p is mounted on some mount of the same fs, with mountpoint
that just happens to be equal to root dentry of mnt (which may be
not the mount p is mounted on)"?

I was trying to check if p is not covered but that's not what it does.



+        /* p is a covering mnt, need to check if p or any of its
+         * children are in use. A reference to p is not held so
+         * don't pass TREE_BUSY_REFERENCED to the propagation
+         * helper.
+         */
... so for these you keep walking through the subtree on them (nevermind
that outer loop will walk it as well)...

+        for (q = p; q; q = next_mnt(q, p)) {
+            if (propagate_mount_tree_busy(q, f)) {
+                busy = true;
+                break;
+            }
... and yet you still keep going in the outer loop?  Confused...

Yes, I've not got this right at all.


      }
      unlock_mount_hash();
+    up_read(&namespace_sem);
+ * count greater than the minimum reference count (ie. are in use).
+ */
+int propagate_mount_tree_busy(struct mount *mnt, unsigned int flags)
+{
+    struct mount *m;
+    struct mount *parent = mnt->mnt_parent;
+    int refcnt = flags & TREE_BUSY_REFERENCED ? 2 : 1;
+
+    if (do_refcount_check(mnt, refcnt))
+        return 1;
+
+    for (m = propagation_next(parent, parent); m;
+            m = propagation_next(m, parent)) {
+        struct mount *child;
+
+        child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint);
+        if (!child)
+            continue;
+
+        if (do_refcount_check(child, 1))
+            return 1;
+    }
+    return 0;
+}
What is the daemon expected to do with your subtree?  Take it apart with
a series of sync (== non-lazy) umount(2)?  I presume it is normal for
it to run into -EBUSY halfway through - i.e. get rid of some, but not
all of the subtree, right?

All I need is to check if a mount and its children are in use, essentially

check if a mount subtree is in use in some way, working directory or open

file(s).


I think what I should be doing is very similar to what may_umount() does but

for the passed in mount and it's children with the adjustment for the ref held

on the passed in mount.


I rather like your implementation of may_umount() and propagate_mount_busy().

I think the only difference to what I need is that the passed in mount won't be

the global root and will usually have children (so I'd invert that list_empty()

check or leave it out for this check).


I'll have a go at that refactor and post it, we'll see if I can come up with

something acceptable.


The other difficulty is that automount can be run in a separate mount namespace

(eg. a container) which introduces a special case environment. I'm not sure how

the propagation will behave in this case. Atm. I'm thinking it might be sufficient

to just use what may_umount_tree() is now so it deliberately only checks the mount

tree in it's own namespace.


So I clearly got this wrong so I've started over.

Unfortunately it looks like I have found a bug so I can get to the checking the propagation

slave behaviors I want to work on.


The "unshare -m" command will create a shell with a new mount namespace that is propagation

private.


If I mount something in the origin mount namespace and then run the unshare command it is

included in the new namespace.


But, with the series here, it looks like if I set my woring directory to this mount in the

new namespace and then umount the above mount in the origin namespace the umount gets propagated

to the created propagation private namespace and without regard for the process working directory.


The behavior in earlier kernels is the mount remains requiring it be umounted in the namespace

or be dissolved on namespace destruction.


Ian





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux