[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <11922275413548-git-send-email-gregkh@suse.de>
Date: Fri, 12 Oct 2007 15:16:26 -0700
From: Greg Kroah-Hartman <gregkh@...e.de>
To: linux-kernel@...r.kernel.org
Cc: Tejun Heo <htejun@...il.com>, Greg Kroah-Hartman <gregkh@...e.de>
Subject: [PATCH 22/75] sysfs: simplify sysfs_rename_dir()
From: Tejun Heo <htejun@...il.com>
With the shadow directories gone, sysfs_rename_dir() can be simplified.
* parent doesn't need to be grabbed separately. Just access
old_dentry->d_parent.
* parent sd can never change. Remove code to move under the new
parent.
* Massage comments a bit.
Signed-off-by: Tejun Heo <htejun@...il.com>
Acked-by: Cornelia Huck <cornelia.huck@...ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
---
fs/sysfs/dir.c | 26 ++++----------------------
1 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 5da8da8..9504d4c 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -883,14 +883,10 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
struct sysfs_dirent *sd;
struct dentry *parent = NULL;
struct dentry *old_dentry = NULL, *new_dentry = NULL;
- struct sysfs_dirent *parent_sd;
const char *dup_name = NULL;
int error;
- if (!kobj->parent)
- return -EINVAL;
-
- /* get dentries */
+ /* get the original dentry */
sd = kobj->sd;
old_dentry = sysfs_get_dentry(sd);
if (IS_ERR(old_dentry)) {
@@ -898,12 +894,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
goto out_dput;
}
- parent_sd = kobj->parent->sd;
- parent = sysfs_get_dentry(parent_sd);
- if (IS_ERR(parent)) {
- error = PTR_ERR(parent);
- goto out_dput;
- }
+ parent = old_dentry->d_parent;
/* lock parent and get dentry for new name */
mutex_lock(&parent->d_inode->i_mutex);
@@ -933,22 +924,14 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
goto out_drop;
mutex_lock(&sysfs_mutex);
-
dup_name = sd->s_name;
sd->s_name = new_name;
+ mutex_unlock(&sysfs_mutex);
- /* move under the new parent */
+ /* rename */
d_add(new_dentry, NULL);
d_move(sd->s_dentry, new_dentry);
- sysfs_unlink_sibling(sd);
- sysfs_get(parent_sd);
- sysfs_put(sd->s_parent);
- sd->s_parent = parent_sd;
- sysfs_link_sibling(sd);
-
- mutex_unlock(&sysfs_mutex);
-
error = 0;
goto out_unlock;
@@ -958,7 +941,6 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
mutex_unlock(&parent->d_inode->i_mutex);
out_dput:
kfree(dup_name);
- dput(parent);
dput(old_dentry);
dput(new_dentry);
return error;
--
1.5.3.4
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists