2003-03-27 03:31:19

by David Brownell

[permalink] [raw]
Subject: 2.5.recent: device_remove_file() doesn't

I've noticed that recent kernels don't clean up device
attribute files correctly when they're removed. Instead,
they're left in the directory with a refcount of zero.

That refcount stays even when the file is recreated later;
and the contents can be read. Delete them again, and now
the refcount is 65535 ... though now reading the contents
may cause oopsing.

This worked correctly at some point last month: the file
no longer appeared in sysfs after deletion.

Got Patch?

- Dave



2003-03-27 18:45:08

by Patrick Mochel

[permalink] [raw]
Subject: Re: 2.5.recent: device_remove_file() doesn't


On Wed, 26 Mar 2003, David Brownell wrote:

> I've noticed that recent kernels don't clean up device
> attribute files correctly when they're removed. Instead,
> they're left in the directory with a refcount of zero.
>
> That refcount stays even when the file is recreated later;
> and the contents can be read. Delete them again, and now
> the refcount is 65535 ... though now reading the contents
> may cause oopsing.
>
> This worked correctly at some point last month: the file
> no longer appeared in sysfs after deletion.
>
> Got Patch?

Yeah, and I apologize. File deletion has been causing some problems
lately due to some bad assumptions of the dentry layer. This patch reverts
a small bit of the patch that went in a couple of weeks ago, and should
hopefully fix everything up.

This should also take care of the problem that some have been seeing of
symlinks not going away on device/module removal (though I've been unable
to reproduce those).

Greg/Mike, could you give this patch a shot and let me know if helps?

Thanks,


-pat

===== fs/sysfs/inode.c 1.84 vs edited =====
--- 1.84/fs/sysfs/inode.c Tue Mar 11 15:30:18 2003
+++ edited/fs/sysfs/inode.c Thu Mar 27 11:53:44 2003
@@ -97,7 +97,7 @@
atomic_read(&victim->d_count));

simple_unlink(dir->d_inode,victim);
-
+ d_delete(victim);
}
/*
* Drop reference from sysfs_get_dentry() above.

2003-03-27 19:54:03

by Greg KH

[permalink] [raw]
Subject: Re: 2.5.recent: device_remove_file() doesn't

On Thu, Mar 27, 2003 at 11:58:14AM -0600, Patrick Mochel wrote:
>
> Greg/Mike, could you give this patch a shot and let me know if helps?

Yes, this seems to fix the symlink problem I was seeing before, thanks.

greg k-h

2003-03-27 22:24:26

by Mike Anderson

[permalink] [raw]
Subject: Re: 2.5.recent: device_remove_file() doesn't

Greg KH [[email protected]] wrote:
> On Thu, Mar 27, 2003 at 11:58:14AM -0600, Patrick Mochel wrote:
> >
> > Greg/Mike, could you give this patch a shot and let me know if helps?
>
> Yes, this seems to fix the symlink problem I was seeing before, thanks.
>

It has also fixed my symlink issue.

thanks,

-andmike
--
Michael Anderson
[email protected]

2003-03-27 23:12:15

by David Brownell

[permalink] [raw]
Subject: Re: 2.5.recent: device_remove_file() doesn't

Thanks, it resolved that problem.

- Dave


> --- 1.84/fs/sysfs/inode.c Tue Mar 11 15:30:18 2003
> +++ edited/fs/sysfs/inode.c Thu Mar 27 11:53:44 2003
> @@ -97,7 +97,7 @@
> atomic_read(&victim->d_count));
>
> simple_unlink(dir->d_inode,victim);
> -
> + d_delete(victim);
> }
> /*
> * Drop reference from sysfs_get_dentry() above.
>
>