dput(): turn into explicit while() loop
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 15 Apr 2018 22:31:03 +0000 (18:31 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 16 Apr 2018 03:36:58 +0000 (23:36 -0400)
No need to mess with gotos when the code yielded by straight while()
isn't any worse...

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

index fd4c6de..c4d2234 100644 (file)
@@ -828,29 +828,24 @@ static inline bool fast_dput(struct dentry *dentry)
  */
 void dput(struct dentry *dentry)
 {
-       if (unlikely(!dentry))
-               return;
+       while (dentry) {
+               might_sleep();
 
-repeat:
-       might_sleep();
+               rcu_read_lock();
+               if (likely(fast_dput(dentry))) {
+                       rcu_read_unlock();
+                       return;
+               }
 
-       rcu_read_lock();
-       if (likely(fast_dput(dentry))) {
+               /* Slow case: now with the dentry lock held */
                rcu_read_unlock();
-               return;
-       }
 
-       /* Slow case: now with the dentry lock held */
-       rcu_read_unlock();
-
-       if (likely(retain_dentry(dentry))) {
-               spin_unlock(&dentry->d_lock);
-               return;
-       }
+               if (likely(retain_dentry(dentry))) {
+                       spin_unlock(&dentry->d_lock);
+                       return;
+               }
 
-       dentry = dentry_kill(dentry);
-       if (dentry) {
-               goto repeat;
+               dentry = dentry_kill(dentry);
        }
 }
 EXPORT_SYMBOL(dput);