[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimq0UVtR-ooutKTfOOE=cS-vxR4gR-aVc1feOzJ@mail.gmail.com>
Date: Fri, 30 Jul 2010 06:36:55 +0200
From: Kay Sievers <kay.sievers@...y.org>
To: Milan Broz <mbroz@...hat.com>
Cc: Karel Zak <kzak@...hat.com>, util-linux-ng@...r.kernel.org,
linux-kernel@...r.kernel.org, axboe@...nel.dk
Subject: Re: [PATCH] loop: add some basic read-only sysfs attributes
On Thu, Jul 29, 2010 at 22:24, Milan Broz <mbroz@...hat.com> wrote:
> On 07/29/2010 09:56 PM, Karel Zak wrote:
>>> Sure it does. Sysfs attributes need to be created _before_ uevents are
>>> sent out. The current behavior is that all blockdev attributes are
>>> safely created before the event is sent. These loop attributes are
>>> created _after_ the event is sent.
>>>
>>> The question is if we can rely on the fact, that 'add' events never
>>> want to look at any of these attributes, and all can be deferred to
>
> The problem is that add_disk() initializes kobject and announces device.
> How can I add some new attributes (subdir) with the current code
> before it happens?
Use attribute groups, and assign them to the class, or in this case to
the device before it is registered. All this stuff is created by the
core before the event is sent out. It also takes care of the subdir,
instead rolling your own kobject stuff, does proper error handling,
and cleans-up things in the proper order, without any further custom
code.
Alternatively, these attributes could be created and removed/created
with the ioctl, and before the 'change' event, only if there is an
active backing file, but I would expect the attribute group at the
device to work just fine.
> And why it is problem at all? After configuration there is always change
> event and at this time attributes are there.
As said, if we can rely on this fact, and there will never be any
attribute now, or added in the future, to this block of attributes,
this might be just fine, that's why I ask ...
We spent a lot of time to get the sysfs timing right, fix all the
subsystems, and make udev work with all sorts of attributes which have
been created like this. To add out-of-band attribute creation timing
today, there needs to be a very good reason to do so.
If you need any help with a try to a switch to the attribute group,
please let me know.
Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists