lkml.org 
[lkml]   [2017]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v4 1/6] fs/dcache: Relocate dentry_kill() after lock_parent()
Date
This patch just relocates the dentry_kill() function to after the
lock_parent() so that dentry_kill() can call lock_parent() in a later
patch. There is no code change.

Signed-off-by: Waiman Long <longman@redhat.com>
---
fs/dcache.c | 64 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index f901413..8979dd8 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -586,38 +586,6 @@ static void __dentry_kill(struct dentry *dentry)
dentry_free(dentry);
}

-/*
- * Finish off a dentry we've decided to kill.
- * dentry->d_lock must be held, returns with it unlocked.
- * If ref is non-zero, then decrement the refcount too.
- * Returns dentry requiring refcount drop, or NULL if we're done.
- */
-static struct dentry *dentry_kill(struct dentry *dentry)
- __releases(dentry->d_lock)
-{
- struct inode *inode = dentry->d_inode;
- struct dentry *parent = NULL;
-
- if (inode && unlikely(!spin_trylock(&inode->i_lock)))
- goto failed;
-
- if (!IS_ROOT(dentry)) {
- parent = dentry->d_parent;
- if (unlikely(!spin_trylock(&parent->d_lock))) {
- if (inode)
- spin_unlock(&inode->i_lock);
- goto failed;
- }
- }
-
- __dentry_kill(dentry);
- return parent;
-
-failed:
- spin_unlock(&dentry->d_lock);
- return dentry; /* try again with same dentry */
-}
-
static inline struct dentry *lock_parent(struct dentry *dentry)
{
struct dentry *parent = dentry->d_parent;
@@ -653,6 +621,38 @@ static inline struct dentry *lock_parent(struct dentry *dentry)
}

/*
+ * Finish off a dentry we've decided to kill.
+ * dentry->d_lock must be held, returns with it unlocked.
+ * If ref is non-zero, then decrement the refcount too.
+ * Returns dentry requiring refcount drop, or NULL if we're done.
+ */
+static struct dentry *dentry_kill(struct dentry *dentry)
+ __releases(dentry->d_lock)
+{
+ struct inode *inode = dentry->d_inode;
+ struct dentry *parent = NULL;
+
+ if (inode && unlikely(!spin_trylock(&inode->i_lock)))
+ goto failed;
+
+ if (!IS_ROOT(dentry)) {
+ parent = dentry->d_parent;
+ if (unlikely(!spin_trylock(&parent->d_lock))) {
+ if (inode)
+ spin_unlock(&inode->i_lock);
+ goto failed;
+ }
+ }
+
+ __dentry_kill(dentry);
+ return parent;
+
+failed:
+ spin_unlock(&dentry->d_lock);
+ return dentry; /* try again with same dentry */
+}
+
+/*
* Try to do a lockless dput(), and return whether that was successful.
*
* If unsuccessful, we return false, having already taken the dentry lock.
--
1.8.3.1
\
 
 \ /
  Last update: 2017-09-18 20:24    [W:0.077 / U:0.280 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site