vfs: restructure d_genocide()
authorMiklos Szeredi <mszeredi@suse.cz>
Thu, 5 Sep 2013 09:44:34 +0000 (11:44 +0200)
committerMaciej Wereski <m.wereski@partner.samsung.com>
Tue, 9 Jun 2015 09:30:59 +0000 (11:30 +0200)
It shouldn't matter when we decrement the refcount during the walk as long
as we do it exactly once.

Restructure d_genocide() to do the killing on entering the dentry instead
of when leaving it.  This helps creating a common helper for tree walking.

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

index c8f5ce8..7cd8dc9 100644 (file)
@@ -2954,6 +2954,10 @@ resume:
                        spin_unlock(&dentry->d_lock);
                        continue;
                }
+               if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
+                       dentry->d_flags |= DCACHE_GENOCIDE;
+                       dentry->d_lockref.count--;
+               }
                if (!list_empty(&dentry->d_subdirs)) {
                        spin_unlock(&this_parent->d_lock);
                        spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_);
@@ -2961,18 +2965,10 @@ resume:
                        spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_);
                        goto repeat;
                }
-               if (!(dentry->d_flags & DCACHE_GENOCIDE)) {
-                       dentry->d_flags |= DCACHE_GENOCIDE;
-                       dentry->d_lockref.count--;
-               }
                spin_unlock(&dentry->d_lock);
        }
        if (this_parent != root) {
                struct dentry *child = this_parent;
-               if (!(this_parent->d_flags & DCACHE_GENOCIDE)) {
-                       this_parent->d_flags |= DCACHE_GENOCIDE;
-                       this_parent->d_lockref.count--;
-               }
                this_parent = try_to_ascend(this_parent, locked, seq);
                if (!this_parent)
                        goto rename_retry;