fs/sysfs/inode.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff -puN fs/sysfs/inode.c~a fs/sysfs/inode.c --- 25/fs/sysfs/inode.c~a 2003-02-25 11:55:29.000000000 -0800 +++ 25-akpm/fs/sysfs/inode.c 2003-02-25 11:59:43.000000000 -0800 @@ -807,8 +807,10 @@ void sysfs_remove_dir(struct kobject * k down(&parent->d_inode->i_sem); down(&dentry->d_inode->i_sem); +repeat: + spin_lock(&dcache_lock); list_for_each_safe(node,next,&dentry->d_subdirs) { - struct dentry * d = dget(list_entry(node,struct dentry,d_child)); + struct dentry * d = list_entry(node,struct dentry,d_child); /** * Make sure dentry is still there */ @@ -819,20 +821,16 @@ void sysfs_remove_dir(struct kobject * k /** * Unlink and unhash. */ + dget_locked(d); + spin_unlock(&dcache_lock); simple_unlink(dentry->d_inode,d); d_delete(d); - - /** - * Drop reference from initial get_dentry(). - */ dput(d); + goto repeat; } pr_debug(" done (%d)\n",atomic_read(&d->d_count)); - /** - * drop reference from dget() above. - */ - dput(d); } + spin_unlock(&dcache_lock); up(&dentry->d_inode->i_sem); d_invalidate(dentry); _