block ioctl cleanups
Subsystems (8)
Hi Jens,
this series has a bunch of cleanups for the block layer ioctl code.
Diffstat:
block/genhd.c | 7 ---- block/ioctl.c | 62 ++++++-------------------------------- drivers/block/loop.c | 2 - drivers/block/mtip32xx/mtip32xx.c | 11 +----- drivers/block/pktcdvd.c | 6 ++- drivers/block/rbd.c | 41 ++----------------------- drivers/md/bcache/request.c | 5 +-- drivers/md/dm.c | 5 ++- drivers/md/md.c | 62 +++++++++++++++++++------------------- drivers/mtd/mtd_blkdevs.c | 28 ----------------- drivers/s390/block/dasd.c | 1 drivers/s390/block/dasd_int.h | 3 + drivers/s390/block/dasd_ioctl.c | 27 +++++----------- include/linux/blkdev.h | 3 - include/linux/genhd.h | 1 15 files changed, 73 insertions(+), 191 deletions(-)
PATCH 1/11 mtd_blkdevs: don't override BLKFLSBUF
BLKFLSBUF does not actually send a flush command to the device, but teard down buffer cache structures. Remove the mtd_blkdevs implementation and just use the default semantics instead.
--- drivers/mtd/mtd_blkdevs.c | 28 ---------------------------- 1 file changed, 28 deletions(-)
drivers/mtd/mtd_blkdevs.c +0 -28
@@ -298,38 +298,10 @@ static int blktrans_getgeo(struct block_device *bdev, struct hd_geometry *geo)return ret; } -static int blktrans_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -struct mtd_blktrans_dev *dev =blktrans_dev_get (bdev->bd_disk); -int ret = -ENXIO ; - -if (!dev) -return ret; - -mutex_lock (&dev->lock); - -if (!dev->mtd) - goto unlock; - -switch (cmd) { -case BLKFLSBUF : - ret = dev->tr->flush ? dev->tr->flush (dev) :0 ; -break ; -default : - ret = -ENOTTY ; - } -unlock: -mutex_unlock (&dev->lock); -blktrans_dev_put (dev); -return ret; -} -static const struct block_device_operations mtd_block_ops = { .owner =THIS_MODULE , .open = blktrans_open, .release = blktrans_release, - .ioctl = blktrans_ioctl, .getgeo = blktrans_getgeo, };
Signature · 1 line
2.28.0
Re: [PATCH 01/11] mtd_blkdevs: don't override BLKFLSBUF
Quoted 6 lines · Christoph Hellwig
BLKFLSBUF does not actually send a flush command to the device, but teard down buffer cache structures. Remove the
mtd_blkdevsimplementation and just use the default semantics instead.Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Thanks, //richard
Re: [PATCH 01/11] mtd_blkdevs: don't override BLKFLSBUF
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
BLKFLSBUF does not actually send a flush command to the device, but teard down buffer cache structures. Remove the
mtd_blkdevs
^^^^^ ?tears?
Quoted 4 lines
implementation and just use the default semantics instead.
Signed-off-by Christoph Hellwig <[email protected]>---
Cheers,
Wol
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/11 mtip32xx: return -ENOTTY for all unhanled ioctls
In reply to Christoph Hellwig-ENOTTY is the convention for "driver does not support this ioctl". Use it properly in mtip32xx instead of the bogys -EINVAL.
--- drivers/block/mtip32xx/mtip32xx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +2 -9
@@ -2029,7 +2029,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd, }default : -return -EINVAL ; +return -ENOTTY ; }return 0 ; }
@@ -3215,12 +3215,7 @@ static int mtip_block_ioctl(struct block_device *dev,if (unlikely (test_bit (MTIP_DDF_REMOVE_PENDING_BIT , &dd->dd_flag)))return -ENOTTY ; -switch (cmd) { -case BLKFLSBUF : -return -ENOTTY ; -default : -return mtip_hw_ioctl (dd, cmd, arg); - } +return mtip_hw_ioctl (dd, cmd, arg); }#ifdef CONFIG_COMPAT
@@ -3254,8 +3249,6 @@ static int mtip_block_compat_ioctl(struct block_device *dev,return -ENOTTY ;switch (cmd) { -case BLKFLSBUF : -return -ENOTTY ;case HDIO_DRIVE_TASKFILE : {struct mtip_compat_ide_task_request_s __user *compat_req_task;ide_task_request_t req_task;
Signature · 1 line
2.28.0
Jens Axboe
maintainerRe: [PATCH 02/11] mtip32xx: return -ENOTTY for all unhanled ioctls
Quoted 2 lines · Christoph Hellwig
-ENOTTYis the convention for "driver does not support this ioctl". Use it properly in mtip32xx instead of the bogys-EINVAL.
While that's certainly true, there is a risk in making a change like this years after the fact. Not that I expect there are any mtip32xx users left at this point, but...
Signature · 1 line
Jens Axboe
Re: [PATCH 02/11] mtip32xx: return -ENOTTY for all unhanled ioctls
Quoted 7 lines · Jens Axboe
Quoted 2 lines · Christoph Hellwig
-ENOTTYis the convention for "driver does not support this ioctl". Use it properly in mtip32xx instead of the bogys-EINVAL.While that's certainly true, there is a risk in making a change like this years after the fact. Not that I expect there are any mtip32xx users left at this point, but...
-ENOTTY is what most drivers return. That being said we can keep the old behavior, so if you prepfer that I can respin to do that.
Jens Axboe
maintainerRe: [PATCH 02/11] mtip32xx: return -ENOTTY for all unhanled ioctls
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 2 lines · Christoph Hellwig
-ENOTTYis the convention for "driver does not support this ioctl". Use it properly in mtip32xx instead of the bogys-EINVAL.While that's certainly true, there is a risk in making a change like this years after the fact. Not that I expect there are any mtip32xx users left at this point, but...
-ENOTTYis what most drivers return. That being said we can keep the old behavior, so if you prepfer that I can respin to do that.
Yeah I know that -ENOTTY is what they all should use (and most of course does), just saying that this change carries some risk. Given that mtip32xx can probably be retired in the not-too-distant future, I say we just keep the -EINVAL here.
Signature · 1 line
Jens Axboe
PATCH 3/11 block: don't call into the driver for BLKFLSBUF
In reply to Christoph HellwigBLKFLSBUF is entirely contained in the block core, and there is no good reason to give the driver a hook into processing it.
--- block/ioctl.c | 7 ------- 1 file changed, 7 deletions(-)
block/ioctl.c +0 -7
@@ -369,15 +369,8 @@ static inline int is_unrecognized_ioctl(int ret)static int blkdev_flushbuf (struct block_device *bdev,fmode_t mode,unsigned cmd,unsigned long arg) { -int ret; -if (!capable (CAP_SYS_ADMIN ))return -EACCES ; - - ret =__blkdev_driver_ioctl (bdev, mode, cmd, arg); -if (!is_unrecognized_ioctl (ret)) -return ret; -fsync_bdev (bdev);invalidate_bdev (bdev);return 0 ;
Signature · 1 line
2.28.0
PATCH 4/11 block: add a new set_read_only method
In reply to Christoph HellwigAdd a new method to allow driver-specific callout when setting or clearing the block device read-only state. This allow to replace the cumbersome and error prone override of the whole ioctl implementation.
--- block/ioctl.c | 5 +++++ include/linux/blkdev.h | 1 + 2 files changed, 6 insertions(+)
block/ioctl.c +5 -0
@@ -389,6 +389,11 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode,return ret;if (get_user (n, (int __user *)arg))return -EFAULT ; +if (bdev->bd_disk->fops->set_read_only) { + ret = bdev->bd_disk->fops->set_read_only (bdev, n); +if (ret) +return ret; + }set_device_ro (bdev, n);return 0 ; }
include/linux/blkdev.h +1 -0
@@ -1850,6 +1850,7 @@ struct block_device_operations {void (*unlock_native_capacity) (struct gendisk *);int (*revalidate_disk) (struct gendisk *);int (*getgeo)(struct block_device *,struct hd_geometry *); +int (*set_read_only)(struct block_device *bdev,bool ro);/* this callback is with swap_lock and sometimes page table lock held */ void (*swap_slot_free_notify) (struct block_device *,unsigned long ); int (*report_zones)(struct gendisk *, sector_t sector,
Signature · 1 line
2.28.0
PATCH 5/11 rbd: implement ->set_read_only to hook into BLKROSET processing
In reply to Christoph HellwigImplement the ->set_read_only method instead of parsing the actual ioctl command.
--- drivers/block/rbd.c | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-)
drivers/block/rbd.c +4 -37
@@ -692,12 +692,9 @@ static void rbd_release(struct gendisk *disk, fmode_t mode)put_device (&rbd_dev->dev); } -static int rbd_ioctl_set_ro (struct rbd_device *rbd_dev,unsigned long arg) +static int rbd_set_read_only (struct block_device *bdev,bool ro) { -int ro; - -if (get_user (ro, (int __user *)arg)) -return -EFAULT ; +struct rbd_device *rbd_dev = bdev->bd_disk->private_data;/* * Both images mapped read-only and snapshots can't be marked
@@ -706,47 +703,17 @@ static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg)if (!ro) {if (rbd_is_ro (rbd_dev))return -EROFS ; -rbd_assert (!rbd_is_snap (rbd_dev)); } -/* Let blkdev_roset() handle it */ -return -ENOTTY ; -} - -static int rbd_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -struct rbd_device *rbd_dev = bdev->bd_disk->private_data; -int ret; - -switch (cmd) { -case BLKROSET : - ret =rbd_ioctl_set_ro (rbd_dev, arg); -break ; -default : - ret = -ENOTTY ; - } - -return ret; -} - -#ifdef CONFIG_COMPAT -static int rbd_compat_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -return rbd_ioctl (bdev, mode, cmd, arg); +return 0 ; } -#endif /* CONFIG_COMPAT */ static const struct block_device_operations rbd_bd_ops = { .owner =THIS_MODULE , .open = rbd_open, .release = rbd_release, - .ioctl = rbd_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = rbd_compat_ioctl, -#endif + .set_read_only = rbd_set_read_only, };/*
Signature · 1 line
2.28.0
Re: [PATCH 05/11] rbd: implement ->set_read_only to hook into BLKROSET processing
Quoted 29 lines · Christoph Hellwig
Implement the ->set_read_only method instead of parsing the actual ioctl command.
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/rbd.c | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-)drivers/block/rbd.c +2
-5@@ -692,12 +692,9 @@ static void rbd_release(struct gendisk *disk, fmode_t mode)put_device (&rbd_dev->dev); } -static int rbd_ioctl_set_ro (struct rbd_device *rbd_dev,unsigned long arg) +static int rbd_set_read_only (struct block_device *bdev,bool ro) { -int ro; - -if (get_user (ro, (int __user *)arg)) -return -EFAULT ; +struct rbd_device *rbd_dev = bdev->bd_disk->private_data;/* * Both images mapped read-only and snapshots can't be marked
drivers/block/rbd.c static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg) · line 706
Quoted 5 lines
drivers/block/rbd.c +0
-1@@ -706,47 +703,17 @@ static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg)if (!ro) {if (rbd_is_ro (rbd_dev))return -EROFS ; -rbd_assert (!rbd_is_snap (rbd_dev));
If you repost, please leave this empty line.
Quoted 45 lines
drivers/block/rbd.c +2
-32} -/* Let blkdev_roset() handle it */ -return -ENOTTY ; -} - -static int rbd_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -struct rbd_device *rbd_dev = bdev->bd_disk->private_data; -int ret; - -switch (cmd) { -case BLKROSET : - ret =rbd_ioctl_set_ro (rbd_dev, arg); -break ; -default : - ret = -ENOTTY ; - } - -return ret; -} - -#ifdef CONFIG_COMPAT -static int rbd_compat_ioctl (struct block_device *bdev,fmode_t mode, -unsigned int cmd,unsigned long arg) -{ -return rbd_ioctl (bdev, mode, cmd, arg); +return 0 ; } -#endif /* CONFIG_COMPAT */ static const struct block_device_operations rbd_bd_ops = { .owner =THIS_MODULE , .open = rbd_open, .release = rbd_release, - .ioctl = rbd_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = rbd_compat_ioctl, -#endif + .set_read_only = rbd_set_read_only, };/* --
Quoted 2 lines
2.28.0
With that nit,
Thanks,
Ilya
PATCH 6/11 md: implement ->set_read_only to hook into BLKROSET processing
In reply to Christoph HellwigImplement the ->set_read_only method instead of parsing the actual ioctl command.
--- drivers/md/md.c | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-)
drivers/md/md.c +31 -31
@@ -7480,7 +7480,6 @@ static inline bool md_ioctl_valid(unsigned int cmd) {switch (cmd) {case ADD_NEW_DISK : -case BLKROSET :case GET_ARRAY_INFO :case GET_BITMAP_FILE :case GET_DISK_INFO :
@@ -7507,7 +7506,6 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,int err =0 ;void __user *argp = (void __user *)arg;struct mddev *mddev =NULL ; -int ro;bool did_set_md_closing = false;if (!md_ioctl_valid (cmd))
@@ -7687,35 +7685,6 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, goto unlock; }break ; - -case BLKROSET : -if (get_user (ro, (int __user *)(arg))) { - err = -EFAULT ; - goto unlock; - } - err = -EINVAL ; - -/* if the bdev is going readonly the value of mddev->ro -* does not matter, no writes are coming -*/ -if (ro) - goto unlock; - -/* are we are already prepared for writes? */ -if (mddev->ro !=1 ) - goto unlock; - -/* transitioning to readauto need only happen for -* arrays that call md_write_start -*/ -if (mddev->pers) { - err =restart_array (mddev); -if (err ==0 ) { - mddev->ro =2 ; -set_disk_ro (mddev->gendisk,0 ); - } - } - goto unlock; }/*
@@ -7809,6 +7778,36 @@ static int md_compat_ioctl(struct block_device *bdev, fmode_t mode, }#endif /* CONFIG_COMPAT */ +static int md_set_read_only (struct block_device *bdev,bool ro) +{ +struct mddev *mddev = bdev->bd_disk->private_data; +int err; + + err =mddev_lock (mddev); +if (err) +return err; + +if (!mddev->raid_disks && !mddev->external) { + err = -ENODEV ; + goto out_unlock; + } + +/* +* Transitioning to readauto need only happen for arrays that call +* md_write_start and which are not ready for writes yet. +*/ +if (!ro && mddev->ro ==1 && mddev->pers) { + err =restart_array (mddev); +if (err) + goto out_unlock; + mddev->ro =2 ; + } + +out_unlock: +mddev_unlock (mddev); +return err; +} +static int md_open (struct block_device *bdev,fmode_t mode) {/*
@@ -7886,6 +7885,7 @@ const struct block_device_operations md_fops =#endif .getgeo = md_getgeo, .check_events = md_check_events, + .set_read_only = md_set_read_only, };static int md_thread (void *arg)
Signature · 1 line
2.28.0
Re: [PATCH 06/11] md: implement ->set_read_only to hook into BLKROSET processing
Quoted 1 line · Christoph Hellwig
(quoted diff) +0
-0@@ -7809,6 +7778,36 @@ static int md_compat_ioctl(struct block_device *bdev, fmode_t mode,
[...]
drivers/md/md.c static int md_compat_ioctl(struct block_device *bdev, fmode_t mode, · line 7797
Quoted 2 lines
drivers/md/md.c +2
-0+* Transitioning to readauto need only happen for arrays that call +* md_write_start and which are not ready for writes yet.
I realise you're just moving the comment around but perhaps you could s/readauto/readonly/ while you're doing so?
Signature · 1 line
James
Re: [PATCH 06/11] md: implement ->set_read_only to hook into BLKROSET processing
Quoted 11 lines · James Troup
Quoted 1 line · Christoph Hellwig
(quoted diff) +0
-0@@ -7809,6 +7778,36 @@ static int md_compat_ioctl(struct block_device *bdev, fmode_t mode,[...]
drivers/md/md.c static int md_compat_ioctl(struct block_device *bdev, fmode_t mode, · line 7797
Quoted 2 lines
drivers/md/md.c +2
-0+* Transitioning to readauto need only happen for arrays that call +* md_write_start and which are not ready for writes yet. I realise you're just moving the comment around but perhaps you could s/readauto/readonly/ while you're doing so?
readonly doesn't make sense here as we transition away from read-only. MD seems to have a read-auto mode, although it usually is spelled with the dash, so I'll switch this comment to use the more common spelling.
PATCH 7/11 dasd: implement ->set_read_only to hook into BLKROSET processing
In reply to Christoph HellwigImplement the ->set_read_only method instead of parsing the actual ioctl command.
--- drivers/s390/block/dasd.c | 1 + drivers/s390/block/dasd_int.h | 3 ++- drivers/s390/block/dasd_ioctl.c | 27 +++++++++------------------ 3 files changed, 12 insertions(+), 19 deletions(-)
drivers/s390/block/dasd.c +1 -0
@@ -3394,6 +3394,7 @@ dasd_device_operations = { .ioctl = dasd_ioctl, .compat_ioctl = dasd_ioctl, .getgeo = dasd_getgeo, + .set_read_only = dasd_set_read_only, };/*******************************************************************************
drivers/s390/block/dasd_int.h +2 -1
@@ -844,7 +844,8 @@ int dasd_scan_partitions(struct dasd_block *);void dasd_destroy_partitions (struct dasd_block *);/* externals in dasd_ioctl.c */ -int dasd_ioctl (struct block_device *,fmode_t ,unsigned int ,unsigned long ); +int dasd_ioctl (struct block_device *,fmode_t ,unsigned int ,unsigned long ); +int dasd_set_read_only (struct block_device *bdev,bool ro);/* externals in dasd_proc.c */ int dasd_proc_init (void );
drivers/s390/block/dasd_ioctl.c +9 -18
@@ -532,28 +532,22 @@ static int dasd_ioctl_information(struct dasd_block *block, void __user *argp,/* * Set read only */ -static int -dasd_ioctl_set_ro (struct block_device *bdev,void __user *argp) +int dasd_set_read_only (struct block_device *bdev,bool ro) {struct dasd_device *base; -int intval, rc; +int rc; -if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +/* do not manipulate hardware state for partitions */ if (bdev_is_partition (bdev)) -// ro setting is not allowed for partitions -return -EINVAL ; -if (get_user (intval, (int __user *)argp)) -return -EFAULT ; +return 0 ; + base =dasd_device_from_gendisk (bdev->bd_disk);if (!base)return -ENODEV ; -if (!intval &&test_bit (DASD_FLAG_DEVICE_RO , &base->flags)) { -dasd_put_device (base); -return -EROFS ; - } -set_disk_ro (bdev->bd_disk, intval); - rc =dasd_set_feature (base->cdev,DASD_FEATURE_READONLY , intval); +if (!ro &&test_bit (DASD_FLAG_DEVICE_RO , &base->flags)) + rc = -EROFS ; +else + rc =dasd_set_feature (base->cdev,DASD_FEATURE_READONLY , ro);dasd_put_device (base);return rc; }
@@ -633,9 +627,6 @@ int dasd_ioctl(struct block_device *bdev, fmode_t mode,case BIODASDPRRST : rc =dasd_ioctl_reset_profile (block);break ; -case BLKROSET : - rc =dasd_ioctl_set_ro (bdev, argp); -break ;case DASDAPIVER : rc =dasd_ioctl_api_version (argp);break ;
Signature · 1 line
2.28.0
PATCH 8/11 block: don't call into the driver for BLKROSET
In reply to Christoph HellwigNow that all drivers that want to hook into setting or clearing the read-only flag use the set_read_only method this code can be removed.
--- block/ioctl.c | 23 ----------------------- 1 file changed, 23 deletions(-)
block/ioctl.c +0 -23
@@ -346,26 +346,6 @@ static int blkdev_pr_clear(struct block_device *bdev,return ops->pr_clear (bdev, c.key); } -/* -* Is it an unrecognized ioctl? The correct returns are either -* ENOTTY (final) or ENOIOCTLCMD ("I don't know this one, try a -* fallback"). ENOIOCTLCMD gets turned into ENOTTY by the ioctl -* code before returning. -* -* Confused drivers sometimes return EINVAL, which is wrong. It -* means "I understood the ioctl command, but the parameters to -* it were wrong". -* -* We should aim to just fix the broken drivers, the EINVAL case -* should go away. -*/ -static inline int is_unrecognized_ioctl (int ret) -{ -return ret == -EINVAL || - ret == -ENOTTY || - ret == -ENOIOCTLCMD ; -} -static int blkdev_flushbuf (struct block_device *bdev,fmode_t mode,unsigned cmd,unsigned long arg) {
@@ -384,9 +364,6 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode,if (!capable (CAP_SYS_ADMIN ))return -EACCES ; - ret =__blkdev_driver_ioctl (bdev, mode, cmd, arg); -if (!is_unrecognized_ioctl (ret)) -return ret;if (get_user (n, (int __user *)arg))return -EFAULT ;if (bdev->bd_disk->fops->set_read_only) {
Signature · 1 line
2.28.0
PATCH 9/11 loop: use set_disk_ro
In reply to Christoph HellwigUse set_disk_ro instead of set_device_ro to match all other block drivers and to ensure all partitions mirror the read-only flag.
--- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/loop.c +1 -1
@@ -1137,7 +1137,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,if (error) goto out_unlock; -set_device_ro (bdev, (lo->lo_flags &LO_FLAGS_READ_ONLY ) !=0 ); +set_disk_ro (lo->lo_disk, (lo->lo_flags &LO_FLAGS_READ_ONLY ) !=0 ); lo->use_dio = lo->lo_flags &LO_FLAGS_DIRECT_IO ; lo->lo_device = bdev;
Signature · 1 line
2.28.0
PATCH 10/11 block: remove set_device_ro
In reply to Christoph HellwigFold set_device_ro into its only remaining caller.
--- block/genhd.c | 7 ------- block/ioctl.c | 2 +- include/linux/genhd.h | 1 - 3 files changed, 1 insertion(+), 9 deletions(-)
block/genhd.c +0 -7
@@ -1843,13 +1843,6 @@ static void set_disk_ro_uevent(struct gendisk *gd, int ro)kobject_uevent_env (&disk_to_dev (gd)->kobj,KOBJ_CHANGE , envp); } -void set_device_ro (struct block_device *bdev,int flag) -{ - bdev->bd_part->policy = flag; -} - -EXPORT_SYMBOL (set_device_ro); -void set_disk_ro (struct gendisk *disk,int flag) {struct disk_part_iter piter;
block/ioctl.c +1 -1
@@ -371,7 +371,7 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode,if (ret)return ret; } -set_device_ro (bdev, n); + bdev->bd_part->policy = n;return 0 ; }
include/linux/genhd.h +0 -1
@@ -304,7 +304,6 @@ extern void del_gendisk(struct gendisk *gp);extern struct gendisk *get_gendisk (dev_t dev,int *partno);extern struct block_device *bdget_disk (struct gendisk *disk,int partno); -extern void set_device_ro (struct block_device *bdev,int flag);extern void set_disk_ro (struct gendisk *disk,int flag);static inline int get_disk_ro (struct gendisk *disk)
Signature · 1 line
2.28.0
PATCH 11/11 block: remove __blkdev_driver_ioctl
In reply to Christoph HellwigJust open code it in the few callers.
--- block/ioctl.c | 25 +++++-------------------- drivers/block/pktcdvd.c | 6 ++++-- drivers/md/bcache/request.c | 5 +++-- drivers/md/dm.c | 5 ++++- include/linux/blkdev.h | 2 -- 5 files changed, 16 insertions(+), 27 deletions(-)
block/ioctl.c +5 -20
@@ -219,23 +219,6 @@ static int compat_put_ulong(compat_ulong_t __user *argp, compat_ulong_t val) }#endif -int __blkdev_driver_ioctl (struct block_device *bdev,fmode_t mode, -unsigned cmd,unsigned long arg) -{ -struct gendisk *disk = bdev->bd_disk; - -if (disk->fops->ioctl) -return disk->fops->ioctl (bdev, mode, cmd, arg); - -return -ENOTTY ; -} -/* -* For the record: _GPL here is only because somebody decided to slap it -* on the previous export. Sheer idiocy, since it wasn't copyrightable -* at all and could be open-coded without any exports by anybody who cares. -*/ -EXPORT_SYMBOL_GPL (__blkdev_driver_ioctl); -#ifdef CONFIG_COMPAT /* * This is the equivalent of compat_ptr_ioctl(), to be used by block
@@ -594,10 +577,12 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, } ret =blkdev_common_ioctl (bdev, mode, cmd, arg, argp); -if (ret == -ENOIOCTLCMD ) -return __blkdev_driver_ioctl (bdev, mode, cmd, arg); +if (ret != -ENOIOCTLCMD ) +return ret; -return ret; +if (!bdev->bd_disk->fops->ioctl) +return -ENOTTY ; +return bdev->bd_disk->fops->ioctl (bdev, mode, cmd, arg); }EXPORT_SYMBOL_GPL (blkdev_ioctl);/* for /dev/raw */
drivers/block/pktcdvd.c +4 -2
@@ -2584,9 +2584,11 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,case CDROM_LAST_WRITTEN :case CDROM_SEND_PACKET :case SCSI_IOCTL_SEND_COMMAND : - ret =__blkdev_driver_ioctl (pd->bdev, mode, cmd, arg); +if (!bdev->bd_disk->fops->ioctl) + ret = -ENOTTY ; +else + ret = bdev->bd_disk->fops->ioctl (bdev, mode, cmd, arg);break ; -default :pkt_dbg (2 , pd,"Unknown ioctl (%x)\n" , cmd); ret = -ENOTTY ;
drivers/md/bcache/request.c +3 -2
@@ -1230,8 +1230,9 @@ static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode,if (dc->io_disable)return -EIO ; - -return __blkdev_driver_ioctl (dc->bdev, mode, cmd, arg); +if (!dc->bdev->bd_disk->fops->ioctl) +return -ENOTTY ; +return dc->bdev->bd_disk->fops->ioctl (dc->bdev, mode, cmd, arg); }void bch_cached_dev_request_init (struct cached_dev *dc)
drivers/md/dm.c +4 -1
@@ -570,7 +570,10 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode, } } - r =__blkdev_driver_ioctl (bdev, mode, cmd, arg); +if (!bdev->bd_disk->fops->ioctl) + r = -ENOTTY ; +else + r = bdev->bd_disk->fops->ioctl (bdev, mode, cmd, arg); out:dm_unprepare_ioctl (md, srcu_idx);return r;
include/linux/blkdev.h +0 -2
@@ -1867,8 +1867,6 @@ extern int blkdev_compat_ptr_ioctl(struct block_device *, fmode_t,#define blkdev_compat_ptr_ioctl NULL#endif -extern int __blkdev_driver_ioctl (struct block_device *,fmode_t ,unsigned int , -unsigned long );extern int bdev_read_page (struct block_device *,sector_t ,struct page *);extern int bdev_write_page (struct block_device *,sector_t ,struct page *,struct writeback_control *);
Signature · 1 line
2.28.0
Jens Axboe
maintainerQuoted 5 lines · Christoph Hellwig
Hi Jens,
this series has a bunch of cleanups for the block layer ioctl code.
Diffstat:
Quoted 16 lines
block/genhd.c | 7 ---- block/ioctl.c | 62 ++++++-------------------------------- drivers/block/loop.c | 2 - drivers/block/mtip32xx/mtip32xx.c | 11 +----- drivers/block/pktcdvd.c | 6 ++- drivers/block/rbd.c | 41 ++----------------------- drivers/md/bcache/request.c | 5 +-- drivers/md/dm.c | 5 ++- drivers/md/md.c | 62 +++++++++++++++++++------------------- drivers/mtd/mtd_blkdevs.c | 28 ----------------- drivers/s390/block/dasd.c | 1 drivers/s390/block/dasd_int.h | 3 + drivers/s390/block/dasd_ioctl.c | 27 +++++----------- include/linux/blkdev.h | 3 - include/linux/genhd.h | 1 15 files changed, 73 insertions(+), 191 deletions(-)
Series looks good to me, apart from the mentioned mtip32xx change. If you repost this, can you look through commit messages and titles for typos, I spotted quite a few. If not I'll do it when applying.
Signature · 1 line
Jens Axboe