sysfs: remove duplicated dput in sysfs_update_file
PATCH 1/1 sysfs: remove duplicated dput in sysfs_update_file
Following function can drops d_count twice against one reference by lookup_one_len.
<SOURCE>
/**
* sysfs_update_file - update the modified timestamp on an object attribute.
* @kobj: object we're acting for.
* @attr: attribute descriptor.
*/
int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
{
struct dentry * dir = kobj->dentry;
struct dentry * victim;
int res = -ENOENT;
mutex_lock(&dir->d_inode->i_mutex);
victim = lookup_one_len(attr->name, dir, strlen(attr->name));
if (!IS_ERR(victim)) {
/* make sure dentry is really there */
if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) {
victim->d_inode->i_mtime = CURRENT_TIME;
fsnotify_modify(victim);
/**
* Drop reference from initial sysfs_get_dentry().
*/
dput(victim);
res = 0;
} else
d_drop(victim);
/**
* Drop the reference acquired from sysfs_get_dentry() above.
*/
dput(victim);
}
mutex_unlock(&dir->d_inode->i_mutex);
return res;
}</SOURCE>
PCI-hotplug (drivers/pci/hotplug/pci_hotplug_core.c) is only user of this function. I confirmed that dentry of /sys/bus/pci/slots/XXX/* have negative d_count value.
This patch removes unnecessary dput().
--- fs/sysfs/file.c | 5 ----- 1 files changed, 5 deletions(-)
fs/sysfs/file.c +0 -5
@@ -483,11 +483,6 @@ (victim->d_parent->d_inode == dir->d_inode)) { victim->d_inode->i_mtime =CURRENT_TIME ;fsnotify_modify (victim); - -/** -* Drop reference from initial sysfs_get_dentry(). -*/ -dput (victim); res =0 ; } elsed_drop (victim );
Re: [PATCH 2.6.18] sysfs: update obsolete comment in sysfs_update_file
And the obsolete comment should be updated (or totally removed).
--- fs/sysfs/file.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
fs/sysfs/file.c +1 -1
@@ -488,7 +488,7 @@d_drop (victim);/** -* Drop the reference acquired from sysfs_get_dentry() above. +* Drop the reference acquired from lookup_one_len() above. */ dput (victim); }
[email protected]
Appliedpatch sysfs-update-obsolete-comment-in-sysfs_update_file.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled
Subject: sysfs: update obsolete comment in sysfs_update_file
to my gregkh-2.6 tree. Its filename is
sysfs-update-obsolete-comment-in-sysfs_update_file.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Wed Sep 20 00:46:42 2006
Message-ID: <[email protected]>
Date: Wed, 20 Sep 2006 16:49:02 +0900
From: Hidetoshi Seto <[email protected]>
To: Greg KH <[email protected]>
Cc: Linux Kernel list <[email protected]>
Subject: sysfs: update obsolete comment in sysfs_update_file
And the obsolete comment should be updated (or totally removed).
--- fs/sysfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/sysfs/file.c +1 -1
@@ -502,7 +502,7 @@ int sysfs_update_file(struct kobject * kd_drop (victim);/** -* Drop the reference acquired from sysfs_get_dentry() above. +* Drop the reference acquired from lookup_one_len() above. */ dput (victim); }
Patches currently in gregkh-2.6 which might be from [email protected] are
driver/sysfs-remove-duplicated-dput-in-sysfs_update_file.patch driver/sysfs-update-obsolete-comment-in-sysfs_update_file.patch
Quoted 64 lines · Hidetoshi Seto
Following function can drops
d_counttwice against one reference bylookup_one_len.<SOURCE>
/**
*sysfs_update_file- update the modified timestamp on an object attribute.
* @kobj: object we're acting for.
* @attr: attribute descriptor.
*/
intsysfs_update_file(struct kobject * kobj, const struct attribute * attr){ struct dentry * dir = kobj->dentry; struct dentry * victim; int res = -ENOENT; mutex_lock(&dir->d_inode->i_mutex); victim = lookup_one_len(attr->name, dir, strlen(attr->name)); if (!IS_ERR(victim)) { /* make sure dentry is really there */ if (victim->d_inode && (victim->d_parent->d_inode == dir->d_inode)) { victim->d_inode->i_mtime = CURRENT_TIME; fsnotify_modify(victim); /** * Drop reference from initial sysfs_get_dentry(). */ dput(victim); res = 0; } else d_drop(victim); /** * Drop the reference acquired from sysfs_get_dentry() above. */ dput(victim); } mutex_unlock(&dir->d_inode->i_mutex); return res; }</SOURCE>
PCI-hotplug (
drivers/pci/hotplug/pci_hotplug_core.c) is only user of this function. I confirmed that dentry of/sys/bus/pci/slots/XXX/*have negatived_countvalue.This patch removes unnecessary
dput().Signed-off-by Hidetoshi Seto <[email protected]>--- fs/sysfs/file.c | 5 ----- 1 files changed, 5 deletions(-)Index:
linux-2.6.18/fs/sysfs/file.c
===================================================================fs/sysfs/file.c +0
-0@@ -483,11 +483,6 @@ (victim->d_parent->d_inode == dir->d_inode)) { victim->d_inode->i_mtime =CURRENT_TIME ;fsnotify_modify (victim);
fs/sysfs/file.c
Quoted 10 lines
fs/sysfs/file.c +0
-6- -/** -* Drop reference from initial sysfs_get_dentry(). -*/ -dput (victim); res =0 ; }else d_drop (victim); -
Looks good to me..
Thanks
Maneesh
[email protected]
Appliedpatch sysfs-remove-duplicated-dput-in-sysfs_update_file.patch added to gregkh-2.6 tree
In reply to Hidetoshi SetoThis is a note to let you know that I've just added the patch titled
Subject: sysfs: remove duplicated dput in sysfs_update_file
to my gregkh-2.6 tree. Its filename is
sysfs-remove-duplicated-dput-in-sysfs_update_file.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Wed Sep 20 00:35:46 2006
Message-ID: <[email protected]>
Date: Wed, 20 Sep 2006 16:38:00 +0900
From: Hidetoshi Seto <[email protected]>
To: Greg KH <[email protected]>
Cc: Linux Kernel list <[email protected]>
Subject: sysfs: remove duplicated dput in sysfs_update_file
Following function can drops d_count twice against one reference by lookup_one_len.
<SOURCE>
/**
* sysfs_update_file - update the modified timestamp on an object attribute.
* @kobj: object we're acting for.
* @attr: attribute descriptor.
*/
int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
{
struct dentry * dir = kobj->dentry;
struct dentry * victim;
int res = -ENOENT;
mutex_lock(&dir->d_inode->i_mutex);
victim = lookup_one_len(attr->name, dir, strlen(attr->name));
if (!IS_ERR(victim)) {
/* make sure dentry is really there */
if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) {
victim->d_inode->i_mtime = CURRENT_TIME;
fsnotify_modify(victim);
/**
* Drop reference from initial sysfs_get_dentry().
*/
dput(victim);
res = 0;
} else
d_drop(victim);
/**
* Drop the reference acquired from sysfs_get_dentry() above.
*/
dput(victim);
}
mutex_unlock(&dir->d_inode->i_mutex);
return res;
}</SOURCE>
PCI-hotplug (drivers/pci/hotplug/pci_hotplug_core.c) is only user of this function. I confirmed that dentry of /sys/bus/pci/slots/XXX/* have negative d_count value.
This patch removes unnecessary dput().
--- fs/sysfs/file.c | 5 ----- 1 file changed, 5 deletions(-)
fs/sysfs/file.c +0 -5
@@ -497,11 +497,6 @@ int sysfs_update_file(struct kobject * k (victim->d_parent->d_inode == dir->d_inode)) { victim->d_inode->i_mtime =CURRENT_TIME ;fsnotify_modify (victim); - -/** -* Drop reference from initial sysfs_get_dentry(). -*/ -dput (victim); res =0 ; } elsed_drop (victim );
Patches currently in gregkh-2.6 which might be from [email protected] are
driver/sysfs-remove-duplicated-dput-in-sysfs_update_file.patch driver/sysfs-update-obsolete-comment-in-sysfs_update_file.patch