]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/namei.c
namei: uninline set_root{,_rcu}()
[karo-tx-linux.git] / fs / namei.c
index b57400ca6a0fc609b8f5024e3dd45d7d8b798f43..177934c79a0456b0790e934e0db044c3ac5f4a6c 100644 (file)
@@ -495,22 +495,20 @@ EXPORT_SYMBOL(path_put);
 #define EMBEDDED_LEVELS 2
 struct nameidata {
        struct path     path;
-       union {
-               struct qstr     last;
-               struct path     link;
-       };
+       struct qstr     last;
        struct path     root;
        struct inode    *inode; /* path.dentry.d_inode */
        unsigned int    flags;
-       unsigned        seq, m_seq;
+       unsigned        seq, m_seq, root_seq;
        int             last_type;
        unsigned        depth;
        int             total_link_count;
-       struct file     *base;
        struct saved {
                struct path link;
                void *cookie;
                const char *name;
+               struct inode *inode;
+               unsigned seq;
        } *stack, internal[EMBEDDED_LEVELS];
 };
 
@@ -538,10 +536,19 @@ static void restore_nameidata(struct nameidata *old)
 
 static int __nd_alloc_stack(struct nameidata *nd)
 {
-       struct saved *p = kmalloc(MAXSYMLINKS * sizeof(struct saved),
+       struct saved *p;
+
+       if (nd->flags & LOOKUP_RCU) {
+               p= kmalloc(MAXSYMLINKS * sizeof(struct saved),
+                                 GFP_ATOMIC);
+               if (unlikely(!p))
+                       return -ECHILD;
+       } else {
+               p= kmalloc(MAXSYMLINKS * sizeof(struct saved),
                                  GFP_KERNEL);
-       if (unlikely(!p))
-               return -ENOMEM;
+               if (unlikely(!p))
+                       return -ENOMEM;
+       }
        memcpy(p, nd->internal, sizeof(nd->internal));
        nd->stack = p;
        return 0;
@@ -556,6 +563,68 @@ static inline int nd_alloc_stack(struct nameidata *nd)
        return __nd_alloc_stack(nd);
 }
 
+static void drop_links(struct nameidata *nd)
+{
+       int i = nd->depth;
+       while (i--) {
+               struct saved *last = nd->stack + i;
+               struct inode *inode = last->inode;
+               if (last->cookie && inode->i_op->put_link) {
+                       inode->i_op->put_link(inode, last->cookie);
+                       last->cookie = NULL;
+               }
+       }
+}
+
+static void terminate_walk(struct nameidata *nd)
+{
+       drop_links(nd);
+       if (!(nd->flags & LOOKUP_RCU)) {
+               int i;
+               path_put(&nd->path);
+               for (i = 0; i < nd->depth; i++)
+                       path_put(&nd->stack[i].link);
+       } else {
+               nd->flags &= ~LOOKUP_RCU;
+               if (!(nd->flags & LOOKUP_ROOT))
+                       nd->root.mnt = NULL;
+               rcu_read_unlock();
+       }
+       nd->depth = 0;
+}
+
+/* path_put is needed afterwards regardless of success or failure */
+static bool legitimize_path(struct nameidata *nd,
+                           struct path *path, unsigned seq)
+{
+       int res = __legitimize_mnt(path->mnt, nd->m_seq);
+       if (unlikely(res)) {
+               if (res > 0)
+                       path->mnt = NULL;
+               path->dentry = NULL;
+               return false;
+       }
+       if (unlikely(!lockref_get_not_dead(&path->dentry->d_lockref))) {
+               path->dentry = NULL;
+               return false;
+       }
+       return !read_seqcount_retry(&path->dentry->d_seq, seq);
+}
+
+static bool legitimize_links(struct nameidata *nd)
+{
+       int i;
+       for (i = 0; i < nd->depth; i++) {
+               struct saved *last = nd->stack + i;
+               if (unlikely(!legitimize_path(nd, &last->link, last->seq))) {
+                       drop_links(nd);
+                       nd->depth = i + 1;
+                       return false;
+               }
+       }
+       return true;
+}
+
 /*
  * Path walking has 2 modes, rcu-walk and ref-walk (see
  * Documentation/filesystems/path-lookup.txt).  In situations when we can't
@@ -571,35 +640,28 @@ static inline int nd_alloc_stack(struct nameidata *nd)
  * unlazy_walk - try to switch to ref-walk mode.
  * @nd: nameidata pathwalk data
  * @dentry: child of nd->path.dentry or NULL
+ * @seq: seq number to check dentry against
  * Returns: 0 on success, -ECHILD on failure
  *
  * unlazy_walk attempts to legitimize the current nd->path, nd->root and dentry
  * for ref-walk mode.  @dentry must be a path found by a do_lookup call on
  * @nd or NULL.  Must be called from rcu-walk context.
+ * Nothing should touch nameidata between unlazy_walk() failure and
+ * terminate_walk().
  */
-static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
+static int unlazy_walk(struct nameidata *nd, struct dentry *dentry, unsigned seq)
 {
-       struct fs_struct *fs = current->fs;
        struct dentry *parent = nd->path.dentry;
 
        BUG_ON(!(nd->flags & LOOKUP_RCU));
 
-       /*
-        * After legitimizing the bastards, terminate_walk()
-        * will do the right thing for non-RCU mode, and all our
-        * subsequent exit cases should rcu_read_unlock()
-        * before returning.  Do vfsmount first; if dentry
-        * can't be legitimized, just set nd->path.dentry to NULL
-        * and rely on dput(NULL) being a no-op.
-        */
-       if (!legitimize_mnt(nd->path.mnt, nd->m_seq))
-               return -ECHILD;
        nd->flags &= ~LOOKUP_RCU;
-
-       if (!lockref_get_not_dead(&parent->d_lockref)) {
-               nd->path.dentry = NULL; 
-               goto out;
-       }
+       if (unlikely(!legitimize_links(nd)))
+               goto out2;
+       if (unlikely(!legitimize_mnt(nd->path.mnt, nd->m_seq)))
+               goto out2;
+       if (unlikely(!lockref_get_not_dead(&parent->d_lockref)))
+               goto out1;
 
        /*
         * For a negative lookup, the lookup sequence point is the parents
@@ -619,7 +681,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
        } else {
                if (!lockref_get_not_dead(&dentry->d_lockref))
                        goto out;
-               if (read_seqcount_retry(&dentry->d_seq, nd->seq))
+               if (read_seqcount_retry(&dentry->d_seq, seq))
                        goto drop_dentry;
        }
 
@@ -628,22 +690,24 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
         * still valid and get it if required.
         */
        if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) {
-               spin_lock(&fs->lock);
-               if (nd->root.mnt != fs->root.mnt || nd->root.dentry != fs->root.dentry)
-                       goto unlock_and_drop_dentry;
-               path_get(&nd->root);
-               spin_unlock(&fs->lock);
+               if (unlikely(!legitimize_path(nd, &nd->root, nd->root_seq))) {
+                       rcu_read_unlock();
+                       dput(dentry);
+                       return -ECHILD;
+               }
        }
 
        rcu_read_unlock();
        return 0;
 
-unlock_and_drop_dentry:
-       spin_unlock(&fs->lock);
 drop_dentry:
        rcu_read_unlock();
        dput(dentry);
        goto drop_root_mnt;
+out2:
+       nd->path.mnt = NULL;
+out1:
+       nd->path.dentry = NULL;
 out:
        rcu_read_unlock();
 drop_root_mnt:
@@ -652,6 +716,24 @@ drop_root_mnt:
        return -ECHILD;
 }
 
