Skip to content

Commit 689d6fa

Browse files
htejunJens Axboe
authored andcommitted
block: replace @ext_minors with GENHD_FL_EXT_DEVT
With previous changes, it's meaningless to limit the number of partitions. Replace @ext_minors with GENHD_FL_EXT_DEVT such that setting the flag allows the disk to have maximum number of allowed partitions (only limited by the number of entries in parsed_partitions as determined by MAX_PART constant). This kills not-too-pretty alloc_disk_ext[_node]() functions and makes @minors parameter to alloc_disk[_node]() unnecessary. The parameter is left alone to avoid disturbing the users. Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 540eed5 commit 689d6fa

File tree

5 files changed

+17
-42
lines changed

5 files changed

+17
-42
lines changed

block/genhd.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,18 +1024,9 @@ struct gendisk *alloc_disk(int minors)
10241024
{
10251025
return alloc_disk_node(minors, -1);
10261026
}
1027+
EXPORT_SYMBOL(alloc_disk);
10271028

10281029
struct gendisk *alloc_disk_node(int minors, int node_id)
1029-
{
1030-
return alloc_disk_ext_node(minors, 0, node_id);
1031-
}
1032-
1033-
struct gendisk *alloc_disk_ext(int minors, int ext_minors)
1034-
{
1035-
return alloc_disk_ext_node(minors, ext_minors, -1);
1036-
}
1037-
1038-
struct gendisk *alloc_disk_ext_node(int minors, int ext_minors, int node_id)
10391030
{
10401031
struct gendisk *disk;
10411032

@@ -1054,7 +1045,6 @@ struct gendisk *alloc_disk_ext_node(int minors, int ext_minors, int node_id)
10541045
disk->part_tbl->part[0] = &disk->part0;
10551046

10561047
disk->minors = minors;
1057-
disk->ext_minors = ext_minors;
10581048
rand_initialize_disk(disk);
10591049
disk_to_dev(disk)->class = &block_class;
10601050
disk_to_dev(disk)->type = &disk_type;
@@ -1065,11 +1055,7 @@ struct gendisk *alloc_disk_ext_node(int minors, int ext_minors, int node_id)
10651055
}
10661056
return disk;
10671057
}
1068-
1069-
EXPORT_SYMBOL(alloc_disk);
10701058
EXPORT_SYMBOL(alloc_disk_node);
1071-
EXPORT_SYMBOL(alloc_disk_ext);
1072-
EXPORT_SYMBOL(alloc_disk_ext_node);
10731059

