[PATCH] mtd: ubi: Fix race condition between ubi device creation and udev
Artem Bityutskiy
dedekind1 at gmail.com
Fri Jul 22 01:45:41 PDT 2016
On Thu, 2016-07-21 at 02:07 +0000, Iosif Harutyunov wrote:
> While implementing udev rules for UBI device I ran into the problem
> when udev would
> ignore UBI rules I created to process attachment of volume.
> Interestingly, when I trigger
> udev ubi subsystem "change" event manually after the attachment,
> rules would work just fine.
>
> I traced problem down to UBI sysfs processing, which turned out to be
> racing condition.
> See patch below to address the problem.
>
> Thanks.
> Iosif,_
>
> Signed-off-by: Iosif Harutyunov <iharutyunov at sonicwall.com>
> ---
> Once ubi is attached, make sure ubi_devices[] is initialized early
> before being
> used in the dev_attribute_show().
>
> This is to prevent race condition between udev ubi rules processing
> and ubi device
> creation, which manifests itself ignoring udev ATTR rules.
Good catch!
Quick feedback: this patch will probably work fine, we could apply the
following logic and select a better place for that line of code. Here
it is:
1. Initialize the device, make it usable. Do not make it available to
anyone before that. This is the code before the 'uif_init()'
invocation. BTW, "uif" means "user interfaces" in this case.
2. Make the device "available" (or "visible") by adding it to the
'ubi_devices' array.
3. Initialize user interfaces, done by 'uif_init()'.
IOW, it put that line just before 'uif_init()'.
More information about the linux-mtd
mailing list