Skip to content

Commit

Permalink
block: remove the minors argument to __alloc_disk_node
Browse files Browse the repository at this point in the history
This was a leftover from the legacy alloc_disk interface.  Switch
the scsi ULPs and dasd to set ->minors directly like all other
drivers and remove the argument.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>	[dasd]
Link: https://lore.kernel.org/r/20210816131910.615153-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Aug 23, 2021
1 parent 9c2b9db commit a58bd76
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -3143,7 +3143,7 @@ struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata,
if (IS_ERR(q))
return ERR_CAST(q);

disk = __alloc_disk_node(0, set->numa_node, lkclass);
disk = __alloc_disk_node(set->numa_node, lkclass);
if (!disk) {
blk_cleanup_queue(q);
return ERR_PTR(-ENOMEM);
Expand Down
6 changes: 2 additions & 4 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,8 +1254,7 @@ dev_t blk_lookup_devt(const char *name, int partno)
return devt;
}

struct gendisk *__alloc_disk_node(int minors, int node_id,
struct lock_class_key *lkclass)
struct gendisk *__alloc_disk_node(int node_id, struct lock_class_key *lkclass)
{
struct gendisk *disk;

Expand All @@ -1277,7 +1276,6 @@ struct gendisk *__alloc_disk_node(int minors, int node_id,
if (xa_insert(&disk->part_tbl, 0, disk->part0, GFP_KERNEL))
goto out_destroy_part_tbl;

disk->minors = minors;
rand_initialize_disk(disk);
disk_to_dev(disk)->class = &block_class;
disk_to_dev(disk)->type = &disk_type;
Expand Down Expand Up @@ -1309,7 +1307,7 @@ struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass)
if (!q)
return NULL;

disk = __alloc_disk_node(0, node, lkclass);
disk = __alloc_disk_node(node, lkclass);
if (!disk) {
blk_cleanup_queue(q);
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions drivers/s390/block/dasd_genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ int dasd_gendisk_alloc(struct dasd_block *block)
if (base->devindex >= DASD_PER_MAJOR)
return -EBUSY;

gdp = __alloc_disk_node(1 << DASD_PARTN_BITS, NUMA_NO_NODE,
&dasd_bio_compl_lkclass);
gdp = __alloc_disk_node(NUMA_NO_NODE, &dasd_bio_compl_lkclass);
if (!gdp)
return -ENOMEM;

/* Initialize gendisk structure. */
gdp->major = DASD_MAJOR;
gdp->first_minor = base->devindex << DASD_PARTN_BITS;
gdp->minors = 1 << DASD_PARTN_BITS;
gdp->fops = &dasd_device_operations;

/*
Expand Down
3 changes: 2 additions & 1 deletion drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3409,7 +3409,7 @@ static int sd_probe(struct device *dev)
if (!sdkp)
goto out;

gd = __alloc_disk_node(SD_MINORS, NUMA_NO_NODE, &sd_bio_compl_lkclass);
gd = __alloc_disk_node(NUMA_NO_NODE, &sd_bio_compl_lkclass);
if (!gd)
goto out_free;

Expand Down Expand Up @@ -3455,6 +3455,7 @@ static int sd_probe(struct device *dev)

gd->major = sd_major((index & 0xf0) >> 4);
gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
gd->minors = SD_MINORS;

gd->fops = &sd_fops;
gd->private_data = &sdkp->driver;
Expand Down
3 changes: 2 additions & 1 deletion drivers/scsi/sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ static int sr_probe(struct device *dev)

kref_init(&cd->kref);

disk = __alloc_disk_node(1, NUMA_NO_NODE, &sr_bio_compl_lkclass);
disk = __alloc_disk_node(NUMA_NO_NODE, &sr_bio_compl_lkclass);
if (!disk)
goto fail_free;
mutex_init(&cd->lock);
Expand All @@ -731,6 +731,7 @@ static int sr_probe(struct device *dev)

disk->major = SCSI_CDROM_MAJOR;
disk->first_minor = minor;
disk->minors = 1;
sprintf(disk->disk_name, "sr%d", minor);
disk->fops = &sr_bdops;
disk->flags = GENHD_FL_CD | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
Expand Down
3 changes: 1 addition & 2 deletions include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ static inline sector_t get_capacity(struct gendisk *disk)
int bdev_disk_changed(struct gendisk *disk, bool invalidate);
void blk_drop_partitions(struct gendisk *disk);

struct gendisk *__alloc_disk_node(int minors, int node_id,
struct lock_class_key *lkclass);
struct gendisk *__alloc_disk_node(int node_id, struct lock_class_key *lkclass);
extern void put_disk(struct gendisk *disk);
struct gendisk *__blk_alloc_disk(int node, struct lock_class_key *lkclass);

Expand Down

0 comments on commit a58bd76

Please sign in to comment.