-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy path0006-block-add-no_part_scan-module-parameter.patch
48 lines (42 loc) · 1.65 KB
/
0006-block-add-no_part_scan-module-parameter.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 9dd3b03210805ce0f76327cc18f7d07a40b275a2 Mon Sep 17 00:00:00 2001
From: Rusty Bird <[email protected]>
Date: Mon, 11 Jul 2016 13:05:38 +0000
Subject: [PATCH] block: add no_part_scan module parameter
Define a boolean module parameter named "no_part_scan" defaulting to N,
which, if set to Y, always causes the GENHD_FL_NO_PART_SCAN flag to be
added to subsequently created block devices, thereby disabling the
kernel's various partition table parsers for them.
The parameter's current value can be changed at any time by writing to
the /sys/module/block/parameters/no_part_scan file.
---
block/genhd.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/block/genhd.c b/block/genhd.c
index 79230c109fca..292a7c8c2188 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -382,6 +382,14 @@ int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
return ret;
}
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "block."
+
+/* partition scanning policy */
+static bool disk_no_part_scan = 0;
+module_param_named(no_part_scan, disk_no_part_scan, bool, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(no_part_scan, "When adding block devices, always mark them as not to be scanned for partitions");
+
/**
* add_disk_fwnode - add disk information to kernel list with fwnode
* @parent: parent device for the disk
@@ -412,6 +420,9 @@ int __must_check add_disk_fwnode(struct device *parent, struct gendisk *disk,
*/
elevator_init_mq(disk->queue);
+ if (disk_no_part_scan)
+ disk->flags |= GENHD_FL_NO_PART;
+
/* Mark bdev as having a submit_bio, if needed */
if (disk->fops->submit_bio)
bdev_set_flag(disk->part0, BD_HAS_SUBMIT_BIO);
--
2.46.0