From: NeilBrown <[email protected]>

->lookup is now always called with a shared lock and LOOKUP_SHARED set,
so we can discard that flag and remove the code for when it wasn't set.

Signed-off-by: NeilBrown <[email protected]>
---
 fs/afs/dir.c           | 10 ++--------
 fs/dcache.c            | 13 +++----------
 fs/namei.c             | 10 +++++-----
 fs/xfs/xfs_iops.c      |  3 +--
 include/linux/dcache.h |  3 +--
 include/linux/namei.h  |  3 +--
 6 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index f259ca2da383..29e39aeaf654 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -938,10 +938,7 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, 
struct dentry *dentry,
        /* Calling d_alloc_parallel() while holding parent locked is 
undesirable.
         * We don't really need the lock any more.
         */
-       if (flags & LOOKUP_SHARED)
-               inode_unlock_shared(dir);
-       else
-               inode_unlock(dir);
+       inode_unlock_shared(dir);
        for (i = 0; i < subs->nr; i++) {
                name = subs->subs[i];
                len = dentry->d_name.len - 4 + strlen(name);
@@ -966,10 +963,7 @@ static struct dentry *afs_lookup_atsys(struct inode *dir, 
struct dentry *dentry,
         */
        ret = NULL;
 out_s:
-       if (flags & LOOKUP_SHARED)
-               inode_lock_shared(dir);
-       else
-               inode_lock_nested(dir, I_MUTEX_PARENT);
+       inode_lock_shared(dir);
        afs_put_sysnames(subs);
        kfree(buf);
 out_p:
diff --git a/fs/dcache.c b/fs/dcache.c
index f573716d1a04..2d694e14bd22 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2224,7 +2224,6 @@ EXPORT_SYMBOL(d_obtain_root);
  * @dentry: the negative dentry that was passed to the parent's lookup func
  * @inode:  the inode case-insensitive lookup has found
  * @name:   the case-exact name to be associated with the returned dentry
- * @bool:   %true if lookup was performed with LOOKUP_SHARED
  *
  * This is to avoid filling the dcache with case-insensitive names to the
  * same inode, only the actual correct case is stored in the dcache for
@@ -2237,7 +2236,7 @@ EXPORT_SYMBOL(d_obtain_root);
  * the exact case, and return the spliced entry.
  */
 struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
-                       struct qstr *name, bool shared)
+                       struct qstr *name)
 {
        struct dentry *found, *res;
 
@@ -2257,19 +2256,13 @@ struct dentry *d_add_ci(struct dentry *dentry, struct 
inode *inode,
         * d_in_lookup() (so ->d_parent is stable) and we are near the
         * end ->lookup() and will shortly drop the lock anyway.
         */
-       if (shared)
-               inode_unlock_shared(d_inode(dentry->d_parent));
-       else
-               inode_unlock(d_inode(dentry->d_parent));
+       inode_unlock_shared(d_inode(dentry->d_parent));
        found = d_alloc_parallel(dentry->d_parent, name);
        if (IS_ERR(found) || !d_in_lookup(found)) {
                iput(inode);
                return found;
        }
-       if (shared)
-               inode_lock_shared(d_inode(dentry->d_parent));
-       else
-               inode_lock_nested(d_inode(dentry->d_parent), I_MUTEX_PARENT);
+       inode_lock_shared(d_inode(dentry->d_parent));
        res = d_splice_alias(inode, found);
        if (res) {
                d_lookup_done(found);
diff --git a/fs/namei.c b/fs/namei.c
index 3d213070a515..9e2ac3077f72 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1826,7 +1826,7 @@ static struct dentry *lookup_one_qstr(const struct qstr 
*name,
        if (unlikely(IS_DEADDIR(dir)))
                old = ERR_PTR(-ENOENT);
        else
-               old = dir->i_op->lookup(dir, dentry, flags | LOOKUP_SHARED);
+               old = dir->i_op->lookup(dir, dentry, flags);
        inode_unlock_shared(dir);
        if (unlikely(old)) {
                d_lookup_done(dentry);
@@ -1951,7 +1951,7 @@ static struct dentry *__lookup_slow(const struct qstr 
*name,
                        old = ERR_PTR(-ENOENT);
                else
                        old = inode->i_op->lookup(inode, dentry,
-                                                 flags | LOOKUP_SHARED);
+                                                 flags);
                inode_unlock_shared(inode);
                d_lookup_done(dentry);
                if (unlikely(old)) {
@@ -1966,14 +1966,14 @@ static noinline struct dentry *lookup_slow(const struct 
qstr *name,
                                  struct dentry *dir,
                                  unsigned int flags)
 {
-       return __lookup_slow(name, dir, flags | LOOKUP_SHARED, TASK_NORMAL);
+       return __lookup_slow(name, dir, flags, TASK_NORMAL);
 }
 
 static struct dentry *lookup_slow_killable(const struct qstr *name,
                                           struct dentry *dir,
                                           unsigned int flags)
 {
-       return __lookup_slow(name, dir, flags | LOOKUP_SHARED, TASK_KILLABLE);
+       return __lookup_slow(name, dir, flags, TASK_KILLABLE);
 }
 
 static inline int may_lookup(struct mnt_idmap *idmap,
@@ -4513,7 +4513,7 @@ static struct dentry *lookup_open(struct nameidata *nd, 
struct file *file,
                        res = ERR_PTR(-ENOENT);
                else
                        res = dir_inode->i_op->lookup(dir_inode, dentry,
-                                                     nd->flags | 
LOOKUP_SHARED);
+                                                     nd->flags);
                inode_unlock_shared(dir_inode);
                d_lookup_done(dentry);
                if (unlikely(res)) {
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 2641061ba1db..cfd1cb42a29f 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -35,7 +35,6 @@
 #include <linux/security.h>
 #include <linux/iversion.h>
 #include <linux/fiemap.h>
-#include <linux/namei.h> // for LOOKUP_SHARED
 
 /*
  * Directories have different lock order w.r.t. mmap_lock compared to regular
@@ -370,7 +369,7 @@ xfs_vn_ci_lookup(
        /* else case-insensitive match... */
        dname.name = ci_name.name;
        dname.len = ci_name.len;
-       dentry = d_add_ci(dentry, VFS_I(ip), &dname, !!(flags & LOOKUP_SHARED));
+       dentry = d_add_ci(dentry, VFS_I(ip), &dname);
        kfree(ci_name.name);
        return dentry;
 }
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index eb1a59b6fca7..74607dbcb7f0 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -250,8 +250,7 @@ struct dentry *d_duplicate(struct dentry *dentry);
 /* weird procfs mess; *NOT* exported */
 extern struct dentry * d_splice_alias_ops(struct inode *, struct dentry *,
                                          const struct dentry_operations *);
-extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *,
-                               bool);
+extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr 
*);
 extern bool d_same_name(const struct dentry *dentry, const struct dentry 
*parent,
                        const struct qstr *name);
 extern struct dentry *d_find_any_alias(struct inode *inode);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index cb79e84c718d..643d862a7fda 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -37,9 +37,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT};
 #define LOOKUP_CREATE          BIT(17) /* ... in object creation */
 #define LOOKUP_EXCL            BIT(18) /* ... in target must not exist */
 #define LOOKUP_RENAME_TARGET   BIT(19) /* ... in destination of rename() */
-#define LOOKUP_SHARED          BIT(20) /* Parent lock is held shared */
 
-/* 3 spare bits for intent */
+/* 4 spare bits for intent */
 
 /* Scoping flags for lookup. */
 #define LOOKUP_NO_SYMLINKS     BIT(24) /* No symlink crossing. */
-- 
2.50.0.107.gf914562f5916.dirty


Reply via email to