Re: [PATCH 11/14] block: remove GENHD_FL_EXT_DEVT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Christoph,

On Mon, Nov 22, 2021 at 02:06:22PM +0100, Christoph Hellwig wrote:
> 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@xxxxxx>
> ---
>  block/genhd.c                  |  6 +++---
>  block/partitions/core.c        |  9 ++++-----
>  drivers/block/amiflop.c        |  1 +
>  drivers/block/ataflop.c        |  1 +
>  drivers/block/brd.c            |  1 -
>  drivers/block/drbd/drbd_main.c |  1 +
>  drivers/block/floppy.c         |  1 +
>  drivers/block/loop.c           |  1 -
>  drivers/block/null_blk/main.c  |  1 -
>  drivers/block/paride/pcd.c     |  1 +
>  drivers/block/paride/pf.c      |  1 +
>  drivers/block/pktcdvd.c        |  2 +-
>  drivers/block/ps3vram.c        |  1 +
>  drivers/block/rbd.c            |  6 ++----
>  drivers/block/swim.c           |  1 +
>  drivers/block/swim3.c          |  2 +-
>  drivers/block/virtio_blk.c     |  1 -
>  drivers/block/z2ram.c          |  1 +
>  drivers/block/zram/zram_drv.c  |  1 +
>  drivers/cdrom/gdrom.c          |  1 +
>  drivers/md/dm.c                |  1 +
>  drivers/md/md.c                |  5 -----
>  drivers/mmc/core/block.c       |  1 -
>  drivers/mtd/ubi/block.c        |  1 +
>  drivers/scsi/sd.c              |  1 -
>  drivers/scsi/sr.c              |  1 +
>  include/linux/genhd.h          | 28 +++++-----------------------
>  27 files changed, 30 insertions(+), 48 deletions(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 09abd41249fd4..e9346fae48ad4 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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);

The above change breaks parted on loop, which reads 'ext_range' to add
partitions.

Follows the test case:

	fallocate -l 4096M loop0.img
	losetup /dev/loop0 loop0.img
	parted -s /dev/loop0 mklabel MSDOS
	parted -s /dev/loop0 mkpart pri 1 1248

Since this patch is merged, /dev/loop0p1 can't be created any more
by above script.



Thanks,
Ming




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux