Skip to content

Commit 19ac817

Browse files
author
Al Viro
committed
fs/namespace.c: sanitize descriptions for {__,}lookup_mnt()
Comments regarding "shadow mounts" were stale - no such thing anymore. Document the locking requirements for __lookup_mnt(). Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent fc812c4 commit 19ac817

1 file changed

Lines changed: 12 additions & 29 deletions

File tree

fs/namespace.c

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -825,24 +825,16 @@ static bool legitimize_mnt(struct vfsmount *bastard, unsigned seq)
825825
}
826826

827827
/**
828-
* __lookup_mnt - find first child mount
828+
* __lookup_mnt - mount hash lookup
829829
* @mnt: parent mount
830-
* @dentry: mountpoint
830+
* @dentry: dentry of mountpoint
831831
*
832-
* If @mnt has a child mount @c mounted @dentry find and return it.
832+
* If @mnt has a child mount @c mounted on @dentry find and return it.
833+
* Caller must either hold the spinlock component of @mount_lock or
834+
* hold rcu_read_lock(), sample the seqcount component before the call
835+
* and recheck it afterwards.
833836
*
834-
* Note that the child mount @c need not be unique. There are cases
835-
* where shadow mounts are created. For example, during mount
836-
* propagation when a source mount @mnt whose root got overmounted by a
837-
* mount @o after path lookup but before @namespace_sem could be
838-
* acquired gets copied and propagated. So @mnt gets copied including
839-
* @o. When @mnt is propagated to a destination mount @d that already
840-
* has another mount @n mounted at the same mountpoint then the source
841-
* mount @mnt will be tucked beneath @n, i.e., @n will be mounted on
842-
* @mnt and @mnt mounted on @d. Now both @n and @o are mounted at @mnt
843-
* on @dentry.
844-
*
845-
* Return: The first child of @mnt mounted @dentry or NULL.
837+
* Return: The child of @mnt mounted on @dentry or %NULL.
846838
*/
847839
struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
848840
{
@@ -855,21 +847,12 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
855847
return NULL;
856848
}
857849

858-
/*
859-
* lookup_mnt - Return the first child mount mounted at path
860-
*
861-
* "First" means first mounted chronologically. If you create the
862-
* following mounts:
863-
*
864-
* mount /dev/sda1 /mnt
865-
* mount /dev/sda2 /mnt
866-
* mount /dev/sda3 /mnt
867-
*
868-
* Then lookup_mnt() on the base /mnt dentry in the root mount will
869-
* return successively the root dentry and vfsmount of /dev/sda1, then
870-
* /dev/sda2, then /dev/sda3, then NULL.
850+
/**
851+
* lookup_mnt - Return the child mount mounted at given location
852+
* @path: location in the namespace
871853
*
872-
* lookup_mnt takes a reference to the found vfsmount.
854+
* Acquires and returns a new reference to mount at given location
855+
* or %NULL if nothing is mounted there.
873856
*/
874857
struct vfsmount *lookup_mnt(const struct path *path)
875858
{

0 commit comments

Comments
 (0)