From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:47818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756600AbdIRSVs (ORCPT ); Mon, 18 Sep 2017 14:21:48 -0400 From: Waiman Long To: Alexander Viro Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Linus Torvalds , Jan Kara , "Paul E. McKenney" , Andrew Morton , Ingo Molnar , Miklos Szeredi , Matthew Wilcox , Larry Woodman , James Bottomley , "Wangkai (Kevin C)" , Waiman Long Subject: [PATCH v4 1/6] fs/dcache: Relocate dentry_kill() after lock_parent() Date: Mon, 18 Sep 2017 14:20:29 -0400 Message-Id: <1505758834-1201-2-git-send-email-longman@redhat.com> In-Reply-To: <1505758834-1201-1-git-send-email-longman@redhat.com> References: <1505758834-1201-1-git-send-email-longman@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- 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