* [PATCH] sysfs: use ilookup5() instead of ilookup5_nowait()
@ 2008-09-27 22:48 Tejun Heo
2008-10-01 20:56 ` patch sysfs-use-ilookup5-instead-of-ilookup5_nowait.patch added to gregkh-2.6 tree gregkh
0 siblings, 1 reply; 2+ messages in thread
From: Tejun Heo @ 2008-09-27 22:48 UTC (permalink / raw)
To: Greg KH, viro, Linux Kernel Mailing List
As inode creation is protected by sysfs_mutex, ilookup5_nowait()
always either fails to find at all or finds one which is fully
initialized, so using ilookup5_nowait() or ilookup5() doesn't make any
difference. Switch to ilookup5() as it's planned to be removed. This
change also makes lookup return value handling a bit simpler.
This change was suggested by Al Viro.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Al Viro <viro@hera.kernel.org>
---
Greg, can you please put this for 2.6.28? This should be safe but
this isn't a bug fix and it's way too late for 2.6.27. Thanks.
fs/sysfs/dir.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index aedaeba..c04935c 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
memset(acxt, 0, sizeof(*acxt));
acxt->parent_sd = parent_sd;
- /* Lookup parent inode. inode initialization and I_NEW
- * clearing are protected by sysfs_mutex. By grabbing it and
- * looking up with _nowait variant, inode state can be
- * determined reliably.
+ /* Lookup parent inode. inode initialization is protected by
+ * sysfs_mutex, so inode existence can be determined by
+ * looking up inode while holding sysfs_mutex.
*/
mutex_lock(&sysfs_mutex);
- inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
- parent_sd);
+ inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
+ parent_sd);
+ if (inode) {
+ WARN_ON(inode->i_state & I_NEW);
- if (inode && !(inode->i_state & I_NEW)) {
/* parent inode available */
acxt->parent_inode = inode;
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
mutex_lock(&inode->i_mutex);
mutex_lock(&sysfs_mutex);
}
- } else
- iput(inode);
+ }
}
/**
^ permalink raw reply related [flat|nested] 2+ messages in thread
* patch sysfs-use-ilookup5-instead-of-ilookup5_nowait.patch added to gregkh-2.6 tree
2008-09-27 22:48 [PATCH] sysfs: use ilookup5() instead of ilookup5_nowait() Tejun Heo
@ 2008-10-01 20:56 ` gregkh
0 siblings, 0 replies; 2+ messages in thread
From: gregkh @ 2008-10-01 20:56 UTC (permalink / raw)
To: tj, gregkh, greg, linux-kernel, viro
This is a note to let you know that I've just added the patch titled
Subject: sysfs: use ilookup5() instead of ilookup5_nowait()
to my gregkh-2.6 tree. Its filename is
sysfs-use-ilookup5-instead-of-ilookup5_nowait.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
>From tj@kernel.org Wed Oct 1 13:34:14 2008
From: Tejun Heo <tj@kernel.org>
Date: Sun, 28 Sep 2008 07:48:08 +0900
Subject: sysfs: use ilookup5() instead of ilookup5_nowait()
To: Greg KH <greg@kroah.com>, viro@hera.kernel.org, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Message-ID: <48DEB828.3020408@kernel.org>
From: Tejun Heo <tj@kernel.org>
As inode creation is protected by sysfs_mutex, ilookup5_nowait()
always either fails to find at all or finds one which is fully
initialized, so using ilookup5_nowait() or ilookup5() doesn't make any
difference. Switch to ilookup5() as it's planned to be removed. This
change also makes lookup return value handling a bit simpler.
This change was suggested by Al Viro.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Al Viro <viro@hera.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/sysfs/dir.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addr
memset(acxt, 0, sizeof(*acxt));
acxt->parent_sd = parent_sd;
- /* Lookup parent inode. inode initialization and I_NEW
- * clearing are protected by sysfs_mutex. By grabbing it and
- * looking up with _nowait variant, inode state can be
- * determined reliably.
+ /* Lookup parent inode. inode initialization is protected by
+ * sysfs_mutex, so inode existence can be determined by
+ * looking up inode while holding sysfs_mutex.
*/
mutex_lock(&sysfs_mutex);
- inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
- parent_sd);
+ inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
+ parent_sd);
+ if (inode) {
+ WARN_ON(inode->i_state & I_NEW);
- if (inode && !(inode->i_state & I_NEW)) {
/* parent inode available */
acxt->parent_inode = inode;
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addr
mutex_lock(&inode->i_mutex);
mutex_lock(&sysfs_mutex);
}
- } else
- iput(inode);
+ }
}
/**
Patches currently in gregkh-2.6 which might be from tj@kernel.org are
driver-core/sysfs-support-sysfs_notify-from-atomic-context-with-new-sysfs_notify_dirent.patch
driver-core/driver-core-use-klist-for-class-device-list-and-implement-iterator.patch
driver-core/klist-don-t-iterate-over-deleted-entries.patch
driver-core/kobject-cleanup-kobject_rename-and-config_sysfs.patch
driver-core/sysfs-implement-__sysfs_get_dentry.patch
driver-core/sysfs-introduce-sysfs_sd_setattr-and-fix-sysfs_chmod.patch
driver-core/sysfs-sysfs_get_dentry-add-a-sb-parameter.patch
driver-core/sysfs-rename-support-multiple-superblocks.patch
driver-core/sysfs-support-for-preventing-unmounts.patch
driver-core/sysfs-sysfs_chmod_file-handle-multiple-superblocks.patch
driver-core/sysfs-implement-sysfs_delete_link-and-sysfs_rename_link.patch
driver-core/sysfs-use-ilookup5-instead-of-ilookup5_nowait.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-01 21:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-27 22:48 [PATCH] sysfs: use ilookup5() instead of ilookup5_nowait() Tejun Heo
2008-10-01 20:56 ` patch sysfs-use-ilookup5-instead-of-ilookup5_nowait.patch added to gregkh-2.6 tree gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).