Re: [linux-usb-devel] [PATCH] back out sysfs reference count change

Alan Stern
2004-04-06T17:03:50Z

On Tue, 6 Apr 2004, Maneesh Soni wrote:

> Yes, it came from check_perm(). I think I found the reason for that. The
> attribute group subdirectory's dentry also has a pointer to the same kobject
> as the corresponding directory's dentry. The kobject directory dentry was
> taken care of but the attribute group subdirectory was still pointing to the
> kobject. And that badness message was coming while opening a file under
> attribute subdir.
>
> I am using dentry->d_flags and a new flag value DCACHE_SYSFS_CONNECTED to
> indicate that the dentry is connected to a vaild kobject. I could run my
> stress test of insmod/rmmod for more than 3 hours without any badness message.
>
> I am copying to the maintainers also and hope to get their comments for
> this patch.
>
> Thanks
> Maneesh

I like your patch a lot. It suggests an additional possibility. Maybe
your DCACHE_SYSFS_CONNECTED flag could be used to indicate that an
attribute is registered. That way, after the file is unregistered (even
if the kobject still exists) reads and writes of the attribute would
return an error. This isn't really necessary since opening an attribute
takes a reference to the module owning the attribute, but it is
conceptually attractive.

Alan Stern