10741060
struct kobject *get_disk(struct gendisk *disk)
10751061
{

drivers/ide/ide-disk.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,12 @@
4141
#include <asm/io.h>
4242
#include <asm/div64.h>
4343

44-
#define IDE_DISK_PARTS (1 << PARTN_BITS)
45-
4644
#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
47-
#define IDE_DISK_MINORS IDE_DISK_PARTS
45+
#define IDE_DISK_MINORS (1 << PARTN_BITS)
4846
#else
4947
#define IDE_DISK_MINORS 1
5048
#endif
5149

52-
#define IDE_DISK_EXT_MINORS (IDE_DISK_PARTS - IDE_DISK_MINORS)
53-
5450
struct ide_disk_obj {
5551
ide_drive_t *drive;
5652
ide_driver_t *driver;
@@ -1161,8 +1157,7 @@ static int ide_disk_probe(ide_drive_t *drive)
11611157
if (!idkp)
11621158
goto failed;
11631159

1164-
g = alloc_disk_ext_node(IDE_DISK_MINORS, IDE_DISK_EXT_MINORS,
1165-
hwif_to_node(drive->hwif));
1160+
g = alloc_disk_node(IDE_DISK_MINORS, hwif_to_node(drive->hwif));
11661161
if (!g)
11671162
goto out_free_idkp;
11681163

@@ -1189,9 +1184,10 @@ static int ide_disk_probe(ide_drive_t *drive)
11891184
drive->attach = 1;
11901185

11911186
g->minors = IDE_DISK_MINORS;
1192-
g->ext_minors = IDE_DISK_EXT_MINORS;
11931187
g->driverfs_dev = &drive->gendev;
1194-
g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
1188+
g->flags |= GENHD_FL_EXT_DEVT;
1189+
if (drive->removable)
1190+
g->flags |= GENHD_FL_REMOVABLE;
11951191
set_capacity(g, idedisk_capacity(drive));
11961192
g->fops = &idedisk_ops;
11971193
add_disk(g);

drivers/scsi/sd.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,12 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);
8686
MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
8787
MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
8888

89-
#define SD_PARTS 64
90-
9189
#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
9290
#define SD_MINORS 16
9391
#else
9492
#define SD_MINORS 1
9593
#endif
9694

97-
#define SD_EXT_MINORS (SD_PARTS - SD_MINORS)
98-
9995
static int sd_revalidate_disk(struct gendisk *);
10096
static int sd_probe(struct device *);
10197
static int sd_remove(struct device *);
@@ -1811,7 +1807,7 @@ static int sd_probe(struct device *dev)
18111807
if (!sdkp)
18121808
goto out;
18131809

1814-
gd = alloc_disk_ext(SD_MINORS, SD_EXT_MINORS);
1810+
gd = alloc_disk(SD_MINORS);
18151811
if (!gd)
18161812
goto out_free;
18171813

@@ -1856,7 +1852,6 @@ static int sd_probe(struct device *dev)
18561852
gd->major = sd_major((index & 0xf0) >> 4);
18571853
gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
18581854
gd->minors = SD_MINORS;
1859-
gd->ext_minors = SD_EXT_MINORS;
18601855
gd->fops = &sd_fops;
18611856

18621857
if (index < 26) {
@@ -1880,7 +1875,7 @@ static int sd_probe(struct device *dev)
18801875
blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
18811876

18821877
gd->driverfs_dev = &sdp->sdev_gendev;
1883-
gd->flags = GENHD_FL_DRIVERFS;
1878+
gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS;
18841879
if (sdp->removable)
18851880
gd->flags |= GENHD_FL_REMOVABLE;
18861881

fs/partitions/check.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
* add_gd_partition adds a partitions details to the devices partition
66
* description.
77
*/
8-
enum { MAX_PART = 256 };
9-
108
struct parsed_partitions {
119
char name[BDEVNAME_SIZE];
1210
struct {
1311
sector_t from;
1412
sector_t size;
1513
int flags;
16-
} parts[MAX_PART];
14+
} parts[DISK_MAX_PARTS];
1715
int next;
1816
int limit;
1917
};

include/linux/genhd.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ enum {
5858
UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */
5959
};
6060

61+
#define DISK_MAX_PARTS 256
62+
6163
#include <linux/major.h>
6264
#include <linux/device.h>
6365
#include <linux/smp.h>
@@ -112,6 +114,7 @@ struct hd_struct {
112114
#define GENHD_FL_CD 8
113115
#define GENHD_FL_UP 16
114116
#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
117+
#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */
115118

116119
#define BLK_SCSI_MAX_CMDS (256)
117120
#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
@@ -129,15 +132,13 @@ struct disk_part_tbl {
129132
};
130133

131134
struct gendisk {
132-
/* major, first_minor, minors and ext_minors are input
133-
* parameters only, don't use directly. Use disk_devt() and
134-
* disk_max_parts().
135+
/* major, first_minor and minors are input parameters only,
136+
* don't use directly. Use disk_devt() and disk_max_parts().
135137
*/
136138
int major; /* major number of driver */
137139
int first_minor;
138140
int minors; /* maximum number of minors, =1 for
139141
* disks that can't be partitioned. */
140-
int ext_minors; /* number of extended dynamic minors */
141142

142143
char disk_name[32]; /* name of major driver */
143144

@@ -180,7 +181,9 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part)
180181

181182
static inline int disk_max_parts(struct gendisk *disk)
182183
{
183-
return disk->minors + disk->ext_minors;
184+
if (disk->flags & GENHD_FL_EXT_DEVT)
185+
return DISK_MAX_PARTS;
186+
return disk->minors;
184187
}
185188

186189
static inline bool disk_partitionable(struct gendisk *disk)
@@ -527,9 +530,6 @@ extern void printk_all_partitions(void);
527530

528531
extern struct gendisk *alloc_disk_node(int minors, int node_id);
529532
extern struct gendisk *alloc_disk(int minors);
530-
extern struct gendisk *alloc_disk_ext_node(int minors, int ext_minrs,
531-
int node_id);
532-
extern struct gendisk *alloc_disk_ext(int minors, int ext_minors);
533533
extern struct kobject *get_disk(struct gendisk *disk);
534534
extern void put_disk(struct gendisk *disk);
535535
extern void blk_register_region(dev_t devt, unsigned long range,

0 commit comments

Comments
 (0)