diff options
author | Tejun Heo <tj@kernel.org> | 2011-08-23 14:01:04 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-08-23 14:01:04 -0400 |
commit | d27769ec3df1a8de9ca450d2dcd72d1ab259ba32 (patch) | |
tree | f17c064e0d8ac26fa80c1c72dccaca053bb55e94 | |
parent | 322a8b034003c0d46d39af85bf24fee27b902f48 (diff) |
block: add GENHD_FL_NO_PART_SCAN
There are cases where suppressing partition scan is useful - e.g. for
lo devices and pseudo SATA devices which advertise to be a disk but
get upset on partition scan (some port multiplier control devices show
such behavior).
This patch adds GENHD_FL_NO_PART_SCAN which suppresses partition scan
regardless of the number of possible partitions. disk_partitionable()
is renamed to disk_part_scan_enabled() as suppressing partition scan
doesn't imply the device can't be partitioned using
BLKPG_ADD/DEL_PARTITION calls from userland. show_partition() now
directly tests disk_max_parts() to maintain backward-compatibility.
-v2: Updated to make it clear that only partition scan is suppressed
not partitioning itself as suggested by Kay Sievers.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
-rw-r--r-- | block/genhd.c | 4 | ||||
-rw-r--r-- | block/ioctl.c | 2 | ||||
-rw-r--r-- | fs/block_dev.c | 2 | ||||
-rw-r--r-- | include/linux/genhd.h | 6 |
4 files changed, 8 insertions, 6 deletions
diff --git a/block/genhd.c b/block/genhd.c index 5cb51c55f6d8..2429ecbbd97d 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -536,7 +536,7 @@ void register_disk(struct gendisk *disk) | |||
536 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); | 536 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); |
537 | 537 | ||
538 | /* No minors to use for partitions */ | 538 | /* No minors to use for partitions */ |
539 | if (!disk_partitionable(disk)) | 539 | if (!disk_part_scan_enabled(disk)) |
540 | goto exit; | 540 | goto exit; |
541 | 541 | ||
542 | /* No such device (e.g., media were just removed) */ | 542 | /* No such device (e.g., media were just removed) */ |
@@ -841,7 +841,7 @@ static int show_partition(struct seq_file *seqf, void *v) | |||
841 | char buf[BDEVNAME_SIZE]; | 841 | char buf[BDEVNAME_SIZE]; |
842 | 842 | ||
843 | /* Don't show non-partitionable removeable devices or empty devices */ | 843 | /* Don't show non-partitionable removeable devices or empty devices */ |
844 | if (!get_capacity(sgp) || (!disk_partitionable(sgp) && | 844 | if (!get_capacity(sgp) || (!disk_max_parts(sgp) && |
845 | (sgp->flags & GENHD_FL_REMOVABLE))) | 845 | (sgp->flags & GENHD_FL_REMOVABLE))) |
846 | return 0; | 846 | return 0; |
847 | if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO) | 847 | if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO) |
diff --git a/block/ioctl.c b/block/ioctl.c index 1124cd297263..5c74efc01903 100644 --- a/block/ioctl.c +++ b/block/ioctl.c | |||
@@ -101,7 +101,7 @@ static int blkdev_reread_part(struct block_device *bdev) | |||
101 | struct gendisk *disk = bdev->bd_disk; | 101 | struct gendisk *disk = bdev->bd_disk; |
102 | int res; | 102 | int res; |
103 | 103 | ||
104 | if (!disk_partitionable(disk) || bdev != bdev->bd_contains) | 104 | if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains) |
105 | return -EINVAL; | 105 | return -EINVAL; |
106 | if (!capable(CAP_SYS_ADMIN)) | 106 | if (!capable(CAP_SYS_ADMIN)) |
107 | return -EACCES; | 107 | return -EACCES; |
diff --git a/fs/block_dev.c b/fs/block_dev.c index ff77262e887c..0bed0d4588dd 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -971,7 +971,7 @@ static void flush_disk(struct block_device *bdev, bool kill_dirty) | |||
971 | 971 | ||
972 | if (!bdev->bd_disk) | 972 | if (!bdev->bd_disk) |
973 | return; | 973 | return; |
974 | if (disk_partitionable(bdev->bd_disk)) | 974 | if (disk_part_scan_enabled(bdev->bd_disk)) |
975 | bdev->bd_invalidated = 1; | 975 | bdev->bd_invalidated = 1; |
976 | } | 976 | } |
977 | 977 | ||
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 02fa4697a0e5..6d18f3531f18 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -128,6 +128,7 @@ struct hd_struct { | |||
128 | #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ | 128 | #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ |
129 | #define GENHD_FL_NATIVE_CAPACITY 128 | 129 | #define GENHD_FL_NATIVE_CAPACITY 128 |
130 | #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256 | 130 | #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256 |
131 | #define GENHD_FL_NO_PART_SCAN 512 | ||
131 | 132 | ||
132 | enum { | 133 | enum { |
133 | DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */ | 134 | DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */ |
@@ -234,9 +235,10 @@ static inline int disk_max_parts(struct gendisk *disk) | |||
234 | return disk->minors; | 235 | return disk->minors; |
235 | } | 236 | } |
236 | 237 | ||
237 | static inline bool disk_partitionable(struct gendisk *disk) | 238 | static inline bool disk_part_scan_enabled(struct gendisk *disk) |
238 | { | 239 | { |
239 | return disk_max_parts(disk) > 1; | 240 | return disk_max_parts(disk) > 1 && |
241 | !(disk->flags & GENHD_FL_NO_PART_SCAN); | ||
240 | } | 242 | } |
241 | 243 | ||
242 | static inline dev_t disk_devt(struct gendisk *disk) | 244 | static inline dev_t disk_devt(struct gendisk *disk) |