+static int unlazy_link(struct nameidata *nd, struct path *link, unsigned seq)
+{
+       if (unlikely(!legitimize_path(nd, link, seq))) {
+               drop_links(nd);
+               nd->depth = 0;
+               nd->flags &= ~LOOKUP_RCU;
+               nd->path.mnt = NULL;
+               nd->path.dentry = NULL;
+               if (!(nd->flags & LOOKUP_ROOT))
+                       nd->root.mnt = NULL;
+               rcu_read_unlock();
+       } else if (likely(unlazy_walk(nd, NULL, 0)) == 0) {
+               return 0;
+       }
+       path_put(link);
+       return -ECHILD;
+}
+
 static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
 {
        return dentry->d_op->d_revalidate(dentry, flags);
@@ -673,26 +755,10 @@ static int complete_walk(struct nameidata *nd)
        int status;
 
        if (nd->flags & LOOKUP_RCU) {
-               nd->flags &= ~LOOKUP_RCU;
                if (!(nd->flags & LOOKUP_ROOT))
                        nd->root.mnt = NULL;
-
-               if (!legitimize_mnt(nd->path.mnt, nd->m_seq)) {
-                       rcu_read_unlock();
+               if (unlikely(unlazy_walk(nd, NULL, 0)))
                        return -ECHILD;
-               }
-               if (unlikely(!lockref_get_not_dead(&dentry->d_lockref))) {
-                       rcu_read_unlock();
-                       mntput(nd->path.mnt);
-                       return -ECHILD;
-               }
-               if (read_seqcount_retry(&dentry->d_seq, nd->seq)) {
-                       rcu_read_unlock();
-                       dput(dentry);
-                       mntput(nd->path.mnt);
-                       return -ECHILD;
-               }
-               rcu_read_unlock();
        }
 
        if (likely(!(nd->flags & LOOKUP_JUMPED)))
@@ -708,26 +774,25 @@ static int complete_walk(struct nameidata *nd)
        if (!status)
                status = -ESTALE;
 
-       path_put(&nd->path);
        return status;
 }
 
-static __always_inline void set_root(struct nameidata *nd)
+static void set_root(struct nameidata *nd)
 {
        get_fs_root(current->fs, &nd->root);
 }
 
-static __always_inline unsigned set_root_rcu(struct nameidata *nd)
+static unsigned set_root_rcu(struct nameidata *nd)
 {
        struct fs_struct *fs = current->fs;
-       unsigned seq, res;
+       unsigned seq;
 
        do {
                seq = read_seqcount_begin(&fs->seq);
                nd->root = fs->root;
-               res = __read_seqcount_begin(&nd->root.dentry->d_seq);
+               nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq);
        } while (read_seqcount_retry(&fs->seq, seq));
-       return res;
+       return nd->root_seq;
 }
 
 static void path_put_conditional(struct path *path, struct nameidata *nd)
@@ -753,8 +818,9 @@ static inline void path_to_nameidata(const struct path *path,
  * Helper to directly jump to a known parsed path from ->follow_link,
  * caller must have taken a reference to path beforehand.
  */
-void nd_jump_link(struct nameidata *nd, struct path *path)
+void nd_jump_link(struct path *path)
 {
+       struct nameidata *nd = current->nameidata;
        path_put(&nd->path);
 
        nd->path = *path;
@@ -765,10 +831,11 @@ void nd_jump_link(struct nameidata *nd, struct path *path)
 static inline void put_link(struct nameidata *nd)
 {
        struct saved *last = nd->stack + --nd->depth;
-       struct inode *inode = last->link.dentry->d_inode;
+       struct inode *inode = last->inode;
        if (last->cookie && inode->i_op->put_link)
-               inode->i_op->put_link(last->link.dentry, last->cookie);
-       path_put(&last->link);
+               inode->i_op->put_link(inode, last->cookie);
+       if (!(nd->flags & LOOKUP_RCU))
+               path_put(&last->link);
 }
 
 int sysctl_protected_symlinks __read_mostly = 0;
@@ -776,7 +843,6 @@ int sysctl_protected_hardlinks __read_mostly = 0;
 
 /**
  * may_follow_link - Check symlink following for unsafe situations
- * @link: The path of the symlink
  * @nd: nameidata pathwalk data
  *
  * In the case of the sysctl_protected_symlinks sysctl being enabled,
@@ -790,7 +856,7 @@ int sysctl_protected_hardlinks __read_mostly = 0;
  *
  * Returns 0 if following the symlink is allowed, -ve on error.
  */
-static inline int may_follow_link(struct path *link, struct nameidata *nd)
+static inline int may_follow_link(struct nameidata *nd)
 {
        const struct inode *inode;
        const struct inode *parent;
@@ -799,7 +865,7 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
                return 0;
 
        /* Allowed if owner and follower match. */
-       inode = link->dentry->d_inode;
+       inode = nd->stack[0].inode;
        if (uid_eq(current_cred()->fsuid, inode->i_uid))
                return 0;
 
@@ -812,9 +878,10 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
        if (uid_eq(parent->i_uid, inode->i_uid))
                return 0;
 
-       audit_log_link_denied("follow_link", link);
-       path_put_conditional(link, nd);
-       path_put(&nd->path);
+       if (nd->flags & LOOKUP_RCU)
+               return -ECHILD;
+
+       audit_log_link_denied("follow_link", &nd->stack[0].link);
        return -EACCES;
 }
 
@@ -890,58 +957,67 @@ static int may_linkat(struct path *link)
 static __always_inline
 const char *get_link(struct nameidata *nd)
 {
-       struct saved *last = nd->stack + nd->depth;
-       struct dentry *dentry = nd->link.dentry;
-       struct inode *inode = dentry->d_inode;
+       struct saved *last = nd->stack + nd->depth - 1;
+       struct dentry *dentry = last->link.dentry;
+       struct inode *inode = last->inode;
        int error;
        const char *res;
 
-       BUG_ON(nd->flags & LOOKUP_RCU);
-
-       if (nd->link.mnt == nd->path.mnt)
-               mntget(nd->link.mnt);
-
-       last->link = nd->link;
-       last->cookie = NULL;
-
-       cond_resched();
-
-       touch_atime(&last->link);
+       if (!(nd->flags & LOOKUP_RCU)) {
+               touch_atime(&last->link);
+               cond_resched();
+       } else if (atime_needs_update(&last->link, inode)) {
+               if (unlikely(unlazy_walk(nd, NULL, 0)))
+                       return ERR_PTR(-ECHILD);
+               touch_atime(&last->link);
+       }
 
-       error = security_inode_follow_link(dentry);
-       res = ERR_PTR(error);
-       if (error)
-               goto out;
+       error = security_inode_follow_link(dentry, inode,
+                                          nd->flags & LOOKUP_RCU);
+       if (unlikely(error))
+               return ERR_PTR(error);
 
        nd->last_type = LAST_BIND;
        res = inode->i_link;
        if (!res) {
-               res = inode->i_op->follow_link(dentry, &last->cookie, nd);
-               if (IS_ERR(res)) {
-out:
-                       path_put(&last->link);
+               if (nd->flags & LOOKUP_RCU) {
+                       if (unlikely(unlazy_walk(nd, NULL, 0)))
+                               return ERR_PTR(-ECHILD);
+               }
+               res = inode->i_op->follow_link(dentry, &last->cookie);
+               if (IS_ERR_OR_NULL(res)) {
+                       last->cookie = NULL;
                        return res;
                }
        }
-       nd->depth++;
+       if (*res == '/') {
+               if (nd->flags & LOOKUP_RCU) {
+                       struct dentry *d;
+                       if (!nd->root.mnt)
+                               set_root_rcu(nd);
+                       nd->path = nd->root;
+                       d = nd->path.dentry;
+                       nd->inode = d->d_inode;
+                       nd->seq = nd->root_seq;
+                       if (unlikely(read_seqcount_retry(&d->d_seq, nd->seq)))
+                               return ERR_PTR(-ECHILD);
+               } else {
+                       if (!nd->root.mnt)
+                               set_root(nd);
+                       path_put(&nd->path);
+                       nd->path = nd->root;
+                       path_get(&nd->root);
+                       nd->inode = nd->path.dentry->d_inode;
+               }
+               nd->flags |= LOOKUP_JUMPED;
+               while (unlikely(*++res == '/'))
+                       ;
+       }
+       if (!*res)
+               res = NULL;
        return res;
 }
 
-static int follow_up_rcu(struct path *path)
-{
-       struct mount *mnt = real_mount(path->mnt);
-       struct mount *parent;
-       struct dentry *mountpoint;
-
-       parent = mnt->mnt_parent;
-       if (&parent->mnt == path->mnt)
-               return 0;
-       mountpoint = mnt->mnt_mountpoint;
-       path->dentry = mountpoint;
-       path->mnt = &parent->mnt;
-       return 1;
-}
-
 /*
  * follow_up - Find the mountpoint of path's vfsmount
  *
@@ -1152,7 +1228,7 @@ static inline int managed_dentry_rcu(struct dentry *dentry)
  * we meet a managed dentry that would need blocking.
  */
 static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
-                              struct inode **inode)
+                              struct inode **inode, unsigned *seqp)
 {
        for (;;) {
                struct mount *mounted;
@@ -1179,7 +1255,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
                path->mnt = &mounted->mnt;
                path->dentry = mounted->mnt.mnt_root;
                nd->flags |= LOOKUP_JUMPED;
-               nd->seq = read_seqcount_begin(&path->dentry->d_seq);
+               *seqp = read_seqcount_begin(&path->dentry->d_seq);
                /*
                 * Update the inode too. We don't need to re-check the
                 * dentry sequence number here after this d_inode read,
@@ -1198,10 +1274,8 @@ static int follow_dotdot_rcu(struct nameidata *nd)
                set_root_rcu(nd);
 
        while (1) {
-               if (nd->path.dentry == nd->root.dentry &&
-                   nd->path.mnt == nd->root.mnt) {
+               if (path_equal(&nd->path, &nd->root))
                        break;
-               }
                if (nd->path.dentry != nd->path.mnt->mnt_root) {
                        struct dentry *old = nd->path.dentry;
                        struct dentry *parent = old->d_parent;
@@ -1209,34 +1283,42 @@ static int follow_dotdot_rcu(struct nameidata *nd)
 
                        inode = parent->d_inode;
                        seq = read_seqcount_begin(&parent->d_seq);
-                       if (read_seqcount_retry(&old->d_seq, nd->seq))
-                               goto failed;
+                       if (unlikely(read_seqcount_retry(&old->d_seq, nd->seq)))
+                               return -ECHILD;
                        nd->path.dentry = parent;
                        nd->seq = seq;
                        break;
+               } else {
+                       struct mount *mnt = real_mount(nd->path.mnt);
+                       struct mount *mparent = mnt->mnt_parent;
+                       struct dentry *mountpoint = mnt->mnt_mountpoint;
+                       struct inode *inode2 = mountpoint->d_inode;
+                       unsigned seq = read_seqcount_begin(&mountpoint->d_seq);
+                       if (unlikely(read_seqretry(&mount_lock, nd->m_seq)))
+                               return -ECHILD;
+                       if (&mparent->mnt == nd->path.mnt)
+                               break;
+                       /* we know that mountpoint was pinned */
+                       nd->path.dentry = mountpoint;
+                       nd->path.mnt = &mparent->mnt;
+                       inode = inode2;
+                       nd->seq = seq;
                }
-               if (!follow_up_rcu(&nd->path))
-                       break;
-               inode = nd->path.dentry->d_inode;
-               nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
        }
-       while (d_mountpoint(nd->path.dentry)) {
+       while (unlikely(d_mountpoint(nd->path.dentry))) {
                struct mount *mounted;
                mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry);
+               if (unlikely(read_seqretry(&mount_lock, nd->m_seq)))
+                       return -ECHILD;
                if (!mounted)
                        break;
                nd->path.mnt = &mounted->mnt;
                nd->path.dentry = mounted->mnt.mnt_root;
                inode = nd->path.dentry->d_inode;
                nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
-               if (read_seqretry(&mount_lock, nd->m_seq))
-                       goto failed;
        }
        nd->inode = inode;
        return 0;
-
-failed:
-       return -ECHILD;
 }
 
 /*
@@ -1415,7 +1497,8 @@ static struct dentry *__lookup_hash(struct qstr *name,
  *  It _is_ time-critical.
  */
 static int lookup_fast(struct nameidata *nd,
-                      struct path *path, struct inode **inode)
+                      struct path *path, struct inode **inode,
+                      unsigned *seqp)
 {
        struct vfsmount *mnt = nd->path.mnt;
        struct dentry *dentry, *parent = nd->path.dentry;
@@ -1439,7 +1522,7 @@ static int lookup_fast(struct nameidata *nd,
                 * This sequence count validates that the inode matches
                 * the dentry name information from lookup.
                 */
-               *inode = dentry->d_inode;
+               *inode = d_backing_inode(dentry);
                negative = d_is_negative(dentry);
                if (read_seqcount_retry(&dentry->d_seq, seq))
                        return -ECHILD;
@@ -1455,8 +1538,8 @@ static int lookup_fast(struct nameidata *nd,
                 */
                if (__read_seqcount_retry(&parent->d_seq, nd->seq))
                        return -ECHILD;
-               nd->seq = seq;
 
+               *seqp = seq;
                if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) {
                        status = d_revalidate(dentry, nd->flags);
                        if (unlikely(status <= 0)) {
@@ -1467,10 +1550,10 @@ static int lookup_fast(struct nameidata *nd,
                }
                path->mnt = mnt;
                path->dentry = dentry;
-               if (likely(__follow_mount_rcu(nd, path, inode)))
+               if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
                        return 0;
 unlazy:
-               if (unlazy_walk(nd, dentry))
+               if (unlazy_walk(nd, dentry, seq))
                        return -ECHILD;
        } else {
                dentry = __d_lookup(parent, &nd->last);
@@ -1499,7 +1582,7 @@ unlazy:
        path->dentry = dentry;
        err = follow_managed(path, nd);
        if (likely(!err))
-               *inode = path->dentry->d_inode;
+               *inode = d_backing_inode(path->dentry);
        return err;
 
 need_lookup:
@@ -1530,7 +1613,7 @@ static inline int may_lookup(struct nameidata *nd)
                int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
                if (err != -ECHILD)
                        return err;
-               if (unlazy_walk(nd, NULL))
+               if (unlazy_walk(nd, NULL, 0))
                        return -ECHILD;
        }
        return inode_permission(nd->inode, MAY_EXEC);
@@ -1547,40 +1630,37 @@ static inline int handle_dots(struct nameidata *nd, int type)
        return 0;
 }
 
-static void terminate_walk(struct nameidata *nd)
-{
-       if (!(nd->flags & LOOKUP_RCU)) {
-               path_put(&nd->path);
-       } else {
-               nd->flags &= ~LOOKUP_RCU;
-               if (!(nd->flags & LOOKUP_ROOT))
-                       nd->root.mnt = NULL;
-               rcu_read_unlock();
-       }
-       while (unlikely(nd->depth))
-               put_link(nd);
-}
-
-static int pick_link(struct nameidata *nd, struct path *link)
+static int pick_link(struct nameidata *nd, struct path *link,
+                    struct inode *inode, unsigned seq)
 {
        int error;
+       struct saved *last;
        if (unlikely(nd->total_link_count++ >= MAXSYMLINKS)) {
                path_to_nameidata(link, nd);
                return -ELOOP;
        }
-       if (nd->flags & LOOKUP_RCU) {
-               if (unlikely(nd->path.mnt != link->mnt ||
-                            unlazy_walk(nd, link->dentry))) {
-                       return -ECHILD;
-               }
+       if (!(nd->flags & LOOKUP_RCU)) {
+               if (link->mnt == nd->path.mnt)
+                       mntget(link->mnt);
        }
        error = nd_alloc_stack(nd);
        if (unlikely(error)) {
-               path_to_nameidata(link, nd);
-               return error;
+               if (error == -ECHILD) {
+                       if (unlikely(unlazy_link(nd, link, seq)))
+                               return -ECHILD;
+                       error = nd_alloc_stack(nd);
+               }
+               if (error) {
+                       path_put(link);
+                       return error;
+               }
        }
 
-       nd->link = *link;
+       last = nd->stack + nd->depth++;
+       last->link = *link;
+       last->cookie = NULL;
+       last->inode = inode;
+       last->seq = seq;
        return 1;
 }
 
@@ -1590,13 +1670,15 @@ static int pick_link(struct nameidata *nd, struct path *link)
  * so we keep a cache of "no, this doesn't need follow_link"
  * for the common case.
  */
-static inline int should_follow_link(struct nameidata *nd, struct path *link, int follow)
+static inline int should_follow_link(struct nameidata *nd, struct path *link,
+                                    int follow,
+                                    struct inode *inode, unsigned seq)
 {
        if (likely(!d_is_symlink(link->dentry)))
                return 0;
        if (!follow)
                return 0;
-       return pick_link(nd, link);
+       return pick_link(nd, link, inode, seq);
 }
 
 enum {WALK_GET = 1, WALK_PUT = 2};
@@ -1605,6 +1687,7 @@ static int walk_component(struct nameidata *nd, int flags)
 {
        struct path path;
        struct inode *inode;
+       unsigned seq;
        int err;
        /*
         * "." and ".." are special - ".." especially so because it has
@@ -1617,7 +1700,7 @@ static int walk_component(struct nameidata *nd, int flags)
                        put_link(nd);
                return err;
        }
-       err = lookup_fast(nd, &path, &inode);
+       err = lookup_fast(nd, &path, &inode, &seq);
        if (unlikely(err)) {
                if (err < 0)
                        return err;
@@ -1626,7 +1709,8 @@ static int walk_component(struct nameidata *nd, int flags)
                if (err < 0)
                        return err;
 
-               inode = path.dentry->d_inode;
+               inode = d_backing_inode(path.dentry);
+               seq = 0;        /* we are already out of RCU mode */
                err = -ENOENT;
                if (d_is_negative(path.dentry))
                        goto out_path_put;
@@ -1634,11 +1718,12 @@ static int walk_component(struct nameidata *nd, int flags)
 
        if (flags & WALK_PUT)
                put_link(nd);
-       err = should_follow_link(nd, &path, flags & WALK_GET);
+       err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq);
        if (unlikely(err))
                return err;
        path_to_nameidata(&path, nd);
        nd->inode = inode;
+       nd->seq = seq;
        return 0;
 
 out_path_put:
@@ -1786,7 +1871,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
 
                err = may_lookup(nd);
                if (err)
-                       break;
+                       return err;
 
                hash_len = hash_name(name);
 
@@ -1808,7 +1893,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
                                struct qstr this = { { .hash_len = hash_len }, .name = name };
                                err = parent->d_op->d_hash(parent, &this);
                                if (err < 0)
-                                       break;
+                                       return err;
                                hash_len = this.hash_len;
                                name = this.name;
                        }
@@ -1830,11 +1915,11 @@ static int link_path_walk(const char *name, struct nameidata *nd)
                } while (unlikely(*name == '/'));
                if (unlikely(!*name)) {
 OK:
-                       /* called from path_init(), done */
+                       /* pathname body, done */
                        if (!nd->depth)
                                return 0;
                        name = nd->stack[nd->depth - 1].name;
-                       /* called from trailing_symlink(), done */
+                       /* trailing symlink, done */
                        if (!name)
                                return 0;
                        /* last component of nested symlink */
@@ -1843,49 +1928,30 @@ OK:
                        err = walk_component(nd, WALK_GET);
                }
                if (err < 0)
-                       break;
+                       return err;
 
                if (err) {
                        const char *s = get_link(nd);
 
-                       if (unlikely(IS_ERR(s))) {
-                               err = PTR_ERR(s);
-                               break;
-                       }
+                       if (unlikely(IS_ERR(s)))
+                               return PTR_ERR(s);
                        err = 0;
                        if (unlikely(!s)) {
                                /* jumped */
                                put_link(nd);
                        } else {
-                               if (*s == '/') {
-                                       if (!nd->root.mnt)
-                                               set_root(nd);
-                                       path_put(&nd->path);
-                                       nd->path = nd->root;
-                                       path_get(&nd->root);
-                                       nd->flags |= LOOKUP_JUMPED;
-                                       while (unlikely(*++s == '/'))
-                                               ;
-                               }
-                               nd->inode = nd->path.dentry->d_inode;
                                nd->stack[nd->depth - 1].name = name;
-                               if (!*s)
-                                       goto OK;
                                name = s;
                                continue;
                        }
                }
-               if (!d_can_lookup(nd->path.dentry)) {
-                       err = -ENOTDIR;
-                       break;
-               }
+               if (unlikely(!d_can_lookup(nd->path.dentry)))
+                       return -ENOTDIR;
        }
