Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Al Viro 4fc8728a 3eb50369

+59 -59
+1 -1
Documentation/filesystems/locking.rst
··· 443 443 int (*direct_access) (struct block_device *, sector_t, void **, 444 444 unsigned long *); 445 445 void (*unlock_native_capacity) (struct gendisk *); 446 - int (*getgeo)(struct block_device *, struct hd_geometry *); 446 + int (*getgeo)(struct gendisk *, struct hd_geometry *); 447 447 void (*swap_slot_free_notify) (struct block_device *, unsigned long); 448 448 449 449 locking rules:
+2 -2
arch/m68k/emu/nfblock.c
··· 77 77 bio_endio(bio); 78 78 } 79 79 80 - static int nfhd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 80 + static int nfhd_getgeo(struct gendisk *disk, struct hd_geometry *geo) 81 81 { 82 - struct nfhd_device *dev = bdev->bd_disk->private_data; 82 + struct nfhd_device *dev = disk->private_data; 83 83 84 84 geo->cylinders = dev->blocks >> (6 - dev->bshift); 85 85 geo->heads = 4;
+3 -3
arch/um/drivers/ubd_kern.c
··· 108 108 109 109 static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode, 110 110 unsigned int cmd, unsigned long arg); 111 - static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo); 111 + static int ubd_getgeo(struct gendisk *disk, struct hd_geometry *geo); 112 112 113 113 #define MAX_DEV (16) 114 114 ··· 1324 1324 return res; 1325 1325 } 1326 1326 1327 - static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 1327 + static int ubd_getgeo(struct gendisk *disk, struct hd_geometry *geo) 1328 1328 { 1329 - struct ubd *ubd_dev = bdev->bd_disk->private_data; 1329 + struct ubd *ubd_dev = disk->private_data; 1330 1330 1331 1331 geo->heads = 128; 1332 1332 geo->sectors = 32;
+2 -2
block/ioctl.c
··· 481 481 */ 482 482 memset(&geo, 0, sizeof(geo)); 483 483 geo.start = get_start_sect(bdev); 484 - ret = disk->fops->getgeo(bdev, &geo); 484 + ret = disk->fops->getgeo(disk, &geo); 485 485 if (ret) 486 486 return ret; 487 487 if (copy_to_user(argp, &geo, sizeof(geo))) ··· 515 515 * want to override it. 516 516 */ 517 517 geo.start = get_start_sect(bdev); 518 - ret = disk->fops->getgeo(bdev, &geo); 518 + ret = disk->fops->getgeo(disk, &geo); 519 519 if (ret) 520 520 return ret; 521 521
+1 -1
block/partitions/ibm.c
··· 358 358 goto out_nolab; 359 359 /* set start if not filled by getgeo function e.g. virtblk */ 360 360 geo->start = get_start_sect(bdev); 361 - if (disk->fops->getgeo(bdev, geo)) 361 + if (disk->fops->getgeo(disk, geo)) 362 362 goto out_freeall; 363 363 if (!fn || fn(disk, info)) { 364 364 kfree(info);
+5 -5
drivers/block/amiflop.c
··· 1523 1523 return BLK_STS_OK; 1524 1524 } 1525 1525 1526 - static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 1526 + static int fd_getgeo(struct gendisk *disk, struct hd_geometry *geo) 1527 1527 { 1528 - int drive = MINOR(bdev->bd_dev) & 3; 1528 + struct amiga_floppy_struct *p = disk->private_data; 1529 1529 1530 - geo->heads = unit[drive].type->heads; 1531 - geo->sectors = unit[drive].dtype->sects * unit[drive].type->sect_mult; 1532 - geo->cylinders = unit[drive].type->tracks; 1530 + geo->heads = p->type->heads; 1531 + geo->sectors = p->dtype->sects * p->type->sect_mult; 1532 + geo->cylinders = p->type->tracks; 1533 1533 return 0; 1534 1534 } 1535 1535
+2 -2
drivers/block/aoe/aoeblk.c
··· 269 269 } 270 270 271 271 static int 272 - aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo) 272 + aoeblk_getgeo(struct gendisk *disk, struct hd_geometry *geo) 273 273 { 274 - struct aoedev *d = bdev->bd_disk->private_data; 274 + struct aoedev *d = disk->private_data; 275 275 276 276 if ((d->flags & DEVFL_UP) == 0) { 277 277 printk(KERN_ERR "aoe: disk not up\n");
+2 -2
drivers/block/floppy.c
··· 3363 3363 return 0; 3364 3364 } 3365 3365 3366 - static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 3366 + static int fd_getgeo(struct gendisk *disk, struct hd_geometry *geo) 3367 3367 { 3368 - int drive = (long)bdev->bd_disk->private_data; 3368 + int drive = (long)disk->private_data; 3369 3369 int type = ITYPE(drive_state[drive].fd_device); 3370 3370 struct floppy_struct *g; 3371 3371 int ret;
+3 -3
drivers/block/mtip32xx/mtip32xx.c
··· 3148 3148 * that each partition is also 4KB aligned. Non-aligned partitions adversely 3149 3149 * affects performance. 3150 3150 * 3151 - * @dev Pointer to the block_device strucutre. 3151 + * @disk Pointer to the gendisk strucutre. 3152 3152 * @geo Pointer to a hd_geometry structure. 3153 3153 * 3154 3154 * return value 3155 3155 * 0 Operation completed successfully. 3156 3156 * -ENOTTY An error occurred while reading the drive capacity. 3157 3157 */ 3158 - static int mtip_block_getgeo(struct block_device *dev, 3158 + static int mtip_block_getgeo(struct gendisk *disk, 3159 3159 struct hd_geometry *geo) 3160 3160 { 3161 - struct driver_data *dd = dev->bd_disk->private_data; 3161 + struct driver_data *dd = disk->private_data; 3162 3162 sector_t capacity; 3163 3163 3164 3164 if (!dd)
+2 -2
drivers/block/rnbd/rnbd-clt.c
··· 942 942 rnbd_clt_put_dev(dev); 943 943 } 944 944 945 - static int rnbd_client_getgeo(struct block_device *block_device, 945 + static int rnbd_client_getgeo(struct gendisk *disk, 946 946 struct hd_geometry *geo) 947 947 { 948 948 u64 size; 949 - struct rnbd_clt_dev *dev = block_device->bd_disk->private_data; 949 + struct rnbd_clt_dev *dev = disk->private_data; 950 950 struct queue_limits *limit = &dev->queue->limits; 951 951 952 952 size = dev->size * (limit->logical_block_size / SECTOR_SIZE);
+1 -2
drivers/block/sunvdc.c
··· 119 119 return vio_dring_avail(dr, VDC_TX_RING_SIZE); 120 120 } 121 121 122 - static int vdc_getgeo(struct block_device *bdev, struct hd_geometry *geo) 122 + static int vdc_getgeo(struct gendisk *disk, struct hd_geometry *geo) 123 123 { 124 - struct gendisk *disk = bdev->bd_disk; 125 124 sector_t nsect = get_capacity(disk); 126 125 sector_t cylinders = nsect; 127 126
+2 -2
drivers/block/swim.c
··· 711 711 return -ENOTTY; 712 712 } 713 713 714 - static int floppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) 714 + static int floppy_getgeo(struct gendisk *disk, struct hd_geometry *geo) 715 715 { 716 - struct floppy_state *fs = bdev->bd_disk->private_data; 716 + struct floppy_state *fs = disk->private_data; 717 717 struct floppy_struct *g; 718 718 int ret; 719 719
+3 -3
drivers/block/virtio_blk.c
··· 829 829 } 830 830 831 831 /* We provide getgeo only to please some old bootloader/partitioning tools */ 832 - static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) 832 + static int virtblk_getgeo(struct gendisk *disk, struct hd_geometry *geo) 833 833 { 834 - struct virtio_blk *vblk = bd->bd_disk->private_data; 834 + struct virtio_blk *vblk = disk->private_data; 835 835 int ret = 0; 836 836 837 837 mutex_lock(&vblk->vdev_mutex); ··· 853 853 /* some standard values, similar to sd */ 854 854 geo->heads = 1 << 6; 855 855 geo->sectors = 1 << 5; 856 - geo->cylinders = get_capacity(bd->bd_disk) >> 11; 856 + geo->cylinders = get_capacity(disk) >> 11; 857 857 } 858 858 out: 859 859 mutex_unlock(&vblk->vdev_mutex);
+2 -2
drivers/block/xen-blkfront.c
··· 493 493 schedule_work(&rinfo->work); 494 494 } 495 495 496 - static int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) 496 + static int blkif_getgeo(struct gendisk *disk, struct hd_geometry *hg) 497 497 { 498 498 /* We don't have real geometry info, but let's at least return 499 499 values consistent with the size of the device */ 500 - sector_t nsect = get_capacity(bd->bd_disk); 500 + sector_t nsect = get_capacity(disk); 501 501 sector_t cylinders = nsect; 502 502 503 503 hg->heads = 0xff;
+2 -2
drivers/md/dm.c
··· 403 403 dm_deferred_remove(); 404 404 } 405 405 406 - static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo) 406 + static int dm_blk_getgeo(struct gendisk *disk, struct hd_geometry *geo) 407 407 { 408 - struct mapped_device *md = bdev->bd_disk->private_data; 408 + struct mapped_device *md = disk->private_data; 409 409 410 410 return dm_get_geometry(md, geo); 411 411 }
+2 -2
drivers/md/md.c
··· 7678 7678 * 4 sectors (with a BIG number of cylinders...). This drives 7679 7679 * dosfs just mad... ;-) 7680 7680 */ 7681 - static int md_getgeo(struct block_device *bdev, struct hd_geometry *geo) 7681 + static int md_getgeo(struct gendisk *disk, struct hd_geometry *geo) 7682 7682 { 7683 - struct mddev *mddev = bdev->bd_disk->private_data; 7683 + struct mddev *mddev = disk->private_data; 7684 7684 7685 7685 geo->heads = 2; 7686 7686 geo->sectors = 4;
+2 -2
drivers/memstick/core/ms_block.c
··· 1953 1953 msb->card = NULL; 1954 1954 } 1955 1955 1956 - static int msb_bd_getgeo(struct block_device *bdev, 1956 + static int msb_bd_getgeo(struct gendisk *disk, 1957 1957 struct hd_geometry *geo) 1958 1958 { 1959 - struct msb_data *msb = bdev->bd_disk->private_data; 1959 + struct msb_data *msb = disk->private_data; 1960 1960 *geo = msb->geometry; 1961 1961 return 0; 1962 1962 }
+2 -2
drivers/memstick/core/mspro_block.c
··· 189 189 kfree(msb); 190 190 } 191 191 192 - static int mspro_block_bd_getgeo(struct block_device *bdev, 192 + static int mspro_block_bd_getgeo(struct gendisk *disk, 193 193 struct hd_geometry *geo) 194 194 { 195 - struct mspro_block_data *msb = bdev->bd_disk->private_data; 195 + struct mspro_block_data *msb = disk->private_data; 196 196 197 197 geo->heads = msb->heads; 198 198 geo->sectors = msb->sectors_per_track;
+2 -2
drivers/mmc/core/block.c
··· 435 435 } 436 436 437 437 static int 438 - mmc_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo) 438 + mmc_blk_getgeo(struct gendisk *disk, struct hd_geometry *geo) 439 439 { 440 - geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16); 440 + geo->cylinders = get_capacity(disk) / (4 * 16); 441 441 geo->heads = 4; 442 442 geo->sectors = 16; 443 443 return 0;
+2 -2
drivers/mtd/mtd_blkdevs.c
··· 246 246 blktrans_dev_put(dev); 247 247 } 248 248 249 - static int blktrans_getgeo(struct block_device *bdev, struct hd_geometry *geo) 249 + static int blktrans_getgeo(struct gendisk *disk, struct hd_geometry *geo) 250 250 { 251 - struct mtd_blktrans_dev *dev = bdev->bd_disk->private_data; 251 + struct mtd_blktrans_dev *dev = disk->private_data; 252 252 int ret = -ENXIO; 253 253 254 254 mutex_lock(&dev->lock);
+2 -2
drivers/mtd/ubi/block.c
··· 282 282 mutex_unlock(&dev->dev_mutex); 283 283 } 284 284 285 - static int ubiblock_getgeo(struct block_device *bdev, struct hd_geometry *geo) 285 + static int ubiblock_getgeo(struct gendisk *disk, struct hd_geometry *geo) 286 286 { 287 287 /* Some tools might require this information */ 288 288 geo->heads = 1; 289 289 geo->cylinders = 1; 290 - geo->sectors = get_capacity(bdev->bd_disk); 290 + geo->sectors = get_capacity(disk); 291 291 geo->start = 0; 292 292 return 0; 293 293 }
+2 -2
drivers/nvdimm/btt.c
··· 1478 1478 bio_endio(bio); 1479 1479 } 1480 1480 1481 - static int btt_getgeo(struct block_device *bd, struct hd_geometry *geo) 1481 + static int btt_getgeo(struct gendisk *disk, struct hd_geometry *geo) 1482 1482 { 1483 1483 /* some standard values */ 1484 1484 geo->heads = 1 << 6; 1485 1485 geo->sectors = 1 << 5; 1486 - geo->cylinders = get_capacity(bd->bd_disk) >> 11; 1486 + geo->cylinders = get_capacity(disk) >> 11; 1487 1487 return 0; 1488 1488 } 1489 1489
+2 -2
drivers/nvme/host/core.c
··· 1803 1803 nvme_ns_release(disk->private_data); 1804 1804 } 1805 1805 1806 - int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo) 1806 + int nvme_getgeo(struct gendisk *disk, struct hd_geometry *geo) 1807 1807 { 1808 1808 /* some standard values */ 1809 1809 geo->heads = 1 << 6; 1810 1810 geo->sectors = 1 << 5; 1811 - geo->cylinders = get_capacity(bdev->bd_disk) >> 11; 1811 + geo->cylinders = get_capacity(disk) >> 11; 1812 1812 return 0; 1813 1813 } 1814 1814
+1 -1
drivers/nvme/host/nvme.h
··· 936 936 unsigned int issue_flags); 937 937 int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid, 938 938 struct nvme_id_ns **id); 939 - int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo); 939 + int nvme_getgeo(struct gendisk *disk, struct hd_geometry *geo); 940 940 int nvme_dev_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags); 941 941 942 942 extern const struct attribute_group *nvme_ns_attr_groups[];
+4 -3
drivers/s390/block/dasd.c
··· 3317 3317 /* 3318 3318 * Return disk geometry. 3319 3319 */ 3320 - static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 3320 + static int dasd_getgeo(struct gendisk *disk, struct hd_geometry *geo) 3321 3321 { 3322 3322 struct dasd_device *base; 3323 3323 3324 - base = dasd_device_from_gendisk(bdev->bd_disk); 3324 + base = dasd_device_from_gendisk(disk); 3325 3325 if (!base) 3326 3326 return -ENODEV; 3327 3327 ··· 3331 3331 return -EINVAL; 3332 3332 } 3333 3333 base->discipline->fill_geometry(base->block, geo); 3334 - geo->start = get_start_sect(bdev) >> base->block->s2b_shift; 3334 + // geo->start is left unchanged by the above 3335 + geo->start >>= base->block->s2b_shift; 3335 3336 dasd_put_device(base); 3336 3337 return 0; 3337 3338 }
+4 -4
drivers/scsi/sd.c
··· 1599 1599 scsi_device_put(sdev); 1600 1600 } 1601 1601 1602 - static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 1602 + static int sd_getgeo(struct gendisk *disk, struct hd_geometry *geo) 1603 1603 { 1604 - struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); 1604 + struct scsi_disk *sdkp = scsi_disk(disk); 1605 1605 struct scsi_device *sdp = sdkp->device; 1606 1606 struct Scsi_Host *host = sdp->host; 1607 1607 sector_t capacity = logical_to_sectors(sdp, sdkp->capacity); ··· 1614 1614 1615 1615 /* override with calculated, extended default, or driver values */ 1616 1616 if (host->hostt->bios_param) 1617 - host->hostt->bios_param(sdp, bdev->bd_disk, capacity, diskinfo); 1617 + host->hostt->bios_param(sdp, disk, capacity, diskinfo); 1618 1618 else 1619 - scsicam_bios_param(bdev->bd_disk, capacity, diskinfo); 1619 + scsicam_bios_param(disk, capacity, diskinfo); 1620 1620 1621 1621 geo->heads = diskinfo[0]; 1622 1622 geo->sectors = diskinfo[1];
+1 -1
include/linux/blkdev.h
··· 1659 1659 unsigned int (*check_events) (struct gendisk *disk, 1660 1660 unsigned int clearing); 1661 1661 void (*unlock_native_capacity) (struct gendisk *); 1662 - int (*getgeo)(struct block_device *, struct hd_geometry *); 1662 + int (*getgeo)(struct gendisk *, struct hd_geometry *); 1663 1663 int (*set_read_only)(struct block_device *bdev, bool ro); 1664 1664 void (*free_disk)(struct gendisk *disk); 1665 1665 /* this callback is with swap_lock and sometimes page table lock held */