1 From: Hannes Reinecke <hare@suse.de>
2 Subject: Implement 'no_partition_scan' commandline option
5 Under certain setups the partition table on the disk is not
6 useable directly (eg for dmraid or multipathing). So we should
7 be able to switch it off completely so as not to be flooded with
10 Signed-off-by: Hannes Reinecke <hare@suse.de>
13 block/genhd.c | 38 ++++++++++++++++++++++++++++++++++++--
14 fs/partitions/check.c | 2 ++
15 include/linux/genhd.h | 1 +
16 3 files changed, 39 insertions(+), 2 deletions(-)
20 @@ -173,6 +173,18 @@ static int exact_lock(dev_t devt, void *
24 +static int __read_mostly no_partition_scan;
26 +static int __init no_partition_scan_setup(char *str)
28 + no_partition_scan = 1;
29 + printk(KERN_INFO "genhd: omit partition scan.\n");
34 +__setup("no_partition_scan", no_partition_scan_setup);
37 * add_disk - add partitioning information to kernel list
38 * @disk: per-device partitioning information
39 @@ -186,6 +198,8 @@ void add_disk(struct gendisk *disk)
42 disk->flags |= GENHD_FL_UP;
43 + if (no_partition_scan)
44 + disk->flags |= GENHD_FL_NO_PARTITION_SCAN;
45 blk_register_region(MKDEV(disk->major, disk->first_minor),
46 disk->minors, NULL, exact_match, exact_lock, disk);
48 @@ -429,7 +443,27 @@ static ssize_t disk_range_show(struct de
50 struct gendisk *disk = dev_to_disk(dev);
52 - return sprintf(buf, "%d\n", disk->minors);
53 + return sprintf(buf, "%d\n",
54 + (disk->flags & GENHD_FL_NO_PARTITION_SCAN ? 0 : disk->minors));
57 +static ssize_t disk_range_store(struct device *dev,
58 + struct device_attribute *attr,
59 + const char *buf, size_t count)
61 + struct gendisk *disk = dev_to_disk(dev);
64 + if (count > 0 && sscanf(buf, "%d", &i) > 0) {
66 + disk->flags |= GENHD_FL_NO_PARTITION_SCAN;
67 + else if (i <= disk->minors)
68 + disk->flags &= ~GENHD_FL_NO_PARTITION_SCAN;
76 static ssize_t disk_removable_show(struct device *dev,
77 @@ -519,7 +553,7 @@ static ssize_t disk_fail_store(struct de
81 -static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
82 +static DEVICE_ATTR(range, S_IRUGO|S_IWUSR, disk_range_show, disk_range_store);
83 static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
84 static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL);
85 static DEVICE_ATTR(size, S_IRUGO, disk_size_show, NULL);
86 --- a/fs/partitions/check.c
87 +++ b/fs/partitions/check.c
88 @@ -486,6 +486,8 @@ int rescan_partitions(struct gendisk *di
89 disk->fops->revalidate_disk(disk);
90 check_disk_size_change(disk, bdev);
91 bdev->bd_invalidated = 0;
92 + if (disk->flags & GENHD_FL_NO_PARTITION_SCAN)
94 if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
96 if (IS_ERR(state)) /* I/O error reading the partition table */
97 --- a/include/linux/genhd.h
98 +++ b/include/linux/genhd.h
99 @@ -109,6 +109,7 @@ struct hd_struct {
100 #define GENHD_FL_UP 16
101 #define GENHD_FL_SUPPRESS_PARTITION_INFO 32
102 #define GENHD_FL_FAIL 64
103 +#define GENHD_FL_NO_PARTITION_SCAN 128
106 int major; /* major number of driver */