mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
block: switch ->getgeo() to struct gendisk
Instances are happier that way and it makes more sense anyway - the only part of the result that is related to partition we are given is the start sector, and that has been filled in by the caller. Everything else is a function of the disk. Only one instance (DASD) is ever looking at anything other than bdev->bd_disk and that one is trivial to adjust. Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
3eb50369c0
commit
4fc8728aa3
27 changed files with 59 additions and 59 deletions
|
|
@ -443,7 +443,7 @@ prototypes::
|
|||
int (*direct_access) (struct block_device *, sector_t, void **,
|
||||
unsigned long *);
|
||||
void (*unlock_native_capacity) (struct gendisk *);
|
||||
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
||||
int (*getgeo)(struct gendisk *, struct hd_geometry *);
|
||||
void (*swap_slot_free_notify) (struct block_device *, unsigned long);
|
||||
|
||||
locking rules:
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ static void nfhd_submit_bio(struct bio *bio)
|
|||
bio_endio(bio);
|
||||
}
|
||||
|
||||
static int nfhd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int nfhd_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct nfhd_device *dev = bdev->bd_disk->private_data;
|
||||
struct nfhd_device *dev = disk->private_data;
|
||||
|
||||
geo->cylinders = dev->blocks >> (6 - dev->bshift);
|
||||
geo->heads = 4;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ static DEFINE_MUTEX(ubd_lock);
|
|||
|
||||
static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||
unsigned int cmd, unsigned long arg);
|
||||
static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
|
||||
static int ubd_getgeo(struct gendisk *disk, struct hd_geometry *geo);
|
||||
|
||||
#define MAX_DEV (16)
|
||||
|
||||
|
|
@ -1324,9 +1324,9 @@ static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
|
|||
return res;
|
||||
}
|
||||
|
||||
static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int ubd_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct ubd *ubd_dev = bdev->bd_disk->private_data;
|
||||
struct ubd *ubd_dev = disk->private_data;
|
||||
|
||||
geo->heads = 128;
|
||||
geo->sectors = 32;
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ static int blkdev_getgeo(struct block_device *bdev,
|
|||
*/
|
||||
memset(&geo, 0, sizeof(geo));
|
||||
geo.start = get_start_sect(bdev);
|
||||
ret = disk->fops->getgeo(bdev, &geo);
|
||||
ret = disk->fops->getgeo(disk, &geo);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (copy_to_user(argp, &geo, sizeof(geo)))
|
||||
|
|
@ -515,7 +515,7 @@ static int compat_hdio_getgeo(struct block_device *bdev,
|
|||
* want to override it.
|
||||
*/
|
||||
geo.start = get_start_sect(bdev);
|
||||
ret = disk->fops->getgeo(bdev, &geo);
|
||||
ret = disk->fops->getgeo(disk, &geo);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ int ibm_partition(struct parsed_partitions *state)
|
|||
goto out_nolab;
|
||||
/* set start if not filled by getgeo function e.g. virtblk */
|
||||
geo->start = get_start_sect(bdev);
|
||||
if (disk->fops->getgeo(bdev, geo))
|
||||
if (disk->fops->getgeo(disk, geo))
|
||||
goto out_freeall;
|
||||
if (!fn || fn(disk, info)) {
|
||||
kfree(info);
|
||||
|
|
|
|||
|
|
@ -1523,13 +1523,13 @@ static blk_status_t amiflop_queue_rq(struct blk_mq_hw_ctx *hctx,
|
|||
return BLK_STS_OK;
|
||||
}
|
||||
|
||||
static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int fd_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
int drive = MINOR(bdev->bd_dev) & 3;
|
||||
struct amiga_floppy_struct *p = disk->private_data;
|
||||
|
||||
geo->heads = unit[drive].type->heads;
|
||||
geo->sectors = unit[drive].dtype->sects * unit[drive].type->sect_mult;
|
||||
geo->cylinders = unit[drive].type->tracks;
|
||||
geo->heads = p->type->heads;
|
||||
geo->sectors = p->dtype->sects * p->type->sect_mult;
|
||||
geo->cylinders = p->type->tracks;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -269,9 +269,9 @@ static blk_status_t aoeblk_queue_rq(struct blk_mq_hw_ctx *hctx,
|
|||
}
|
||||
|
||||
static int
|
||||
aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
aoeblk_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct aoedev *d = bdev->bd_disk->private_data;
|
||||
struct aoedev *d = disk->private_data;
|
||||
|
||||
if ((d->flags & DEVFL_UP) == 0) {
|
||||
printk(KERN_ERR "aoe: disk not up\n");
|
||||
|
|
|
|||
|
|
@ -3363,9 +3363,9 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int fd_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
int drive = (long)bdev->bd_disk->private_data;
|
||||
int drive = (long)disk->private_data;
|
||||
int type = ITYPE(drive_state[drive].fd_device);
|
||||
struct floppy_struct *g;
|
||||
int ret;
|
||||
|
|
|
|||
|
|
@ -3148,17 +3148,17 @@ static int mtip_block_compat_ioctl(struct block_device *dev,
|
|||
* that each partition is also 4KB aligned. Non-aligned partitions adversely
|
||||
* affects performance.
|
||||
*
|
||||
* @dev Pointer to the block_device strucutre.
|
||||
* @disk Pointer to the gendisk strucutre.
|
||||
* @geo Pointer to a hd_geometry structure.
|
||||
*
|
||||
* return value
|
||||
* 0 Operation completed successfully.
|
||||
* -ENOTTY An error occurred while reading the drive capacity.
|
||||
*/
|
||||
static int mtip_block_getgeo(struct block_device *dev,
|
||||
static int mtip_block_getgeo(struct gendisk *disk,
|
||||
struct hd_geometry *geo)
|
||||
{
|
||||
struct driver_data *dd = dev->bd_disk->private_data;
|
||||
struct driver_data *dd = disk->private_data;
|
||||
sector_t capacity;
|
||||
|
||||
if (!dd)
|
||||
|
|
|
|||
|
|
@ -942,11 +942,11 @@ static void rnbd_client_release(struct gendisk *gen)
|
|||
rnbd_clt_put_dev(dev);
|
||||
}
|
||||
|
||||
static int rnbd_client_getgeo(struct block_device *block_device,
|
||||
static int rnbd_client_getgeo(struct gendisk *disk,
|
||||
struct hd_geometry *geo)
|
||||
{
|
||||
u64 size;
|
||||
struct rnbd_clt_dev *dev = block_device->bd_disk->private_data;
|
||||
struct rnbd_clt_dev *dev = disk->private_data;
|
||||
struct queue_limits *limit = &dev->queue->limits;
|
||||
|
||||
size = dev->size * (limit->logical_block_size / SECTOR_SIZE);
|
||||
|
|
|
|||
|
|
@ -119,9 +119,8 @@ static inline u32 vdc_tx_dring_avail(struct vio_dring_state *dr)
|
|||
return vio_dring_avail(dr, VDC_TX_RING_SIZE);
|
||||
}
|
||||
|
||||
static int vdc_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int vdc_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct gendisk *disk = bdev->bd_disk;
|
||||
sector_t nsect = get_capacity(disk);
|
||||
sector_t cylinders = nsect;
|
||||
|
||||
|
|
|
|||
|
|
@ -711,9 +711,9 @@ static int floppy_ioctl(struct block_device *bdev, blk_mode_t mode,
|
|||
return -ENOTTY;
|
||||
}
|
||||
|
||||
static int floppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int floppy_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct floppy_state *fs = bdev->bd_disk->private_data;
|
||||
struct floppy_state *fs = disk->private_data;
|
||||
struct floppy_struct *g;
|
||||
int ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -829,9 +829,9 @@ out:
|
|||
}
|
||||
|
||||
/* We provide getgeo only to please some old bootloader/partitioning tools */
|
||||
static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
|
||||
static int virtblk_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct virtio_blk *vblk = bd->bd_disk->private_data;
|
||||
struct virtio_blk *vblk = disk->private_data;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&vblk->vdev_mutex);
|
||||
|
|
@ -853,7 +853,7 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
|
|||
/* some standard values, similar to sd */
|
||||
geo->heads = 1 << 6;
|
||||
geo->sectors = 1 << 5;
|
||||
geo->cylinders = get_capacity(bd->bd_disk) >> 11;
|
||||
geo->cylinders = get_capacity(disk) >> 11;
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&vblk->vdev_mutex);
|
||||
|
|
|
|||
|
|
@ -493,11 +493,11 @@ static void blkif_restart_queue_callback(void *arg)
|
|||
schedule_work(&rinfo->work);
|
||||
}
|
||||
|
||||
static int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg)
|
||||
static int blkif_getgeo(struct gendisk *disk, struct hd_geometry *hg)
|
||||
{
|
||||
/* We don't have real geometry info, but let's at least return
|
||||
values consistent with the size of the device */
|
||||
sector_t nsect = get_capacity(bd->bd_disk);
|
||||
sector_t nsect = get_capacity(disk);
|
||||
sector_t cylinders = nsect;
|
||||
|
||||
hg->heads = 0xff;
|
||||
|
|
|
|||
|
|
@ -403,9 +403,9 @@ static void do_deferred_remove(struct work_struct *w)
|
|||
dm_deferred_remove();
|
||||
}
|
||||
|
||||
static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int dm_blk_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct mapped_device *md = bdev->bd_disk->private_data;
|
||||
struct mapped_device *md = disk->private_data;
|
||||
|
||||
return dm_get_geometry(md, geo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7678,9 +7678,9 @@ static int set_disk_faulty(struct mddev *mddev, dev_t dev)
|
|||
* 4 sectors (with a BIG number of cylinders...). This drives
|
||||
* dosfs just mad... ;-)
|
||||
*/
|
||||
static int md_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int md_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct mddev *mddev = bdev->bd_disk->private_data;
|
||||
struct mddev *mddev = disk->private_data;
|
||||
|
||||
geo->heads = 2;
|
||||
geo->sectors = 4;
|
||||
|
|
|
|||
|
|
@ -1953,10 +1953,10 @@ static void msb_data_clear(struct msb_data *msb)
|
|||
msb->card = NULL;
|
||||
}
|
||||
|
||||
static int msb_bd_getgeo(struct block_device *bdev,
|
||||
static int msb_bd_getgeo(struct gendisk *disk,
|
||||
struct hd_geometry *geo)
|
||||
{
|
||||
struct msb_data *msb = bdev->bd_disk->private_data;
|
||||
struct msb_data *msb = disk->private_data;
|
||||
*geo = msb->geometry;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,10 +189,10 @@ static void mspro_block_bd_free_disk(struct gendisk *disk)
|
|||
kfree(msb);
|
||||
}
|
||||
|
||||
static int mspro_block_bd_getgeo(struct block_device *bdev,
|
||||
static int mspro_block_bd_getgeo(struct gendisk *disk,
|
||||
struct hd_geometry *geo)
|
||||
{
|
||||
struct mspro_block_data *msb = bdev->bd_disk->private_data;
|
||||
struct mspro_block_data *msb = disk->private_data;
|
||||
|
||||
geo->heads = msb->heads;
|
||||
geo->sectors = msb->sectors_per_track;
|
||||
|
|
|
|||
|
|
@ -435,9 +435,9 @@ static void mmc_blk_release(struct gendisk *disk)
|
|||
}
|
||||
|
||||
static int
|
||||
mmc_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
mmc_blk_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16);
|
||||
geo->cylinders = get_capacity(disk) / (4 * 16);
|
||||
geo->heads = 4;
|
||||
geo->sectors = 16;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -246,9 +246,9 @@ unlock:
|
|||
blktrans_dev_put(dev);
|
||||
}
|
||||
|
||||
static int blktrans_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int blktrans_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct mtd_blktrans_dev *dev = bdev->bd_disk->private_data;
|
||||
struct mtd_blktrans_dev *dev = disk->private_data;
|
||||
int ret = -ENXIO;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
|
|
|||
|
|
@ -282,12 +282,12 @@ static void ubiblock_release(struct gendisk *gd)
|
|||
mutex_unlock(&dev->dev_mutex);
|
||||
}
|
||||
|
||||
static int ubiblock_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int ubiblock_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
/* Some tools might require this information */
|
||||
geo->heads = 1;
|
||||
geo->cylinders = 1;
|
||||
geo->sectors = get_capacity(bdev->bd_disk);
|
||||
geo->sectors = get_capacity(disk);
|
||||
geo->start = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1478,12 +1478,12 @@ static void btt_submit_bio(struct bio *bio)
|
|||
bio_endio(bio);
|
||||
}
|
||||
|
||||
static int btt_getgeo(struct block_device *bd, struct hd_geometry *geo)
|
||||
static int btt_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
/* some standard values */
|
||||
geo->heads = 1 << 6;
|
||||
geo->sectors = 1 << 5;
|
||||
geo->cylinders = get_capacity(bd->bd_disk) >> 11;
|
||||
geo->cylinders = get_capacity(disk) >> 11;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1803,12 +1803,12 @@ static void nvme_release(struct gendisk *disk)
|
|||
nvme_ns_release(disk->private_data);
|
||||
}
|
||||
|
||||
int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
int nvme_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
/* some standard values */
|
||||
geo->heads = 1 << 6;
|
||||
geo->sectors = 1 << 5;
|
||||
geo->cylinders = get_capacity(bdev->bd_disk) >> 11;
|
||||
geo->cylinders = get_capacity(disk) >> 11;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -936,7 +936,7 @@ int nvme_ns_head_chr_uring_cmd(struct io_uring_cmd *ioucmd,
|
|||
unsigned int issue_flags);
|
||||
int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
|
||||
struct nvme_id_ns **id);
|
||||
int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo);
|
||||
int nvme_getgeo(struct gendisk *disk, struct hd_geometry *geo);
|
||||
int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags);
|
||||
|
||||
extern const struct attribute_group *nvme_ns_attr_groups[];
|
||||
|
|
|
|||
|
|
@ -3317,11 +3317,11 @@ static void dasd_release(struct gendisk *disk)
|
|||
/*
|
||||
* Return disk geometry.
|
||||
*/
|
||||
static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int dasd_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct dasd_device *base;
|
||||
|
||||
base = dasd_device_from_gendisk(bdev->bd_disk);
|
||||
base = dasd_device_from_gendisk(disk);
|
||||
if (!base)
|
||||
return -ENODEV;
|
||||
|
||||
|
|
@ -3331,7 +3331,8 @@ static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
|||
return -EINVAL;
|
||||
}
|
||||
base->discipline->fill_geometry(base->block, geo);
|
||||
geo->start = get_start_sect(bdev) >> base->block->s2b_shift;
|
||||
// geo->start is left unchanged by the above
|
||||
geo->start >>= base->block->s2b_shift;
|
||||
dasd_put_device(base);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1599,9 +1599,9 @@ static void sd_release(struct gendisk *disk)
|
|||
scsi_device_put(sdev);
|
||||
}
|
||||
|
||||
static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
||||
static int sd_getgeo(struct gendisk *disk, struct hd_geometry *geo)
|
||||
{
|
||||
struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk);
|
||||
struct scsi_disk *sdkp = scsi_disk(disk);
|
||||
struct scsi_device *sdp = sdkp->device;
|
||||
struct Scsi_Host *host = sdp->host;
|
||||
sector_t capacity = logical_to_sectors(sdp, sdkp->capacity);
|
||||
|
|
@ -1614,9 +1614,9 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
|||
|
||||
/* override with calculated, extended default, or driver values */
|
||||
if (host->hostt->bios_param)
|
||||
host->hostt->bios_param(sdp, bdev->bd_disk, capacity, diskinfo);
|
||||
host->hostt->bios_param(sdp, disk, capacity, diskinfo);
|
||||
else
|
||||
scsicam_bios_param(bdev->bd_disk, capacity, diskinfo);
|
||||
scsicam_bios_param(disk, capacity, diskinfo);
|
||||
|
||||
geo->heads = diskinfo[0];
|
||||
geo->sectors = diskinfo[1];
|
||||
|
|
|
|||
|
|
@ -1659,7 +1659,7 @@ struct block_device_operations {
|
|||
unsigned int (*check_events) (struct gendisk *disk,
|
||||
unsigned int clearing);
|
||||
void (*unlock_native_capacity) (struct gendisk *);
|
||||
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
||||
int (*getgeo)(struct gendisk *, struct hd_geometry *);
|
||||
int (*set_read_only)(struct block_device *bdev, bool ro);
|
||||
void (*free_disk)(struct gendisk *disk);
|
||||
/* this callback is with swap_lock and sometimes page table lock held */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue