Skip to content

Commit 15f2373

Browse files
author
Al Viro
committed
fast_dput(): new rules for refcount
By now there is only one place in entire fast_dput() where we return false; that happens after refcount had been decremented and found (under ->d_lock) to be zero. In that case, just prior to returning false to caller, fast_dput() forcibly changes the refcount from 0 to 1. Lift that resetting refcount to 1 into the callers; later in the series it will be massaged out of existence. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 504e08c commit 15f2373

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

fs/dcache.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,6 @@ static inline bool fast_dput(struct dentry *dentry)
847847
spin_unlock(&dentry->d_lock);
848848
return true;
849849
}
850-
851-
/*
852-
* Re-get the reference we optimistically dropped. We hold the
853-
* lock, and we just tested that it was zero, so we can just
854-
* set it to 1.
855-
*/
856-
dentry->d_lockref.count = 1;
857850
return false;
858851
}
859852

@@ -896,6 +889,7 @@ void dput(struct dentry *dentry)
896889
}
897890

898891
/* Slow case: now with the dentry lock held */
892+
dentry->d_lockref.count = 1;
899893
rcu_read_unlock();
900894

901895
if (likely(retain_dentry(dentry))) {
@@ -930,6 +924,7 @@ void dput_to_list(struct dentry *dentry, struct list_head *list)
930924
return;
931925
}
932926
rcu_read_unlock();
927+
dentry->d_lockref.count = 1;
933928
if (!retain_dentry(dentry))
934929
__dput_to_list(dentry, list);
935930
spin_unlock(&dentry->d_lock);

0 commit comments

Comments
 (0)