Re: [Bug? Report] kref problem

From: Artem B. Bityutskiy
Date: Thu Mar 16 2006 - 12:05:25 EST


On Thu, 2006-03-16 at 08:53 -0800, Greg KH wrote:
> > static void a_release(struct kobject *kobj)
> > {
> > struct my_obj_a *a;
> >
> > printk("%s\n", __FUNCTION__);
> > a = container_of(kobj, struct my_obj_a, kobj);
> > sysfs_remove_dir(&a->kobj);
>
> Woah, don't do that here, the kobject core already does this. A release
> function is for you to release the memory you have created with this
> kobject, not to mess with sysfs.
So do you mean this (attached) ? Anyway I end up with -1 kref.

My real task is: I have sysfs directory /sys/A which corresponds to my
module, to my subsystem. There I want to create subdirectories
like /sys/A/B/ and delete them from time to time. So the problem is that
whenver I remove B I end up with A's kref decremented. The attached test
demonstrates this. P;ease, look at its output:

a inited, kref 1
b inited, kref 1
dir A created, A kref 1, B kref 1
dir B created, A kref 1, B kref 1
dir B removed, A kref 1, B kref 1
b_release
a_release <--- What is this? I removed B, not A ???
kobj B put, A kref 0, B kref 0
dir A removed, A kref 0, B kref 0
kobj A put, A kref -1, B kref 0

Thanks.

--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/