From patchwork Thu Apr 21 17:08:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 92427 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9116FB701E for ; Fri, 22 Apr 2011 03:08:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754954Ab1DURIc (ORCPT ); Thu, 21 Apr 2011 13:08:32 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:61267 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754914Ab1DURIb (ORCPT ); Thu, 21 Apr 2011 13:08:31 -0400 Received: by fxm17 with SMTP id 17so1054799fxm.19 for ; Thu, 21 Apr 2011 10:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:date:from:to:cc:subject:message-id :mime-version:content-type:content-disposition:user-agent; bh=y65wDyxOELuLavz5CooFZH6UAvVnayP/OsE0DGFZXuo=; b=kxHX+9VYQ9iOd18Vvsc3Qjmkt4rLQRsELS7iu1Uu9xEzHZtL8fDex7vCAot1WDuZiR 3bles5AdM0acFwiqDooyt0Qn49XWCZg7In8YFJmpD+MSEknDg8pbU7T8x1U4e21wUGJL bL9Q6Jn2Ybo5hwXUlAsGK6sqnDXM13eqNcMr0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=ffAE4KVQWC/lU1pODj1MYo1AB/qa1oMBBPJCBTQ4zAm39EIUHyQjheqUwwbXE81dH3 tm7f76ntD20WPxxQ0B6B/LgJow4WZLjKtLAwX5GFCEAovM5lCKLuAjv/+gQUXQRmWvIq DuLvEUdeSAMn9XG6znfUoBDpFM81QlKVQFKFg= Received: by 10.223.76.205 with SMTP id d13mr171025fak.110.1303405709755; Thu, 21 Apr 2011 10:08:29 -0700 (PDT) Received: from htj.dyndns.org ([130.75.117.88]) by mx.google.com with ESMTPS id k5sm653718faa.15.2011.04.21.10.08.28 (version=SSLv3 cipher=OTHER); Thu, 21 Apr 2011 10:08:28 -0700 (PDT) Date: Thu, 21 Apr 2011 19:08:26 +0200 From: Tejun Heo To: Jens Axboe Cc: Linus Torvalds , Christoph Hellwig , Neil Brown , "David S. Miller" , linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, kay.sievers@vrfy.org Subject: [PATCH 1/2] block: don't propagate unlisted DISK_EVENTs to userland Message-ID: <20110421170826.GC15988@htj.dyndns.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org 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 Tested-by: Shaun Ruffell --- These two patches fix infinite MEDIA_CHANGE events problem reported w/ ide-cd. I tried an alternate patch to implement proper check_events() for ide-cd but given the deprecated status of ide and the existence of fallback userland event polling, this minimal approach seems better. Thank you. block/genhd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: work/block/genhd.c =================================================================== --- work.orig/block/genhd.c +++ work/block/genhd.c @@ -1588,9 +1588,13 @@ static void disk_events_workfn(struct wo 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)