lkml.org 
[lkml]   [2010]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 27/34] union-mount: Basic infrastructure of __union_lookup()
    Date
    Create a very simple version of union lookup.  This patch only looks
    up the target in each layer of the union but does not process it in
    any way. Patches to do whiteouts, etc. follow.

    Signed-off-by: Valerie Aurora <vaurora@redhat.com>
    ---
    fs/namei.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    1 files changed, 68 insertions(+), 0 deletions(-)

    diff --git a/fs/namei.c b/fs/namei.c
    index 2de4378..8373463 100644
    --- a/fs/namei.c
    +++ b/fs/namei.c
    @@ -724,6 +724,74 @@ static __always_inline void follow_dotdot(struct nameidata *nd)
    follow_mount(&nd->path);
    }

    +static struct dentry *__lookup_hash(struct qstr *name, struct dentry *base,
    + struct nameidata *nd);
    +
    +/*
    + * __lookup_union - Lookup and build union stack
    + *
    + * @nd - nameidata for the parent of @topmost
    + * @name - name of target
    + * @topmost - path of the target on the topmost file system
    + *
    + * Do the "union" part of lookup for @topmost - that is, look it up in
    + * the lower layers of its parent directory's union stack. If
    + * @topmost is a directory, build its union stack. @topmost is the
    + * path of the target in the topmost layer of the union file system.
    + * It is either a directory or a negative (non-whiteout) dentry.
    + * @topmost and its parent must have passed the needs_union_lookup()
    + * test.
    + *
    + * This function may stomp nd->path with the path of the parent
    + * directory of the lower layers, so the caller must save nd->path and
    + * restore it afterwards.
    + */
    +
    +static int __lookup_union(struct nameidata *nd, struct qstr *name,
    + struct path *topmost)
    +{
    + struct path lower, parent = nd->path;
    + struct path *path;
    + unsigned int i, layers = parent.dentry->d_sb->s_union_count;
    + int err = 0;
    +
    + /*
    + * Note: This loop iterates through the union stack of the
    + * parent of the target, not the target itself. This function
    + * builds the union stack of the target (if any). The union
    + * stack of the root directory is built at mount.
    + */
    + for (i = 0; i < layers; i++) {
    + /*
    + * Get the parent directory for this layer and lookup
    + * the target in it.
    + */
    + path = union_find_dir(parent.dentry, i);
    + if (!path->mnt)
    + continue;
    +
    + nd->path = *path;
    + lower.mnt = mntget(nd->path.mnt);
    + mutex_lock(&nd->path.dentry->d_inode->i_mutex);
    + lower.dentry = __lookup_hash(name, nd->path.dentry, nd);
    + mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
    +
    + if (IS_ERR(lower.dentry)) {
    + mntput(lower.mnt);
    + err = PTR_ERR(lower.dentry);
    + goto out_err;
    + }
    + /* XXX - do nothing, lookup rule processing in later patches */
    + path_put(&lower);
    + }
    + return 0;
    +
    +out_err:
    + d_free_unions(topmost->dentry);
    + path_put(&lower);
    + return err;
    +}
    +
    /*
    * It's more convoluted than I'd like it to be, but... it's still fairly
    * small and for now I'd prefer to have fast path as straight as possible.
    --
    1.6.3.3


    \
     
     \ /
      Last update: 2010-09-17 00:21    [W:2.316 / U:0.136 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site