From patchwork Tue Jul 26 15:48:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kay Sievers X-Patchwork-Id: 1008812 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6QFp58s023976 for ; Tue, 26 Jul 2011 15:51:27 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6QFmJX1018756; Tue, 26 Jul 2011 11:48:21 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6QFmImA001838 for ; Tue, 26 Jul 2011 11:48:18 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6QFmDov008224; Tue, 26 Jul 2011 11:48:13 -0400 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6QFmALm015728; Tue, 26 Jul 2011 11:48:11 -0400 Received: by vws1 with SMTP id 1so567597vws.33 for ; Tue, 26 Jul 2011 08:48:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrfy.org; s=google; h=subject:from:to:cc:date:in-reply-to:references:content-type :x-mailer:content-transfer-encoding:message-id:mime-version; bh=vznvZYczAHhuIFEj86/s/X9Rqf0iHziN/q/CG8Hx/ms=; b=XvGODxeSixzkMgo+XoWhzPeMRiyY+Rp69cHDku1SUQMfvJtf4FcjSv5ppAgtLdPlkS hEnMKWnPy2YVM85P1rTLpJQH1Lx9RN3Zsu8uARgYr6WlpTth9/ecRgWCkNLbid+gl/tc wgNaO9ZyS187AazKVVv1FSJAQParPCX6mx7kc= Received: by 10.52.176.229 with SMTP id cl5mr2137149vdc.318.1311695290697; Tue, 26 Jul 2011 08:48:10 -0700 (PDT) Received: from [192.168.178.34] (hmbg-4d06c3f7.pool.mediaWays.net [77.6.195.247]) by mx.google.com with ESMTPS id dh9sm257626vdc.46.2011.07.26.08.48.08 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jul 2011 08:48:09 -0700 (PDT) From: Kay Sievers To: Zdenek Kabelac Date: Tue, 26 Jul 2011 17:48:06 +0200 In-Reply-To: References: <4E2987AE.2070707@redhat.com> <1311553130.1671.21.camel@mop> <4E2D4177.9000402@redhat.com> <4E2D678E.2010209@redhat.com> Message-ID: <1311695289.1325.9.camel@mop> Mime-Version: 1.0 X-RedHat-Spam-Score: -0.8 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com Cc: Greg KH , device-mapper development , LKML Subject: Re: [dm-devel] [PATCH] Reduce number of KOBJ_REMOVE events X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 26 Jul 2011 15:51:27 +0000 (UTC) On Mon, 2011-07-25 at 16:22 +0200, Kay Sievers wrote: > On Mon, Jul 25, 2011 at 14:54, Zdenek Kabelac wrote: > > Dne 25.7.2011 14:17, Kay Sievers napsal(a): > > >>>> Then have 'dm_blk_dops' add '.uevent' and let the core call into the dm > >>>> code to the needed properties to the 'remove' event, instead of sending > >>>> its own, and see the duplication. > >>> > >>> Sounds like complex solution > >> > >> I don't think so, It's clean, ~30 lines long, and technically correct, I expect. > > In include/linux/blkdev.h add: > int (*uevent) (struct gendisk *, struct kobj_uevent_env *env); > to > struct block_device_operations > > In block/genhd.c add: > .uevent = block_uevent; > to > struct class block_class > and have the block_uevent() callback check for an existing uevent() in > the block_device_operations, call it when it's specified. > > In drivers/md/dm.c add: > .dm_uevent; > to > struct block_device_operations dm_blk_dops > and add all the needed variables there, instead of sending out a faked > device 'remove' event. Here is the code to illustrate, and fix the issue of needing to send any 'remove' for a device from a driver. Thanks, Kay --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/genhd.c b/block/genhd.c index 6024b82..c2e9714 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1097,8 +1097,21 @@ static void disk_release(struct device *dev) free_part_info(&disk->part0); kfree(disk); } + +static int block_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct gendisk *disk = dev_to_disk(dev); + + if (!disk->fops) + return 0; + if (disk->fops->uevent) + return disk->fops->uevent(disk, env); + return 0; +} + struct class block_class = { .name = "block", + .dev_uevent = block_uevent, }; static char *block_devnode(struct device *dev, mode_t *mode) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 0cf68b4..22e486e 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2682,11 +2682,17 @@ void dm_free_md_mempools(struct dm_md_mempools *pools) kfree(pools); } +static int dm_uevent(struct gendisk *disk, struct kobj_uevent_env *env) +{ + return add_uevent_var(env, "COOKIE_MONSTER=1"); +} + static const struct block_device_operations dm_blk_dops = { .open = dm_blk_open, .release = dm_blk_close, .ioctl = dm_blk_ioctl, .getgeo = dm_blk_getgeo, + .uevent = dm_uevent, .owner = THIS_MODULE }; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1a23722..6dbd69e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1300,6 +1300,7 @@ struct block_device_operations { void **, unsigned long *); unsigned int (*check_events) (struct gendisk *disk, unsigned int clearing); + int (*uevent) (struct gendisk *, struct kobj_uevent_env *env); /* ->media_changed() is DEPRECATED, use ->check_events() instead */ int (*media_changed) (struct gendisk *); void (*unlock_native_capacity) (struct gendisk *);