diff options
author | Tejun Heo <tj@kernel.org> | 2008-09-27 18:48:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-10-16 12:24:51 -0400 |
commit | 45c076c5d71e6e644e2eae64f80922d162c900ac (patch) | |
tree | 68e188af66201219f41681d57975a1bdf7ec9347 /fs/sysfs/dir.c | |
parent | 8a89efd18aa15bb832778baa4e6eee3857ecada4 (diff) |
sysfs: use ilookup5() instead of ilookup5_nowait()
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>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r-- | fs/sysfs/dir.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 53bc7fc31af3..c18342641cec 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, | |||
370 | memset(acxt, 0, sizeof(*acxt)); | 370 | memset(acxt, 0, sizeof(*acxt)); |
371 | acxt->parent_sd = parent_sd; | 371 | acxt->parent_sd = parent_sd; |
372 | 372 | ||
373 | /* Lookup parent inode. inode initialization and I_NEW | 373 | /* Lookup parent inode. inode initialization is protected by |
374 | * clearing are protected by sysfs_mutex. By grabbing it and | 374 | * sysfs_mutex, so inode existence can be determined by |
375 | * looking up with _nowait variant, inode state can be | 375 | * looking up inode while holding sysfs_mutex. |
376 | * determined reliably. | ||
377 | */ | 376 | */ |
378 | mutex_lock(&sysfs_mutex); | 377 | mutex_lock(&sysfs_mutex); |
379 | 378 | ||
380 | inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, | 379 | inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, |
381 | parent_sd); | 380 | parent_sd); |
381 | if (inode) { | ||
382 | WARN_ON(inode->i_state & I_NEW); | ||
382 | 383 | ||
383 | if (inode && !(inode->i_state & I_NEW)) { | ||
384 | /* parent inode available */ | 384 | /* parent inode available */ |
385 | acxt->parent_inode = inode; | 385 | acxt->parent_inode = inode; |
386 | 386 | ||
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, | |||
393 | mutex_lock(&inode->i_mutex); | 393 | mutex_lock(&inode->i_mutex); |
394 | mutex_lock(&sysfs_mutex); | 394 | mutex_lock(&sysfs_mutex); |
395 | } | 395 | } |
396 | } else | 396 | } |
397 | iput(inode); | ||
398 | } | 397 | } |
399 | 398 | ||
400 | /** | 399 | /** |