[PATCH] [UBI] [1/3] ubi notifications API
Artem Bityutskiy
dedekind at infradead.org
Mon May 18 04:05:29 EDT 2009
On Wed, 2009-04-29 at 19:29 +0400, dmitry pervushin wrote:
> +/**
> + * ubi_register_volume_notifier - register the volume notification function.
> + * @nb: pointer to the filled struct ¬ifier_block
> + * @ignore_existing: boolean flag; if set to 1, UBI will not send notifications
> + * about ADDing existing volumes
> + *
> + * The function @nb.notifier_call will be called when volume is added,
> + * removed, resized or renamed. Its first parameter is &enum
> + * ubi_volume_notification_type, and the second points to the structure
> + * that contains information about "changed" volume - ubi_num and
> + * volume_id. When the notifier is called, it is safe to use all UBI API.
> + *
> + * Returns %0 on success, error code otherwise.
> + */
> +int ubi_register_volume_notifier(struct notifier_block *nb,
> + int ignore_existing)
> +{
> + int err;
> +
> + err = blocking_notifier_chain_register(&ubi_notifiers, nb);
> + if (err != 0)
> + return err;
> + if (ignore_existing)
> + return err;
> + down_read(&ubi_notifiers.rwsem);
> +
> + ubi_enum_all_volumes(UBI_VOLUME_ADDED, nb);
> + up_read(&ubi_notifiers.rwsem);
> + return err;
> +}
You take the rwsem here. Then:
'ubi_enum_all_volumes()' ->
'ubi_enum_volumes()' ->
'blocking_notifier_call_chain()' ->
'blocking_notifier_call_chain()'
and down_read(&nh->rwsem);
Deadlock. Have you tested your code?
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
More information about the linux-mtd
mailing list