summaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2018-02-22 18:50:21 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2018-03-12 11:59:13 -0400
commitc1d0c1a2b51e86124b7ba8ff9054698e2036d8e7 (patch)
tree72e83696cc87bedb6c65a0315fd3c1c62ebd29e8 /fs/dcache.c
parent06080d100d921848b35196850ec17310469e06ba (diff)
fs/dcache: Move dentry_kill() below lock_parent()
A subsequent patch will modify dentry_kill() to call lock_parent(). Move the dentry_kill() implementation "as is" below lock_parent() first. This will help simplify the review of the subsequent patch with dentry_kill() changes. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 9a83fc5f440c..01c0432ec83a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -588,37 +588,6 @@ static void __dentry_kill(struct dentry *dentry)
588 dentry_free(dentry); 588 dentry_free(dentry);
589} 589}
590 590
591/*
592 * Finish off a dentry we've decided to kill.
593 * dentry->d_lock must be held, returns with it unlocked.
594 * Returns dentry requiring refcount drop, or NULL if we're done.
595 */
596static struct dentry *dentry_kill(struct dentry *dentry)
597 __releases(dentry->d_lock)
598{
599 struct inode *inode = dentry->d_inode;
600 struct dentry *parent = NULL;
601
602 if (inode && unlikely(!spin_trylock(&inode->i_lock)))
603 goto failed;
604
605 if (!IS_ROOT(dentry)) {
606 parent = dentry->d_parent;
607 if (unlikely(!spin_trylock(&parent->d_lock))) {
608 if (inode)
609 spin_unlock(&inode->i_lock);
610 goto failed;
611 }
612 }
613
614 __dentry_kill(dentry);
615 return parent;
616
617failed:
618 spin_unlock(&dentry->d_lock);
619 return dentry; /* try again with same dentry */
620}
621
622static inline struct dentry *lock_parent(struct dentry *dentry) 591static inline struct dentry *lock_parent(struct dentry *dentry)
623{ 592{
624 struct dentry *parent = dentry->d_parent; 593 struct dentry *parent = dentry->d_parent;
@@ -659,6 +628,37 @@ again:
659} 628}
660 629
661/* 630/*
631 * Finish off a dentry we've decided to kill.
632 * dentry->d_lock must be held, returns with it unlocked.
633 * Returns dentry requiring refcount drop, or NULL if we're done.
634 */
635static struct dentry *dentry_kill(struct dentry *dentry)
636 __releases(dentry->d_lock)
637{
638 struct inode *inode = dentry->d_inode;
639 struct dentry *parent = NULL;
640
641 if (inode && unlikely(!spin_trylock(&inode->i_lock)))
642 goto failed;
643
644 if (!IS_ROOT(dentry)) {
645 parent = dentry->d_parent;
646 if (unlikely(!spin_trylock(&parent->d_lock))) {
647 if (inode)
648 spin_unlock(&inode->i_lock);
649 goto failed;
650 }
651 }
652
653 __dentry_kill(dentry);
654 return parent;
655
656failed:
657 spin_unlock(&dentry->d_lock);
658 return dentry; /* try again with same dentry */
659}
660
661/*
662 * Try to do a lockless dput(), and return whether that was successful. 662 * Try to do a lockless dput(), and return whether that was successful.
663 * 663 *
664 * If unsuccessful, we return false, having already taken the dentry lock. 664 * If unsuccessful, we return false, having already taken the dentry lock.