ovl: use an auxiliary var for overlay root entry
authorAmir Goldstein <amir73il@gmail.com>
Wed, 26 Apr 2017 20:40:52 +0000 (23:40 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Fri, 5 May 2017 09:38:58 +0000 (11:38 +0200)
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/namei.c

index b8b077821fb03bea9d63b3bf3508039836409e1b..d0a3e4ad3042d2db73aa1af6bfc53f4d9ab32b09 100644 (file)
@@ -220,6 +220,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
        const struct cred *old_cred;
        struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
        struct ovl_entry *poe = dentry->d_parent->d_fsdata;
+       struct ovl_entry *roe = dentry->d_sb->s_root->d_fsdata;
        struct path *stack = NULL;
        struct dentry *upperdir, *upperdentry = NULL;
        unsigned int ctr = 0;
@@ -259,7 +260,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
                        if (!upperredirect)
                                goto out_put_upper;
                        if (d.redirect[0] == '/')
-                               poe = dentry->d_sb->s_root->d_fsdata;
+                               poe = roe;
                }
                upperopaque = d.opaque;
        }
@@ -290,10 +291,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
                if (d.stop)
                        break;
 
-               if (d.redirect &&
-                   d.redirect[0] == '/' &&
-                   poe != dentry->d_sb->s_root->d_fsdata) {
-                       poe = dentry->d_sb->s_root->d_fsdata;
+               if (d.redirect && d.redirect[0] == '/' && poe != roe) {
+                       poe = roe;
 
                        /* Find the current layer on the root dentry */
                        for (i = 0; i < poe->numlower; i++)