-       terminate_walk(nd);
-       return err;
 }
 
-static int path_init(int dfd, const struct filename *name, unsigned int flags,
-                    struct nameidata *nd)
+static const char *path_init(int dfd, const struct filename *name,
+                            unsigned int flags, struct nameidata *nd)
 {
        int retval = 0;
        const char *s = name->name;
@@ -1893,27 +1959,28 @@ static int path_init(int dfd, const struct filename *name, unsigned int flags,
        nd->last_type = LAST_ROOT; /* if there are only slashes... */
        nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT;
        nd->depth = 0;
-       nd->base = NULL;
+       nd->total_link_count = 0;
        if (flags & LOOKUP_ROOT) {
                struct dentry *root = nd->root.dentry;
                struct inode *inode = root->d_inode;
                if (*s) {
                        if (!d_can_lookup(root))
-                               return -ENOTDIR;
+                               return ERR_PTR(-ENOTDIR);
                        retval = inode_permission(inode, MAY_EXEC);
                        if (retval)
-                               return retval;
+                               return ERR_PTR(retval);
                }
                nd->path = nd->root;
                nd->inode = inode;
                if (flags & LOOKUP_RCU) {
                        rcu_read_lock();
                        nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
+                       nd->root_seq = nd->seq;
                        nd->m_seq = read_seqbegin(&mount_lock);
                } else {
                        path_get(&nd->path);
                }
-               goto done;
+               return s;
        }
 
        nd->root.mnt = NULL;
@@ -1949,41 +2016,39 @@ static int path_init(int dfd, const struct filename *name, unsigned int flags,
                struct dentry *dentry;
 
                if (!f.file)
-                       return -EBADF;
+                       return ERR_PTR(-EBADF);
 
                dentry = f.file->f_path.dentry;
 
                if (*s) {
                        if (!d_can_lookup(dentry)) {
                                fdput(f);
-                               return -ENOTDIR;
+                               return ERR_PTR(-ENOTDIR);
                        }
                }
 
                nd->path = f.file->f_path;
                if (flags & LOOKUP_RCU) {
-                       if (f.flags & FDPUT_FPUT)
-                               nd->base = f.file;
-                       nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
                        rcu_read_lock();
+                       nd->inode = nd->path.dentry->d_inode;
+                       nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
                } else {
                        path_get(&nd->path);
-                       fdput(f);
+                       nd->inode = nd->path.dentry->d_inode;
                }
+               fdput(f);
+               return s;
        }
 
        nd->inode = nd->path.dentry->d_inode;
        if (!(flags & LOOKUP_RCU))
-               goto done;
+               return s;
        if (likely(!read_seqcount_retry(&nd->path.dentry->d_seq, nd->seq)))
-               goto done;
+               return s;
        if (!(nd->flags & LOOKUP_ROOT))
                nd->root.mnt = NULL;
        rcu_read_unlock();
-       return -ECHILD;
-done:
-       nd->total_link_count = 0;
-       return link_path_walk(s, nd);
+       return ERR_PTR(-ECHILD);
 }
 
 static void path_cleanup(struct nameidata *nd)
@@ -1992,93 +2057,59 @@ static void path_cleanup(struct nameidata *nd)
                path_put(&nd->root);
                nd->root.mnt = NULL;
        }
-       if (unlikely(nd->base))
-               fput(nd->base);
 }
 
-static int trailing_symlink(struct nameidata *nd)
+static const char *trailing_symlink(struct nameidata *nd)
 {
        const char *s;
-       int error = may_follow_link(&nd->link, nd);
+       int error = may_follow_link(nd);
        if (unlikely(error))
-               return error;
+               return ERR_PTR(error);
        nd->flags |= LOOKUP_PARENT;
-       s = get_link(nd);
-       if (unlikely(IS_ERR(s))) {
-               terminate_walk(nd);
-               return PTR_ERR(s);
-       }
-       if (unlikely(!s))
-               return 0;
-       if (*s == '/') {
-               if (!nd->root.mnt)
-                       set_root(nd);
-               path_put(&nd->path);
-               nd->path = nd->root;
-               path_get(&nd->root);
-               nd->flags |= LOOKUP_JUMPED;
-       }
-       nd->inode = nd->path.dentry->d_inode;
        nd->stack[0].name = NULL;
-       return link_path_walk(s, nd);
+       s = get_link(nd);
+       return s ? s : "";
 }
 
 static inline int lookup_last(struct nameidata *nd)
 {
-       int err;
        if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len])
                nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
 
        nd->flags &= ~LOOKUP_PARENT;
