block: automatically enable GENHD_FL_EXT_DEVT
authorChristoph Hellwig <hch@lst.de>
Fri, 21 May 2021 05:50:53 +0000 (07:50 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 1 Jun 2021 13:42:23 +0000 (07:42 -0600)
Automatically set the GENHD_FL_EXT_DEVT flag for all disks allocated
without an explicit number of minors.  This is what all new block
drivers should do, so make sure it is the default without boilerplate
code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c
block/partitions/core.c
drivers/block/n64cart.c
drivers/lightnvm/core.c
drivers/memstick/core/ms_block.c
drivers/nvdimm/blk.c
drivers/nvdimm/btt.c
drivers/nvdimm/pmem.c
drivers/nvme/host/core.c
drivers/nvme/host/multipath.c

index 8c1816d..9fa734c 100644 (file)
@@ -497,7 +497,6 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
                }
        } else {
                WARN_ON(disk->minors);
-               WARN_ON(!(disk->flags & (GENHD_FL_EXT_DEVT | GENHD_FL_HIDDEN)));
 
                ret = blk_alloc_ext_minor();
                if (ret < 0) {
@@ -506,6 +505,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
                }
                disk->major = BLOCK_EXT_MAJOR;
                disk->first_minor = MINOR(ret);
+               disk->flags |= GENHD_FL_EXT_DEVT;
        }
 
        disk->flags |= GENHD_FL_UP;
index 504297b..ada3e1e 100644 (file)
@@ -326,10 +326,6 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
        const char *dname;
        int err;
 
-       /*
-        * disk_max_parts() won't be zero, either GENHD_FL_EXT_DEVT is set
-        * or 'minors' is passed to alloc_disk().
-        */
        if (partno >= disk_max_parts(disk))
                return ERR_PTR(-EINVAL);
 
index 47bdf32..3dae4b6 100644 (file)
@@ -141,7 +141,7 @@ static int __init n64cart_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        disk->first_minor = 0;
-       disk->flags = GENHD_FL_NO_PART_SCAN | GENHD_FL_EXT_DEVT;
+       disk->flags = GENHD_FL_NO_PART_SCAN;
        disk->fops = &n64cart_fops;
        disk->private_data = &pdev->dev;
        strcpy(disk->disk_name, "n64cart");
index 40a948c..e7dc539 100644 (file)
@@ -383,7 +383,6 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
        }
 
        strlcpy(tdisk->disk_name, create->tgtname, sizeof(tdisk->disk_name));
-       tdisk->flags = GENHD_FL_EXT_DEVT;
        tdisk->major = 0;
        tdisk->first_minor = 0;
        tdisk->fops = tt->bops;
index 8004dd6..0bacf42 100644 (file)
@@ -2136,7 +2136,6 @@ static int msb_init_disk(struct memstick_dev *card)
        msb->disk->fops = &msb_bdops;
        msb->disk->private_data = msb;
        msb->disk->queue = msb->queue;
-       msb->disk->flags |= GENHD_FL_EXT_DEVT;
 
        capacity = msb->pages_in_block * msb->logical_block_count;
        capacity *= (msb->page_size / 512);
index 7b95562..7ba446d 100644 (file)
@@ -267,7 +267,6 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
        disk->first_minor       = 0;
        disk->fops              = &nd_blk_fops;
        disk->queue             = q;
-       disk->flags             = GENHD_FL_EXT_DEVT;
        disk->private_data      = nsblk;
        nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name);
 
index 18a267d..1741a7b 100644 (file)
@@ -1537,7 +1537,6 @@ static int btt_blk_init(struct btt *btt)
        btt->btt_disk->fops = &btt_fops;
        btt->btt_disk->private_data = btt;
        btt->btt_disk->queue = btt->btt_queue;
-       btt->btt_disk->flags = GENHD_FL_EXT_DEVT;
 
        blk_queue_logical_block_size(btt->btt_queue, btt->sector_size);
        blk_queue_max_hw_sectors(btt->btt_queue, UINT_MAX);
index ed10a8b..968b848 100644 (file)
@@ -477,7 +477,6 @@ static int pmem_attach_disk(struct device *dev,
 
        disk->fops              = &pmem_fops;
        disk->queue             = q;
-       disk->flags             = GENHD_FL_EXT_DEVT;
        disk->private_data      = pmem;
        nvdimm_namespace_disk_name(ndns, disk->disk_name);
        set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
index 762125f..24bcae8 100644 (file)
@@ -3699,7 +3699,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
        disk->fops = &nvme_bdev_ops;
        disk->private_data = ns;
        disk->queue = ns->queue;
-       disk->flags = GENHD_FL_EXT_DEVT;
        /*
         * Without the multipath code enabled, multiple controller per
         * subsystems are visible as devices and thus we cannot use the
index f81871c..a5d02f2 100644 (file)
@@ -462,7 +462,6 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
        head->disk->fops = &nvme_ns_head_ops;
        head->disk->private_data = head;
        head->disk->queue = q;
-       head->disk->flags = GENHD_FL_EXT_DEVT;
        sprintf(head->disk->disk_name, "nvme%dn%d",
                        ctrl->subsys->instance, head->instance);
        return 0;