Prev: [PATCH 10/38] whiteout: Split of ext2_append_link() from ext2_add_link()
Next: [PATCH 20/38] union-mount: Free union dirs on removal from dcache
From: Valerie Aurora on 6 Aug 2010 18:50 Add comments describing what the directions "up" and "down" mean and ref count handling to the VFS follow_mount() family of functions. Signed-off-by: Valerie Aurora <vaurora(a)redhat.com> Cc: Alexander Viro <viro(a)zeniv.linux.org.uk> --- fs/namei.c | 43 +++++++++++++++++++++++++++++++++++++++---- fs/namespace.c | 16 ++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 868d0cb..fd6df0d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -597,6 +597,17 @@ loop: return err; } +/* + * follow_up - Find the mountpoint of path's vfsmount + * + * Given a path, find the mountpoint of its source file system. + * Replace @path with the path of the mountpoint in the parent mount. + * Up is towards /. + * + * Return 1 if we went up a level and 0 if we were already at the + * root. + */ + int follow_up(struct path *path) { struct vfsmount *parent; @@ -617,8 +628,22 @@ int follow_up(struct path *path) return 1; } -/* no need for dcache_lock, as serialization is taken care in - * namespace.c +/* + * __follow_mount - Return the most recent mount at this mountpoint + * + * Given a mountpoint, find the most recently mounted file system at + * this mountpoint and return the path to its root dentry. This is + * the file system that is visible, and it is in the direction of VFS + * "down" - away from the root of the mount tree. See comments to + * lookup_mnt() for an example of "down." + * + * Does not decrement the refcount on the given mount even if it + * follows it to another mount and returns that path instead. + * + * Returns 0 if path was unchanged, 1 if we followed it to another mount. + * + * No need for dcache_lock, as serialization is taken care in + * namespace.c. */ static int __follow_mount(struct path *path) { @@ -637,6 +662,12 @@ static int __follow_mount(struct path *path) return res; } +/* + * Like __follow_mount, but no return value and drops references to + * both mnt and dentry of the given path if it follows to another + * mount. + */ + static void follow_mount(struct path *path) { while (d_mountpoint(path->dentry)) { @@ -650,8 +681,12 @@ static void follow_mount(struct path *path) } } -/* no need for dcache_lock, as serialization is taken care in - * namespace.c +/* + * Like follow_mount(), but traverses only one layer instead of + * continuing until it runs out. + * + * No need for dcache_lock, as serialization is taken care in + * namespace.c. */ int follow_down(struct path *path) { diff --git a/fs/namespace.c b/fs/namespace.c index 88058de..b8a66db 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -433,8 +433,20 @@ struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, } /* - * lookup_mnt increments the ref count before returning - * the vfsmount struct. + * lookup_mnt - Return the first child mount mounted at path + * + * "First" means first mounted chronologically. If you create the + * following mounts: + * + * mount /dev/sda1 /mnt + * mount /dev/sda2 /mnt + * mount /dev/sda3 /mnt + * + * Then lookup_mnt() on the base /mnt dentry in the root mount will + * return successively the root dentry and vfsmount of /dev/sda1, then + * /dev/sda2, then /dev/sda3, then NULL. + * + * lookup_mnt takes a reference to the found vfsmount. */ struct vfsmount *lookup_mnt(struct path *path) { -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |