qubes-linux-kernel/patches.suse/no-partition-scan

109 lines
3.2 KiB
Plaintext
Raw Normal View History

From: Hannes Reinecke <hare@suse.de>
Subject: Implement 'no_partition_scan' commandline option
Refences: FATE#303697
Patch-mainline: Not yet
Under certain setups the partition table on the disk is not
useable directly (eg for dmraid or multipathing). So we should
be able to switch it off completely so as not to be flooded with
pointless messages.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
block/genhd.c | 39 +++++++++++++++++++++++++++++++++++++--
fs/partitions/check.c | 2 ++
include/linux/genhd.h | 1 +
3 files changed, 40 insertions(+), 2 deletions(-)
--- a/block/genhd.c
+++ b/block/genhd.c
2011-04-19 20:09:59 +00:00
@@ -504,6 +504,18 @@ static int exact_lock(dev_t devt, void *
disk_part_iter_exit(&piter);
}
+static int __read_mostly no_partition_scan;
+
+static int __init no_partition_scan_setup(char *str)
+{
+ no_partition_scan = 1;
+ printk(KERN_INFO "genhd: omit partition scan.\n");
+
+ return 1;
+}
+
+__setup("no_partition_scan", no_partition_scan_setup);
+
/**
* add_disk - add partitioning information to kernel list
* @disk: per-device partitioning information
2011-04-19 20:09:59 +00:00
@@ -528,6 +540,9 @@ void add_disk(struct gendisk *disk)
disk->flags |= GENHD_FL_UP;
+ if (no_partition_scan)
+ disk->flags |= GENHD_FL_NO_PARTITION_SCAN;
+
retval = blk_alloc_devt(&disk->part0, &devt);
if (retval) {
WARN_ON(1);
2011-04-19 20:09:59 +00:00
@@ -817,7 +832,27 @@ static ssize_t disk_range_show(struct de
{
struct gendisk *disk = dev_to_disk(dev);
- return sprintf(buf, "%d\n", disk->minors);
+ return sprintf(buf, "%d\n",
+ (disk->flags & GENHD_FL_NO_PARTITION_SCAN ? 0 : disk->minors));
+}
+
+static ssize_t disk_range_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct gendisk *disk = dev_to_disk(dev);
+ int i;
+
+ if (count > 0 && sscanf(buf, "%d", &i) > 0) {
+ if (i == 0)
+ disk->flags |= GENHD_FL_NO_PARTITION_SCAN;
+ else if (i <= disk->minors)
+ disk->flags &= ~GENHD_FL_NO_PARTITION_SCAN;
+ else
+ count = -EINVAL;
+ }
+
+ return count;
}
static ssize_t disk_ext_range_show(struct device *dev,
2011-04-19 20:09:59 +00:00
@@ -871,7 +906,7 @@ static ssize_t disk_discard_alignment_sh
return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
}
-static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
+static DEVICE_ATTR(range, S_IRUGO|S_IWUSR, disk_range_show, disk_range_store);
static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL);
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
2011-04-19 20:09:59 +00:00
@@ -597,6 +597,8 @@ rescan:
disk->fops->revalidate_disk(disk);
check_disk_size_change(disk, bdev);
bdev->bd_invalidated = 0;
+ if (disk->flags & GENHD_FL_NO_PARTITION_SCAN)
+ return 0;
if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
return 0;
2011-04-19 20:09:59 +00:00
if (IS_ERR(state)) {
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
2011-04-19 20:09:59 +00:00
@@ -116,6 +116,7 @@ struct hd_struct {
#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */
#define GENHD_FL_NATIVE_CAPACITY 128
+#define GENHD_FL_NO_PARTITION_SCAN 256
2011-04-19 20:09:59 +00:00
enum {
DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */