[PATCH 07/15] sysfs: kill unnecessary sysfs_get() in open paths

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <ebiederm@...>, <cornelia.huck@...>, <greg@...>, <stern@...>, <kay.sievers@...>, <linux-kernel@...>, <htejun@...>
Cc: Tejun Heo <htejun@...>
Date: Thursday, September 20, 2007 - 3:05 am

There's no reason to get an extra reference to sysfs_dirent for an
open file.  Open file has a reference to the dentry which in turn has
a reference to sysfs_dirent.  This is fairly obvious as otherwise open
itself won't be able to access the sysfs_dirent.  Kill the extra
sysfs_get() and matching sysfs_put().

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 fs/sysfs/bin.c  |    4 +---
 fs/sysfs/file.c |    6 +-----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index a819a7e..e93fe5e 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -193,9 +193,8 @@ static int open(struct inode * inode, struct file * file)
 	mutex_init(&bb->mutex);
 	file->private_data = bb;
 
-	/* open succeeded, put active reference and pin attr_sd */
+	/* open succeeded, put active reference */
 	sysfs_put_active(attr_sd);
-	sysfs_get(attr_sd);
 	return 0;
 
  err_out:
@@ -211,7 +210,6 @@ static int release(struct inode * inode, struct file * file)
 
 	if (bb->mmapped)
 		sysfs_put_active_two(attr_sd);
-	sysfs_put(attr_sd);
 	kfree(bb->buffer);
 	kfree(bb);
 	return 0;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 61a8c19..73333dc 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -298,9 +298,8 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	buffer->ops = ops;
 	file->private_data = buffer;
 
-	/* open succeeded, put active references and pin attr_sd */
+	/* open succeeded, put active references */
 	sysfs_put_active_two(attr_sd);
-	sysfs_get(attr_sd);
 	return 0;
 
  err_out:
@@ -310,11 +309,8 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 
 static int sysfs_release(struct inode * inode, struct file * filp)
 {
-	struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
 	struct sysfs_buffer *buffer = filp->private_data;
 
-	sysfs_put(attr_sd);
-
 	if (buffer) {
 		if (buffer->page)
 			free_page((unsigned long)buffer->page);
-- 
1.5.0.3


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHSET 1/4] sysfs: misc updates, Tejun Heo, (Thu Sep 20, 3:05 am)
Re: [PATCHSET 1/4] sysfs: misc updates, Cornelia Huck, (Wed Sep 26, 7:04 am)
Re: [PATCHSET 1/4] sysfs: misc updates, Greg KH, (Wed Sep 26, 11:19 am)
[PATCH 14/15] sysfs: implement sysfs_open_dirent, Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 10/15] sysfs: make s_elem an anonymous union, Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 05/15] sysfs: kill sysfs_update_file(), Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 07/15] sysfs: kill unnecessary sysfs_get() in open pa..., Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 04/15] sysfs: clean up header files, Tejun Heo, (Thu Sep 20, 3:05 am)
[PATCH 01/15] sysfs: kill SYSFS_FLAG_REMOVED, Tejun Heo, (Thu Sep 20, 3:05 am)
Re: [PATCH 01/15] sysfs: kill SYSFS_FLAG_REMOVED, Greg KH, (Tue Sep 25, 5:32 pm)