From patchwork Thu Mar 18 13:58:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 86749 Received: from mx01.colomx.prod.int.phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2IFmiSt015522 for ; Thu, 18 Mar 2010 15:49:20 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IFgGhm008206; Thu, 18 Mar 2010 11:42:17 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IDwciD026082 for ; Thu, 18 Mar 2010 09:58:38 -0400 Received: from localhost.localdomain (vpn2-9-191.ams2.redhat.com [10.36.9.191]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IDwUlB012053; Thu, 18 Mar 2010 09:58:32 -0400 From: Milan Broz To: dm-devel@redhat.com, kay.sievers@vrfy.org Date: Thu, 18 Mar 2010 14:58:13 +0100 Message-Id: <1268920694-10960-2-git-send-email-mbroz@redhat.com> In-Reply-To: <1268920694-10960-1-git-send-email-mbroz@redhat.com> References: <1268920694-10960-1-git-send-email-mbroz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 18 Mar 2010 11:42:14 -0400 Cc: Milan Broz Subject: [dm-devel] [PATCH 2/3] Add genhd flag requesting notification of partition changes only. 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: , MIME-Version: 1.0 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.3 (demeter.kernel.org [140.211.167.41]); Thu, 18 Mar 2010 15:49:20 +0000 (UTC) diff --git a/block/ioctl.c b/block/ioctl.c index be48ea5..77faed3 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -101,7 +101,8 @@ static int blkdev_reread_part(struct block_device *bdev) struct gendisk *disk = bdev->bd_disk; int res; - if (!disk_partitionable(disk) || bdev != bdev->bd_contains) + if (!disk_userspace_partitions(disk) && + (!disk_partitionable(disk) || bdev != bdev->bd_contains)) return -EINVAL; if (!capable(CAP_SYS_ADMIN)) return -EACCES; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 7b364d7..57da1f7 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1934,6 +1934,7 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); md->disk->flags |= GENHD_FL_SUPPRESS_ADD_EVENT; + md->disk->flags |= GENHD_FL_PARTITION_CHANGE_NOTIFY; add_disk(md->disk); format_dev_t(md->name, MKDEV(_major, minor)); diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 916173b..b66253f 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -548,6 +548,12 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) struct parsed_partitions *state; int p, highest, res; + /* partitions handled in userspace, just send change event */ + if (disk_userspace_partitions(disk)) { + kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); + return 0; + } + if (bdev->bd_part_count) return -EBUSY; res = invalidate_partition(disk, 0); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index ade71ff..64b25f0 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -118,6 +118,9 @@ struct hd_struct { #define GENHD_FL_NATIVE_CAPACITY 128 #define GENHD_FL_SUPPRESS_ADD_EVENT 256 +/* notify udev instead of use in-kernel partitioning */ +#define GENHD_FL_PARTITION_CHANGE_NOTIFY 512 + #define BLK_SCSI_MAX_CMDS (256) #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) @@ -182,6 +185,11 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part) return NULL; } +static inline bool disk_userspace_partitions(struct gendisk *disk) +{ + return (disk->flags & GENHD_FL_PARTITION_CHANGE_NOTIFY) ? 1 : 0; +} + static inline int disk_max_parts(struct gendisk *disk) { if (disk->flags & GENHD_FL_EXT_DEVT)