dasd: cleanup dasd_ioctl
Subsystems (2)
PATCH 1/5 dasd: cleanup dasd_ioctl
Handle ioctls implemented in dasd_ioctl through the normal switch statement that most drivers use instead of the awkwarddasd_ioctl_no_register routine. This avoids searching a linear list
on every call to dasd_ioctl(), and allows to give the various ioctl implementation functions sane prototypes, aswell as moving the check for bdev->bd_disk->private_data from the individual functions to dasd_ioctl. (I think it can't actually every be NULL, but let's keep that for later)
dasd.c | 4 dasd_int.h | 2 dasd_ioctl.c | 241 +++++++++++++++++++++-------------------------------------- 3 files changed, 86 insertions(+), 161 deletions(-)
drivers/s390/block/dasd_int.h +0 -2
@@ -558,8 +558,6 @@void dasd_destroy_partitions (struct dasd_device *);/* externals in dasd_ioctl.c */ -int dasd_ioctl_init (void ); -void dasd_ioctl_exit (void );int dasd_ioctl_no_register (struct module *,int ,dasd_ioctl_fn_t );int dasd_ioctl_no_unregister (struct module *,int ,dasd_ioctl_fn_t );int dasd_ioctl (struct inode *,struct file *,unsigned int ,unsigned long );
drivers/s390/block/dasd_ioctl.c +86 -155
381 lines not on this page · raw message
drivers/s390/block/dasd.c +0 -4
@@ -1803,7 +1803,6 @@#ifdef CONFIG_PROC_FS dasd_proc_exit ();#endif -dasd_ioctl_exit ();if (dasd_page_cache !=NULL ) {kmem_cache_destroy (dasd_page_cache); dasd_page_cache =NULL ;
@@ -2123,9 +2122,6 @@ rc =dasd_parse ();if (rc) goto failed; - rc =dasd_ioctl_init (); -if (rc) - goto failed;#ifdef CONFIG_PROC_FS rc =dasd_proc_init ();if (rc)
drivers/s390/block/dasd_ioctl.c line 85
Quoted 8 lines · Christoph Hellwig
static int
drivers/s390/block/dasd_ioctl.c +2
-2-dasd_ioctl_api_version(struct block_device *bdev, int no, long args) +dasd_ioctl_api_version(void __user *argp) {int ver =DASD_API_VERSION ; -return put_user (ver, (int __user *) args); +return put_user (ver, (int *)argp); }
Doesn't this need to be "int __user *"?
drivers/s390/block/dasd_ioctl.c line 473
Quoted 12 lines
drivers/s390/block/dasd_ioctl.c +6
-4+long +dasd_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { -int i; +int rval; -for (i =0 ; dasd_ioctls[i].no !=-1 ; i++) -dasd_ioctl_no_unregister (NULL , dasd_ioctls[i].no, - dasd_ioctls[i].fn); +lock_kernel (); + rval =dasd_ioctl (filp->f_dentry->d_inode, filp, cmd, arg); +unlock_kernel ();
The lock_kernel looks spurious.
Bastian
Signature · 2 lines
Conquest is easy. Control is not. -- Kirk, "Mirror, Mirror", stardate unknown
Quoted 11 lines · Bastian Blank
drivers/s390/block/dasd_ioctl.c line 85
Quoted 8 lines · Christoph Hellwig
static int
drivers/s390/block/dasd_ioctl.c +2
-2-dasd_ioctl_api_version(struct block_device *bdev, int no, long args) +dasd_ioctl_api_version(void __user *argp) {int ver =DASD_API_VERSION ; -return put_user (ver, (int __user *) args); +return put_user (ver, (int *)argp); }Doesn't this need to be "int
__user*"?
Yes.
Quoted 6 lines
Quoted 6 lines
drivers/s390/block/dasd_ioctl.c +3
-1+long +dasd_compat_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { -int i; +int rval;
Quoted 8 lines
drivers/s390/block/dasd_ioctl.c line 473
Quoted 6 lines
drivers/s390/block/dasd_ioctl.c +3
-3-for (i =0 ; dasd_ioctls[i].no !=-1 ; i++) -dasd_ioctl_no_unregister (NULL , dasd_ioctls[i].no, - dasd_ioctls[i].fn); +lock_kernel (); + rval =dasd_ioctl (filp->f_dentry->d_inode, filp, cmd, arg); +unlock_kernel ();The
lock_kernellooks spurious.
dasd_compat_ioctl just moved down unchanged to the end of the file so it can call dasd_ioctl without a forward-prototype. When I introduced this function a while ago I added the lock_kernel because that the BKL is held when dasd_ioctl is called directly and I wanted to avoid different locks from different codepathes. Once we can switch dasd to ->unlocked_ioctl it could probably go away.
Quoted 10 lines · Christoph Hellwig
drivers/s390/block/dasd_ioctl.c +2
-3@@ -480,68 +389,90 @@* Set read only */ static int -dasd_ioctl_set_ro (struct block_device *bdev,int no,long args) +dasd_ioctl_set_ro (struct block_device *bdev,void __user *argp) { -struct dasd_device *device; -int intval, rc; +struct dasd_device *device = bdev->bd_disk->private_data;
drivers/s390/block/dasd_ioctl.c line 403
Quoted 10 lines
drivers/s390/block/dasd_ioctl.c +2
-1+int intval;if (!capable (CAP_SYS_ADMIN ))return -EACCES ;if (bdev != bdev->bd_contains)// ro setting is not allowed for partitions return -EINVAL ; -if (get_user (intval, (int __user *) args)) +if (get_user (intval, (int *)argp))return -EFAULT ;
I think this is another candidate for "int __user *".
Bastian