]> www.infradead.org Git - users/hch/misc.git/commitdiff
open_detached_copy(): don't bother with mount_lock_hash()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 26 Aug 2025 20:53:42 +0000 (16:53 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 16 Sep 2025 01:26:44 +0000 (21:26 -0400)
we are holding namespace_sem and a reference to root of tree;
iterating through that tree does not need mount_lock.  Neither
does the insertion into the rbtree of new namespace or incrementing
the mount count of that namespace.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c

index 7489c9c716c62319c793d1346a485a22551518a2..468ae0cb475e8611877f9106e68acbf74ccf73af 100644 (file)
@@ -3080,14 +3080,12 @@ static struct file *open_detached_copy(struct path *path, bool recursive)
                return ERR_CAST(mnt);
        }
 
-       lock_mount_hash();
        for (p = mnt; p; p = next_mnt(p, mnt)) {
                mnt_add_to_ns(ns, p);
                ns->nr_mounts++;
        }
        ns->root = mnt;
        mntget(&mnt->mnt);
-       unlock_mount_hash();
        namespace_unlock();
 
        mntput(path->mnt);