-       err = walk_component(nd,
+       return walk_component(nd,
                        nd->flags & LOOKUP_FOLLOW
                                ? nd->depth
                                        ? WALK_PUT | WALK_GET
                                        : WALK_GET
                                : 0);
-       if (err < 0)
-               terminate_walk(nd);
-       return err;
 }
 
 /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
 static int path_lookupat(int dfd, const struct filename *name,
                                unsigned int flags, struct nameidata *nd)
 {
+       const char *s = path_init(dfd, name, flags, nd);
        int err;
 
-       /*
-        * Path walking is largely split up into 2 different synchronisation
-        * schemes, rcu-walk and ref-walk (explained in
-        * Documentation/filesystems/path-lookup.txt). These share much of the
-        * path walk code, but some things particularly setup, cleanup, and
-        * following mounts are sufficiently divergent that functions are
-        * duplicated. Typically there is a function foo(), and its RCU
-        * analogue, foo_rcu().
-        *
-        * -ECHILD is the error number of choice (just to avoid clashes) that
-        * is returned if some aspect of an rcu-walk fails. Such an error must
-        * be handled by restarting a traditional ref-walk (which will always
-        * be able to complete).
-        */
-       err = path_init(dfd, name, flags, nd);
-       if (!err && !(flags & LOOKUP_PARENT)) {
-               while ((err = lookup_last(nd)) > 0) {
-                       err = trailing_symlink(nd);
-                       if (err)
-                               break;
+       if (IS_ERR(s))
+               return PTR_ERR(s);
+       while (!(err = link_path_walk(s, nd))
+               && ((err = lookup_last(nd)) > 0)) {
+               s = trailing_symlink(nd);
+               if (IS_ERR(s)) {
+                       err = PTR_ERR(s);
+                       break;
                }
        }
-
        if (!err)
                err = complete_walk(nd);
 
-       if (!err && nd->flags & LOOKUP_DIRECTORY) {
-               if (!d_can_lookup(nd->path.dentry)) {
-                       path_put(&nd->path);
+       if (!err && nd->flags & LOOKUP_DIRECTORY)
+               if (!d_can_lookup(nd->path.dentry))
                        err = -ENOTDIR;
-               }
-       }
+       if (err)
+               terminate_walk(nd);
 
        path_cleanup(nd);
        return err;
@@ -2102,6 +2133,41 @@ static int filename_lookup(int dfd, struct filename *name,
        return retval;
 }
 
+/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
+static int path_parentat(int dfd, const struct filename *name,
+                               unsigned int flags, struct nameidata *nd)
+{
+       const char *s = path_init(dfd, name, flags, nd);
+       int err;
+       if (IS_ERR(s))
+               return PTR_ERR(s);
+       err = link_path_walk(s, nd);
+       if (!err)
+               err = complete_walk(nd);
+       if (err)
+               terminate_walk(nd);
+       path_cleanup(nd);
+       return err;
+}
+
+static int filename_parentat(int dfd, struct filename *name,
+                               unsigned int flags, struct nameidata *nd)
+{
+       int retval;
+       struct nameidata *saved_nd = set_nameidata(nd);
+
+       retval = path_parentat(dfd, name, flags | LOOKUP_RCU, nd);
+       if (unlikely(retval == -ECHILD))
+               retval = path_parentat(dfd, name, flags, nd);
+       if (unlikely(retval == -ESTALE))
+               retval = path_parentat(dfd, name, flags | LOOKUP_REVAL, nd);
+
+       if (likely(!retval))
+               audit_inode(name, nd->path.dentry, LOOKUP_PARENT);
+       restore_nameidata(saved_nd);
+       return retval;
+}
+
 /* does lookup, returns the object with parent locked */
 struct dentry *kern_path_locked(const char *name, struct path *path)
 {
@@ -2113,7 +2179,7 @@ struct dentry *kern_path_locked(const char *name, struct path *path)
        if (IS_ERR(filename))
                return ERR_CAST(filename);
 
-       err = filename_lookup(AT_FDCWD, filename, LOOKUP_PARENT, &nd);
+       err = filename_parentat(AT_FDCWD, filename, 0, &nd);
        if (err) {
                d = ERR_PTR(err);
                goto out;
@@ -2283,7 +2349,7 @@ user_path_parent(int dfd, const char __user *path,
        if (IS_ERR(s))
                return s;
 
-       error = filename_lookup(dfd, s, flags | LOOKUP_PARENT, &nd);
+       error = filename_parentat(dfd, s, flags, &nd);
        if (error) {
                putname(s);
                return ERR_PTR(error);
@@ -2331,10 +2397,8 @@ mountpoint_last(struct nameidata *nd, struct path *path)
 
        /* If we're in rcuwalk, drop out of it to handle last component */
        if (nd->flags & LOOKUP_RCU) {
-               if (unlazy_walk(nd, NULL)) {
-                       error = -ECHILD;
-                       goto out;
-               }
+               if (unlazy_walk(nd, NULL, 0))
+                       return -ECHILD;
        }
 
        nd->flags &= ~LOOKUP_PARENT;
@@ -2342,7 +2406,7 @@ mountpoint_last(struct nameidata *nd, struct path *path)
        if (unlikely(nd->last_type != LAST_NORM)) {
                error = handle_dots(nd, nd->last_type);
                if (error)
-                       goto out;
+                       return error;
                dentry = dget(nd->path.dentry);
                goto done;
        }
@@ -2357,41 +2421,33 @@ mountpoint_last(struct nameidata *nd, struct path *path)
                 */
                dentry = d_alloc(dir, &nd->last);
                if (!dentry) {
-                       error = -ENOMEM;
                        mutex_unlock(&dir->d_inode->i_mutex);
-                       goto out;
+                       return -ENOMEM;
                }
                dentry = lookup_real(dir->d_inode, dentry, nd->flags);
-               error = PTR_ERR(dentry);
                if (IS_ERR(dentry)) {
                        mutex_unlock(&dir->d_inode->i_mutex);
-                       goto out;
+                       return PTR_ERR(dentry);
                }
        }
        mutex_unlock(&dir->d_inode->i_mutex);
 
 done:
        if (d_is_negative(dentry)) {
-               error = -ENOENT;
                dput(dentry);
-               goto out;
+               return -ENOENT;
        }
        if (nd->depth)
                put_link(nd);
        path->dentry = dentry;
        path->mnt = nd->path.mnt;
-       error = should_follow_link(nd, path, nd->flags & LOOKUP_FOLLOW);
-       if (unlikely(error)) {
-               if (error < 0)
-                       goto out;
+       error = should_follow_link(nd, path, nd->flags & LOOKUP_FOLLOW,
+                                  d_backing_inode(dentry), 0);
+       if (unlikely(error))
                return error;
-       }
        mntget(path->mnt);
        follow_mount(path);
-       error = 0;
-out:
-       terminate_walk(nd);
-       return error;
+       return 0;
 }
 
 /**
@@ -2408,16 +2464,19 @@ static int
 path_mountpoint(int dfd, const struct filename *name, struct path *path,
                struct nameidata *nd, unsigned int flags)
 {
-       int err = path_init(dfd, name, flags, nd);
-       if (unlikely(err))
-               goto out;
-
-       while ((err = mountpoint_last(nd, path)) > 0) {
-               err = trailing_symlink(nd);
-               if (err)
+       const char *s = path_init(dfd, name, flags, nd);
+       int err;
+       if (IS_ERR(s))
+               return PTR_ERR(s);
+       while (!(err = link_path_walk(s, nd)) &&
+               (err = mountpoint_last(nd, path)) > 0) {
+               s = trailing_symlink(nd);
+               if (IS_ERR(s)) {
+                       err = PTR_ERR(s);
                        break;
+               }
        }
-out:
+       terminate_walk(nd);
        path_cleanup(nd);
        return err;
 }
@@ -2505,7 +2564,7 @@ EXPORT_SYMBOL(__check_sticky);
  */
 static int may_delete(struct inode *dir, struct dentry *victim, bool isdir)
 {
-       struct inode *inode = victim->d_inode;
+       struct inode *inode = d_backing_inode(victim);
        int error;
 
        if (d_is_negative(victim))
@@ -2980,6 +3039,7 @@ static int do_last(struct nameidata *nd,
        bool will_truncate = (open_flag & O_TRUNC) != 0;
        bool got_write = false;
        int acc_mode = op->acc_mode;
+       unsigned seq;
        struct inode *inode;
        struct path save_parent = { .dentry = NULL, .mnt = NULL };
        struct path path;
@@ -2991,10 +3051,8 @@ static int do_last(struct nameidata *nd,
 
        if (nd->last_type != LAST_NORM) {
                error = handle_dots(nd, nd->last_type);
-               if (unlikely(error)) {
-                       terminate_walk(nd);
+               if (unlikely(error))
                        return error;
-               }
                goto finish_open;
        }
 
@@ -3002,12 +3060,12 @@ static int do_last(struct nameidata *nd,
                if (nd->last.name[nd->last.len])
                        nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
                /* we _can_ be in RCU mode here */
-               error = lookup_fast(nd, &path, &inode);
+               error = lookup_fast(nd, &path, &inode, &seq);
                if (likely(!error))
                        goto finish_lookup;
 
                if (error < 0)
-                       goto out;
+                       return error;
 
                BUG_ON(nd->inode != dir->d_inode);
        } else {
@@ -3018,17 +3076,13 @@ static int do_last(struct nameidata *nd,
                 * about to look up
                 */
                error = complete_walk(nd);
-               if (error) {
-                       if (nd->depth)
-                               put_link(nd);
+               if (error)
                        return error;
-               }
 
                audit_inode(name, dir, LOOKUP_PARENT);
-               error = -EISDIR;
                /* trailing slashes? */
-               if (nd->last.name[nd->last.len])
-                       goto out;
+               if (unlikely(nd->last.name[nd->last.len]))
+                       return -EISDIR;
        }
 
 retry_lookup:
@@ -3083,35 +3137,33 @@ retry_lookup:
                got_write = false;
        }
 
-       error = -EEXIST;
-       if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))
-               goto exit_dput;
+       if (unlikely((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))) {
+               path_to_nameidata(&path, nd);
+               return -EEXIST;
+       }
 
        error = follow_managed(&path, nd);
-       if (error < 0)
-               goto out;
+       if (unlikely(error < 0))
+               return error;
 
        BUG_ON(nd->flags & LOOKUP_RCU);
-       inode = path.dentry->d_inode;
-       error = -ENOENT;
-       if (d_is_negative(path.dentry)) {
+       inode = d_backing_inode(path.dentry);
+       seq = 0;        /* out of RCU mode, so the value doesn't matter */
+       if (unlikely(d_is_negative(path.dentry))) {
                path_to_nameidata(&path, nd);
-               goto out;
+               return -ENOENT;
        }
 finish_lookup:
        if (nd->depth)
                put_link(nd);
-       error = should_follow_link(nd, &path, nd->flags & LOOKUP_FOLLOW);
-       if (unlikely(error)) {
-               if (error < 0)
-                       goto out;
+       error = should_follow_link(nd, &path, nd->flags & LOOKUP_FOLLOW,
+                                  inode, seq);
+       if (unlikely(error))
                return error;
-       }
 
        if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
                path_to_nameidata(&path, nd);
-               error = -ELOOP;
-               goto out;
+               return -ELOOP;
        }
 
        if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) {
@@ -3123,12 +3175,11 @@ finish_lookup:
 
        }
        nd->inode = inode;
+       nd->seq = seq;
        /* Why this, you ask?  _Now_ we might have grown LOOKUP_JUMPED... */
 finish_open:
        error = complete_walk(nd);
        if (error) {
-               if (nd->depth)
-                       put_link(nd);
                path_put(&save_parent);
                return error;
        }
@@ -3179,12 +3230,8 @@ out:
        if (got_write)
                mnt_drop_write(nd->path.mnt);
        path_put(&save_parent);
-       terminate_walk(nd);
        return error;
 
-exit_dput:
-       path_put_conditional(&path, nd);
-       goto out;
 exit_fput:
        fput(file);
        goto out;
@@ -3273,6 +3320,7 @@ out:
 static struct file *path_openat(int dfd, struct filename *pathname,
                struct nameidata *nd, const struct open_flags *op, int flags)
 {
+       const char *s;
        struct file *file;
        int opened = 0;
        int error;
@@ -3288,17 +3336,21 @@ static struct file *path_openat(int dfd, struct filename *pathname,
                goto out2;
        }
 
-       error = path_init(dfd, pathname, flags, nd);
-       if (unlikely(error))
-               goto out;
-
-       while ((error = do_last(nd, file, op, &opened, pathname)) > 0) {
+       s = path_init(dfd, pathname, flags, nd);
+       if (IS_ERR(s)) {
+               put_filp(file);
+               return ERR_CAST(s);
+       }
+       while (!(error = link_path_walk(s, nd)) &&
+               (error = do_last(nd, file, op, &opened, pathname)) > 0) {
                nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL);
-               error = trailing_symlink(nd);
-               if (unlikely(error))
+               s = trailing_symlink(nd);
+               if (IS_ERR(s)) {
+                       error = PTR_ERR(s);
                        break;
+               }
        }
-out:
+       terminate_walk(nd);
        path_cleanup(nd);
 out2:
        if (!(opened & FILE_OPENED)) {
@@ -3377,7 +3429,7 @@ static struct dentry *filename_create(int dfd, struct filename *name,
         */
        lookup_flags &= LOOKUP_REVAL;
 
-       error = filename_lookup(dfd, name, LOOKUP_PARENT|lookup_flags, &nd);
+       error = filename_parentat(dfd, name, lookup_flags, &nd);
        if (error)
                return ERR_PTR(error);
 
@@ -4481,17 +4533,18 @@ EXPORT_SYMBOL(readlink_copy);
 int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
 {
        void *cookie;
-       const char *link = dentry->d_inode->i_link;
+       struct inode *inode = d_inode(dentry);
+       const char *link = inode->i_link;
        int res;
 
        if (!link) {
-               link = dentry->d_inode->i_op->follow_link(dentry, &cookie, NULL);
+               link = inode->i_op->follow_link(dentry, &cookie);
                if (IS_ERR(link))
                        return PTR_ERR(link);
        }
        res = readlink_copy(buffer, buflen, link);
-       if (cookie && dentry->d_inode->i_op->put_link)
-               dentry->d_inode->i_op->put_link(dentry, cookie);
+       if (inode->i_op->put_link)
+               inode->i_op->put_link(inode, cookie);
        return res;
 }
 EXPORT_SYMBOL(generic_readlink);
@@ -4523,7 +4576,7 @@ int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
 }
 EXPORT_SYMBOL(page_readlink);
 
-const char *page_follow_link_light(struct dentry *dentry, void **cookie, struct nameidata *nd)
+const char *page_follow_link_light(struct dentry *dentry, void **cookie)
 {
        struct page *page = NULL;
        char *res = page_getlink(dentry, &page);
@@ -4533,7 +4586,7 @@ const char *page_follow_link_light(struct dentry *dentry, void **cookie, struct
 }
 EXPORT_SYMBOL(page_follow_link_light);
 
-void page_put_link(struct dentry *dentry, void *cookie)
+void page_put_link(struct inode *unused, void *cookie)
 {
        struct page *page = cookie;
        kunmap(page);