]> git.neil.brown.name Git - linux.git/commitdiff
split the slow part of lock_parent() off
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 24 Feb 2018 03:11:34 +0000 (22:11 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 29 Mar 2018 19:07:42 +0000 (15:07 -0400)
Turn the "trylock failed" part into uninlined __lock_parent().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index 916fd57b9d18d04cd338ee930f243fc3d7eef6f5..61819fb32e1392947f1846a96babd7643ac70a33 100644 (file)
@@ -588,13 +588,9 @@ static void __dentry_kill(struct dentry *dentry)
                dentry_free(dentry);
 }
 
-static inline struct dentry *lock_parent(struct dentry *dentry)
+static struct dentry *__lock_parent(struct dentry *dentry)
 {
-       struct dentry *parent = dentry->d_parent;
-       if (IS_ROOT(dentry))
-               return NULL;
-       if (likely(spin_trylock(&parent->d_lock)))
-               return parent;
+       struct dentry *parent;
        rcu_read_lock();
        spin_unlock(&dentry->d_lock);
 again:
@@ -620,6 +616,16 @@ static inline struct dentry *lock_parent(struct dentry *dentry)
        return parent;
 }
 
+static inline struct dentry *lock_parent(struct dentry *dentry)
+{
+       struct dentry *parent = dentry->d_parent;
+       if (IS_ROOT(dentry))
+               return NULL;
+       if (likely(spin_trylock(&parent->d_lock)))
+               return parent;
+       return __lock_parent(dentry);
+}
+
 /*
  * Finish off a dentry we've decided to kill.
  * dentry->d_lock must be held, returns with it unlocked.