[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200729151740.GA3430@haolee.github.io>
Date: Wed, 29 Jul 2020 15:21:28 +0000
From: Hao Lee <haolee.swjtu@...il.com>
To: viro@...iv.linux.org.uk
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
haolee.swjtu@...il.com
Subject: [PATCH] fs: Eliminate a local variable to make the code more clear
The dentry local variable is introduced in 'commit 84d17192d2afd ("get
rid of full-hash scan on detaching vfsmounts")' to reduce the length of
some long statements for example
mutex_lock(&path->dentry->d_inode->i_mutex). We have already used
inode_lock(dentry->d_inode) to do the same thing now, and its length is
acceptable. Furthermore, it seems not concise that assign path->dentry
to local variable dentry in the statement before goto. So, this function
would be more clear if we eliminate the local variable dentry.
The function logic is not changed.
Signed-off-by: Hao Lee <haolee.swjtu@...il.com>
---
fs/namespace.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index 4a0f600a3328..fcb93586fcc9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2187,20 +2187,19 @@ static int attach_recursive_mnt(struct mount *source_mnt,
static struct mountpoint *lock_mount(struct path *path)
{
struct vfsmount *mnt;
- struct dentry *dentry = path->dentry;
retry:
- inode_lock(dentry->d_inode);
- if (unlikely(cant_mount(dentry))) {
- inode_unlock(dentry->d_inode);
+ inode_lock(path->dentry->d_inode);
+ if (unlikely(cant_mount(path->dentry))) {
+ inode_unlock(path->dentry->d_inode);
return ERR_PTR(-ENOENT);
}
namespace_lock();
mnt = lookup_mnt(path);
if (likely(!mnt)) {
- struct mountpoint *mp = get_mountpoint(dentry);
+ struct mountpoint *mp = get_mountpoint(path->dentry);
if (IS_ERR(mp)) {
namespace_unlock();
- inode_unlock(dentry->d_inode);
+ inode_unlock(path->dentry->d_inode);
return mp;
}
return mp;
@@ -2209,7 +2208,7 @@ static struct mountpoint *lock_mount(struct path *path)
inode_unlock(path->dentry->d_inode);
path_put(path);
path->mnt = mnt;
- dentry = path->dentry = dget(mnt->mnt_root);
+ path->dentry = dget(mnt->mnt_root);
goto retry;
}
--
2.24.1
Powered by blists - more mailing lists