From: Tejun Heo Date: Thu, 21 Apr 2011 17:43:58 +0000 (+0200) Subject: block: don't propagate unlisted DISK_EVENTs to userland X-Git-Tag: v2.6.39-rc5~24^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c88a168da8003fd4d8fb6ae103c4ecf29cb1130;p=profile%2Fivi%2Fkernel-x86-ivi.git block: don't propagate unlisted DISK_EVENTs to userland DISK_EVENT_MEDIA_CHANGE is used for both userland visible event and internal event for revalidation of removeable devices. Some legacy drivers don't implement proper event detection and continuously generate events under certain circumstances. For example, ide-cd generates media changed continuously if there's no media in the drive, which can lead to infinite loop of events jumping back and forth between the driver and userland event handler. This patch updates disk event infrastructure such that it never propagates events not listed in disk->events to userland. Those events are processed the same for internal purposes but uevent generation is suppressed. This also ensures that userland only gets events which are advertised in the @events sysfs node lowering risk of confusion. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- diff --git a/block/genhd.c b/block/genhd.c index b364bd038a1..2dd988723d7 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1588,9 +1588,13 @@ static void disk_events_workfn(struct work_struct *work) spin_unlock_irq(&ev->lock); - /* tell userland about new events */ + /* + * Tell userland about new events. Only the events listed in + * @disk->events are reported. Unlisted events are processed the + * same internally but never get reported to userland. + */ for (i = 0; i < ARRAY_SIZE(disk_uevents); i++) - if (events & (1 << i)) + if (events & disk->events & (1 << i)) envp[nr_events++] = disk_uevents[i]; if (nr_events)