]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Hannes Reinecke <hare@suse.de> |
2 | Subject: Implement 'no_partition_scan' commandline option | |
3 | Refences: FATE#303697 | |
4 | ||
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 | |
8 | pointless messages. | |
9 | ||
10 | Signed-off-by: Hannes Reinecke <hare@suse.de> | |
11 | ||
12 | --- | |
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(-) | |
17 | ||
18 | --- a/block/genhd.c | |
19 | +++ b/block/genhd.c | |
20 | @@ -173,6 +173,18 @@ static int exact_lock(dev_t devt, void * | |
21 | return 0; | |
22 | } | |
23 | ||
24 | +static int __read_mostly no_partition_scan; | |
25 | + | |
26 | +static int __init no_partition_scan_setup(char *str) | |
27 | +{ | |
28 | + no_partition_scan = 1; | |
29 | + printk(KERN_INFO "genhd: omit partition scan.\n"); | |
30 | + | |
31 | + return 1; | |
32 | +} | |
33 | + | |
34 | +__setup("no_partition_scan", no_partition_scan_setup); | |
35 | + | |
36 | /** | |
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) | |
40 | int retval; | |
41 | ||
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); | |
47 | register_disk(disk); | |
48 | @@ -429,7 +443,27 @@ static ssize_t disk_range_show(struct de | |
49 | { | |
50 | struct gendisk *disk = dev_to_disk(dev); | |
51 | ||
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)); | |
55 | +} | |
56 | + | |
57 | +static ssize_t disk_range_store(struct device *dev, | |
58 | + struct device_attribute *attr, | |
59 | + const char *buf, size_t count) | |
60 | +{ | |
61 | + struct gendisk *disk = dev_to_disk(dev); | |
62 | + int i; | |
63 | + | |
64 | + if (count > 0 && sscanf(buf, "%d", &i) > 0) { | |
65 | + if (i == 0) | |
66 | + disk->flags |= GENHD_FL_NO_PARTITION_SCAN; | |
67 | + else if (i <= disk->minors) | |
68 | + disk->flags &= ~GENHD_FL_NO_PARTITION_SCAN; | |
69 | + else | |
70 | + count = -EINVAL; | |
71 | + } | |
72 | + | |
73 | + return count; | |
74 | } | |
75 | ||
76 | static ssize_t disk_removable_show(struct device *dev, | |
77 | @@ -519,7 +553,7 @@ static ssize_t disk_fail_store(struct de | |
78 | ||
79 | #endif | |
80 | ||
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) | |
93 | + return 0; | |
94 | if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) | |
95 | return 0; | |
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 | |
104 | ||
105 | struct gendisk { | |
106 | int major; /* major number of driver */ |