You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
block: remove GENHD_FL_EXT_DEVT
All modern drivers can support extra partitions using the extended dev_t. In fact except for the ioctl method drivers never even see partitions in normal operation. So remove the GENHD_FL_EXT_DEVT and allow extra partitions for all block devices that do support partitions, and require those that do not support partitions to explicit disallow them using GENHD_FL_NO_PART. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20211122130625.1136848-12-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
3b5149ac50
commit
1ebe2e5f9d
@@ -376,7 +376,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
|
||||
{
|
||||
struct block_device *bdev;
|
||||
|
||||
if (!disk_part_scan_enabled(disk))
|
||||
if (disk->flags & GENHD_FL_NO_PART)
|
||||
return -EINVAL;
|
||||
if (disk->open_partitions)
|
||||
return -EBUSY;
|
||||
@@ -438,7 +438,6 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
|
||||
return ret;
|
||||
disk->major = BLOCK_EXT_MAJOR;
|
||||
disk->first_minor = ret;
|
||||
disk->flags |= GENHD_FL_EXT_DEVT;
|
||||
}
|
||||
|
||||
ret = disk_alloc_events(disk);
|
||||
@@ -872,7 +871,8 @@ static ssize_t disk_ext_range_show(struct device *dev,
|
||||
{
|
||||
struct gendisk *disk = dev_to_disk(dev);
|
||||
|
||||
return sprintf(buf, "%d\n", disk_max_parts(disk));
|
||||
return sprintf(buf, "%d\n",
|
||||
(disk->flags & GENHD_FL_NO_PART) ? 1 : DISK_MAX_PARTS);
|
||||
}
|
||||
|
||||
static ssize_t disk_removable_show(struct device *dev,
|
||||
|
||||
@@ -98,13 +98,12 @@ static void bdev_set_nr_sectors(struct block_device *bdev, sector_t sectors)
|
||||
static struct parsed_partitions *allocate_partitions(struct gendisk *hd)
|
||||
{
|
||||
struct parsed_partitions *state;
|
||||
int nr;
|
||||
int nr = DISK_MAX_PARTS;
|
||||
|
||||
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
if (!state)
|
||||
return NULL;
|
||||
|
||||
nr = disk_max_parts(hd);
|
||||
state->parts = vzalloc(array_size(nr, sizeof(state->parts[0])));
|
||||
if (!state->parts) {
|
||||
kfree(state);
|
||||
@@ -326,7 +325,7 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
|
||||
|
||||
lockdep_assert_held(&disk->open_mutex);
|
||||
|
||||
if (partno >= disk_max_parts(disk))
|
||||
if (partno >= DISK_MAX_PARTS)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
/*
|
||||
@@ -604,7 +603,7 @@ static int blk_add_partitions(struct gendisk *disk)
|
||||
struct parsed_partitions *state;
|
||||
int ret = -EAGAIN, p;
|
||||
|
||||
if (!disk_part_scan_enabled(disk))
|
||||
if (disk->flags & GENHD_FL_NO_PART)
|
||||
return 0;
|
||||
|
||||
state = check_partition(disk);
|
||||
@@ -687,7 +686,7 @@ rescan:
|
||||
* userspace for this particular setup.
|
||||
*/
|
||||
if (invalidate) {
|
||||
if (disk_part_scan_enabled(disk) ||
|
||||
if (!(disk->flags & GENHD_FL_NO_PART) ||
|
||||
!(disk->flags & GENHD_FL_REMOVABLE))
|
||||
set_capacity(disk, 0);
|
||||
}
|
||||
|
||||
@@ -1790,6 +1790,7 @@ static int fd_alloc_disk(int drive, int system)
|
||||
disk->first_minor = drive + system;
|
||||
disk->minors = 1;
|
||||
disk->fops = &floppy_fops;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
if (system)
|
||||
sprintf(disk->disk_name, "fd%d_msdos", drive);
|
||||
|
||||
@@ -2000,6 +2000,7 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type)
|
||||
disk->minors = 1;
|
||||
sprintf(disk->disk_name, "fd%d", drive);
|
||||
disk->fops = &floppy_fops;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
disk->private_data = &unit[drive];
|
||||
set_capacity(disk, MAX_DISK_SIZE * 2);
|
||||
|
||||
@@ -405,7 +405,6 @@ static int brd_alloc(int i)
|
||||
disk->minors = max_part;
|
||||
disk->fops = &brd_fops;
|
||||
disk->private_data = brd;
|
||||
disk->flags = GENHD_FL_EXT_DEVT;
|
||||
strlcpy(disk->disk_name, buf, DISK_NAME_LEN);
|
||||
set_capacity(disk, rd_size * 2);
|
||||
|
||||
|
||||
@@ -2734,6 +2734,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
|
||||
disk->first_minor = minor;
|
||||
disk->minors = 1;
|
||||
disk->fops = &drbd_ops;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
sprintf(disk->disk_name, "drbd%d", minor);
|
||||
disk->private_data = device;
|
||||
|
||||
|
||||
@@ -4503,6 +4503,7 @@ static int floppy_alloc_disk(unsigned int drive, unsigned int type)
|
||||
disk->first_minor = TOMINOR(drive) | (type << 2);
|
||||
disk->minors = 1;
|
||||
disk->fops = &floppy_fops;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
if (type)
|
||||
sprintf(disk->disk_name, "fd%d_type%d", drive, type);
|
||||
|
||||
@@ -2033,7 +2033,6 @@ static int loop_add(int i)
|
||||
*/
|
||||
if (!part_shift)
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->flags |= GENHD_FL_EXT_DEVT;
|
||||
atomic_set(&lo->lo_refcnt, 0);
|
||||
mutex_init(&lo->lo_mutex);
|
||||
lo->lo_number = i;
|
||||
|
||||
@@ -1850,7 +1850,6 @@ static int null_gendisk_register(struct nullb *nullb)
|
||||
|
||||
set_capacity(disk, size);
|
||||
|
||||
disk->flags |= GENHD_FL_EXT_DEVT;
|
||||
disk->major = null_major;
|
||||
disk->first_minor = nullb->index;
|
||||
disk->minors = 1;
|
||||
|
||||
@@ -928,6 +928,7 @@ static int pcd_init_unit(struct pcd_unit *cd, bool autoprobe, int port,
|
||||
disk->minors = 1;
|
||||
strcpy(disk->disk_name, cd->name); /* umm... */
|
||||
disk->fops = &pcd_bdops;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
disk->event_flags = DISK_EVENT_FLAG_BLOCK_ON_EXCL_WRITE;
|
||||
|
||||
|
||||
@@ -942,6 +942,7 @@ static int __init pf_init_unit(struct pf_unit *pf, bool autoprobe, int port,
|
||||
disk->minors = 1;
|
||||
strcpy(disk->disk_name, pf->name);
|
||||
disk->fops = &pf_fops;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
disk->private_data = pf;
|
||||
|
||||
|
||||
@@ -2719,7 +2719,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
|
||||
disk->first_minor = idx;
|
||||
disk->minors = 1;
|
||||
disk->fops = &pktcdvd_ops;
|
||||
disk->flags = GENHD_FL_REMOVABLE;
|
||||
disk->flags = GENHD_FL_REMOVABLE | GENHD_FL_NO_PART;
|
||||
strcpy(disk->disk_name, pd->name);
|
||||
disk->private_data = pd;
|
||||
|
||||
|
||||
@@ -742,6 +742,7 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev)
|
||||
priv->gendisk = gendisk;
|
||||
gendisk->major = ps3vram_major;
|
||||
gendisk->minors = 1;
|
||||
gendisk->flags |= GENHD_FL_NO_PART;
|
||||
gendisk->fops = &ps3vram_fops;
|
||||
gendisk->private_data = dev;
|
||||
strlcpy(gendisk->disk_name, DEVICE_NAME, sizeof(gendisk->disk_name));
|
||||
|
||||
@@ -4924,12 +4924,10 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
|
||||
rbd_dev->dev_id);
|
||||
disk->major = rbd_dev->major;
|
||||
disk->first_minor = rbd_dev->minor;
|
||||
if (single_major) {
|
||||
if (single_major)
|
||||
disk->minors = (1 << RBD_SINGLE_MAJOR_PART_SHIFT);
|
||||
disk->flags |= GENHD_FL_EXT_DEVT;
|
||||
} else {
|
||||
else
|
||||
disk->minors = RBD_MINORS_PER_MAJOR;
|
||||
}
|
||||
disk->fops = &rbd_bd_ops;
|
||||
disk->private_data = rbd_dev;
|
||||
|
||||
|
||||
@@ -840,6 +840,7 @@ static int swim_floppy_init(struct swim_priv *swd)
|
||||
swd->unit[drive].disk->minors = 1;
|
||||
sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive);
|
||||
swd->unit[drive].disk->fops = &floppy_fops;
|
||||
swd->unit[drive].disk->flags |= GENHD_FL_NO_PART;
|
||||
swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
swd->unit[drive].disk->private_data = &swd->unit[drive];
|
||||
set_capacity(swd->unit[drive].disk, 2880);
|
||||
|
||||
@@ -1227,7 +1227,7 @@ static int swim3_attach(struct macio_dev *mdev,
|
||||
disk->fops = &floppy_fops;
|
||||
disk->private_data = fs;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
disk->flags |= GENHD_FL_REMOVABLE;
|
||||
disk->flags |= GENHD_FL_REMOVABLE | GENHD_FL_NO_PART;
|
||||
sprintf(disk->disk_name, "fd%d", floppy_count);
|
||||
set_capacity(disk, 2880);
|
||||
rc = add_disk(disk);
|
||||
|
||||
@@ -843,7 +843,6 @@ static int virtblk_probe(struct virtio_device *vdev)
|
||||
vblk->disk->minors = 1 << PART_BITS;
|
||||
vblk->disk->private_data = vblk;
|
||||
vblk->disk->fops = &virtblk_fops;
|
||||
vblk->disk->flags |= GENHD_FL_EXT_DEVT;
|
||||
vblk->index = index;
|
||||
|
||||
/* configure queue flush support */
|
||||
|
||||
@@ -327,6 +327,7 @@ static int z2ram_register_disk(int minor)
|
||||
disk->major = Z2RAM_MAJOR;
|
||||
disk->first_minor = minor;
|
||||
disk->minors = 1;
|
||||
disk->flags |= GENHD_FL_NO_PART;
|
||||
disk->fops = &z2_fops;
|
||||
if (minor)
|
||||
sprintf(disk->disk_name, "z2ram%d", minor);
|
||||
|
||||
@@ -1947,6 +1947,7 @@ static int zram_add(void)
|
||||
zram->disk->major = zram_major;
|
||||
zram->disk->first_minor = device_id;
|
||||
zram->disk->minors = 1;
|
||||
zram->disk->flags |= GENHD_FL_NO_PART;
|
||||
zram->disk->fops = &zram_devops;
|
||||
zram->disk->private_data = zram;
|
||||
snprintf(zram->disk->disk_name, 16, "zram%d", device_id);
|
||||
|
||||
@@ -719,6 +719,7 @@ static void probe_gdrom_setupdisk(void)
|
||||
gd.disk->major = gdrom_major;
|
||||
gd.disk->first_minor = 1;
|
||||
gd.disk->minors = 1;
|
||||
gd.disk->flags |= GENHD_FL_NO_PART;
|
||||
strcpy(gd.disk->disk_name, GDROM_DEV_NAME);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user