BKL ioctl pushdown
Subsystems (3)
cover BKL ioctl pushdown
These patches convert ioctls to unlocked_ioctls by pushing down the bkl into them. I had to go outside of the files that we agreed on, because logically the ioctls in each kind of file system belong together.
Frederic and Arnd, you can pull from:
git.kernel.org//pub/scm/linux/kernel/git/jkacur/jk-2.6.git linus-bkl-pushdown
John Kacur (6):
coda: BKL ioctl pushdown
coda: Clean-up whitespace problems in pioctl.c
fat: BKL ioctl pushdown
ncpfs: BKL ioctl pushdown
smbfs: BKL ioctl pushdown
udf: BKL ioctl pushdown
fs/coda/pioctl.c | 76 ++++++++++++++++++++++++++---------------------- fs/fat/dir.c | 36 +++++++++++++++------- fs/fat/fat.h | 3 +- fs/fat/file.c | 22 ++++++++++---- fs/ncpfs/dir.c | 2 +- fs/ncpfs/file.c | 2 +- fs/ncpfs/ioctl.c | 27 ++++++++++------- fs/smbfs/dir.c | 2 +- fs/smbfs/file.c | 2 +- fs/smbfs/ioctl.c | 10 ++++-- fs/smbfs/proto.h | 2 +- fs/udf/dir.c | 2 +- fs/udf/file.c | 43 +++++++++++++++++---------- fs/udf/udfdecl.h | 3 +- include/linux/ncp_fs.h | 2 +- 15 files changed, 140 insertions(+), 94 deletions(-)
PATCH 1/6 coda: BKL ioctl pushdown
Convert coda_pioctl to an unlocked_ioctl pushing down the BKL into it.
--- fs/coda/pioctl.c | 41 ++++++++++++++++++++++++----------------- 1 files changed, 24 insertions(+), 17 deletions(-)
fs/coda/pioctl.c +24 -17
@@ -23,10 +23,12 @@#include <linux/coda_fs_i.h> #include <linux/coda_psdev.h> +#include <linux/smp_lock.h> +/* pioctl ops */ static int coda_ioctl_permission (struct inode *inode,int mask); -static int coda_pioctl (struct inode * inode,struct file * filp, -unsigned int cmd,unsigned long user_data); +static long coda_pioctl (struct file *filp,unsigned int cmd, +unsigned long user_data);/* exported from this file */ const struct inode_operations coda_ioctl_inode_operations =
@@ -37,7 +39,7 @@ const struct inode_operations coda_ioctl_inode_operations =const struct file_operations coda_ioctl_operations = { .owner =THIS_MODULE , - .ioctl = coda_pioctl, + .unlocked_ioctl = coda_pioctl, };/* the coda pioctl inode ops */
@@ -46,40 +48,43 @@ static int coda_ioctl_permission(struct inode *inode, int mask)return (mask &MAY_EXEC ) ? -EACCES :0 ; } -static int coda_pioctl (struct inode * inode,struct file * filp, -unsigned int cmd,unsigned long user_data) +static long coda_pioctl (struct file *filp,unsigned int cmd, +unsigned long user_data) {struct path path;int error;struct PioctlData data; +struct inode *inode = filp->f_dentry->d_inode;struct inode *target_inode =NULL ;struct coda_inode_info *cnp; +lock_kernel (); +/* get the Pioctl data arguments from user space */ if (copy_from_user (&data, (void __user *)user_data,sizeof (data))) { -return -EINVAL ; + error = -EINVAL ; + goto out; }/* * Look up the pathname. Note that the pathname is in * user memory, and namei takes care of this */ -if (data.follow) { +if (data.follow) error =user_path (data.path, &path); - }else { +else error =user_lpath (data.path, &path); - } - -if ( error ) { -return error; - }else { + +if (error) + goto out; +else target_inode = path.dentry->d_inode; - } - +/* return if it is not a Coda inode */ if ( target_inode->i_sb != inode->i_sb ) {path_put (&path); -return -EINVAL ; + error = -EINVAL ; + goto out; }/* now proceed to make the upcall */
@@ -88,6 +93,8 @@ static int coda_pioctl(struct inode * inode, struct file * filp, error =venus_pioctl (inode->i_sb, &(cnp->c_fid), cmd, &data);path_put (&path); + +out: +unlock_kernel ();return error; } -
Signature · 1 line
1.6.6.1
Frederic Weisbecker
AppliedRe: [PATCH 1/6] coda: BKL ioctl pushdown
Quoted 4 lines · John Kacur
Convert
coda_pioctlto anunlocked_ioctlpushing down the BKL into it.Signed-off-by John Kacur <[email protected]>---
Applied, thanks!
PATCH 2/6 coda: Clean-up whitespace problems in pioctl.c
In reply to John Kacur--- fs/coda/pioctl.c | 35 +++++++++++++++++------------------ 1 files changed, 17 insertions(+), 18 deletions(-)
fs/coda/pioctl.c +17 -18
@@ -1,6 +1,6 @@/* * Pioctl operations for Coda. -* Original version: (C) 1996 Peter Braam +* Original version: (C) 1996 Peter Braam * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University * * Carnegie Mellon encourages users of this code to contribute improvements
@@ -31,8 +31,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data);/* exported from this file */ -const struct inode_operations coda_ioctl_inode_operations = -{ +const struct inode_operations coda_ioctl_inode_operations = { .permission = coda_ioctl_permission, .setattr = coda_setattr, };
@@ -52,28 +51,28 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data) {struct path path; -int error; +int error;struct PioctlData data;struct inode *inode = filp->f_dentry->d_inode; -struct inode *target_inode =NULL ; -struct coda_inode_info *cnp; +struct inode *target_inode =NULL ; +struct coda_inode_info *cnp;lock_kernel (); -/* get the Pioctl data arguments from user space */ -if (copy_from_user (&data, (void __user *)user_data,sizeof (data))) { +/* get the Pioctl data arguments from user space */ +if (copy_from_user (&data, (void __user *)user_data,sizeof (data))) { error = -EINVAL ; goto out; } - -/* -* Look up the pathname. Note that the pathname is in -* user memory, and namei takes care of this -*/ + +/* +* Look up the pathname. Note that the pathname is in +* user memory, and namei takes care of this +*/ if (data.follow) - error =user_path (data.path, &path); + error =user_path (data.path, &path);else - error =user_lpath (data.path, &path); + error =user_lpath (data.path, &path);if (error) goto out;
@@ -81,14 +80,14 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, target_inode = path.dentry->d_inode;/* return if it is not a Coda inode */ -if ( target_inode->i_sb != inode->i_sb ) { +if (target_inode->i_sb != inode->i_sb) {path_put (&path); error = -EINVAL ; goto out; }/* now proceed to make the upcall */ - cnp =ITOC (target_inode); + cnp =ITOC (target_inode); error =venus_pioctl (inode->i_sb, &(cnp->c_fid), cmd, &data);
@@ -96,5 +95,5 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, out:unlock_kernel (); -return error; +return error; }
Signature · 1 line
1.6.6.1
Re: [PATCH 2/6] coda: Clean-up whitespace problems in pioctl.c
Quoted 2 lines · John Kacur
Signed-off-by John Kacur <[email protected]>---
Applied too, thanks.
PATCH 3/6 fat: BKL ioctl pushdown
In reply to John KacurConvert fat_generic_ioctl and fat_dir_ioctl to unlocked_ioctls and push down the bkl into those functions.
--- fs/fat/dir.c | 36 ++++++++++++++++++++++++------------ fs/fat/fat.h | 3 +-- fs/fat/file.c | 22 ++++++++++++++++------ 3 files changed, 41 insertions(+), 20 deletions(-)
fs/fat/dir.c +24 -12
@@ -19,6 +19,7 @@#include <linux/buffer_head.h> #include <linux/compat.h> #include <asm/uaccess.h> +#include <linux/smp_lock.h> #include "fat.h" /*
@@ -737,10 +738,11 @@ efault: \ FAT_IOCTL_FILLDIR_FUNC(fat_ioctl_filldir, __fat_dirent) -static int fat_ioctl_readdir (struct inode *inode,struct file *filp, +static long fat_ioctl_readdir (struct file *filp,void __user *dirent,filldir_t filldir,int short_only,int both) { +struct inode *inode = filp->f_dentry->d_inode;struct fat_ioctl_filldir_callback buf;int ret;
@@ -758,9 +760,10 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *filp,return ret; } -static int fat_dir_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long fat_dir_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg) { +long error;struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg;int short_only, both;
@@ -774,21 +777,31 @@ static int fat_dir_ioctl(struct inode *inode, struct file *filp, both =1 ;break ;default : -return fat_generic_ioctl (inode, filp, cmd, arg); +lock_kernel (); + error =fat_generic_ioctl (filp, cmd, arg); + goto out; } -if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ]))) -return -EFAULT ; +lock_kernel (); +if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ]))) { + error = -EFAULT ; + goto out; + }/* * Yes, we don't need this put_user() absolutely. However old * code didn't return the right value. So, app use this value, * in order to check whether it is EOF. */ -if (put_user (0 , &d1->d_reclen)) -return -EFAULT ; +if (put_user (0 , &d1->d_reclen)) { + error = -EFAULT ; + goto out; + } -return fat_ioctl_readdir (inode, filp, d1, fat_ioctl_filldir, + error =fat_ioctl_readdir (filp, d1, fat_ioctl_filldir, short_only, both); +out: +unlock_kernel (); +return error; }#ifdef CONFIG_COMPAT
@@ -800,7 +813,6 @@ FAT_IOCTL_FILLDIR_FUNC(fat_compat_ioctl_filldir, compat_dirent)static long fat_compat_dir_ioctl (struct file *filp,unsigned cmd,unsigned long arg) { -struct inode *inode = filp->f_path.dentry->d_inode;struct compat_dirent __user *d1 =compat_ptr (arg);int short_only, both;
@@ -827,7 +839,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd,if (put_user (0 , &d1->d_reclen))return -EFAULT ; -return fat_ioctl_readdir (inode, filp, d1, fat_compat_ioctl_filldir, +return fat_ioctl_readdir (filp, d1, fat_compat_ioctl_filldir, short_only, both); }#endif /* CONFIG_COMPAT */
@@ -836,7 +848,7 @@ const struct file_operations fat_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = fat_readdir, - .ioctl = fat_dir_ioctl, + .unlocked_ioctl = fat_dir_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = fat_compat_dir_ioctl,#endif
fs/fat/fat.h +1 -2
@@ -298,8 +298,7 @@ extern int fat_free_clusters(struct inode *inode, int cluster);extern int fat_count_free_clusters (struct super_block *sb);/* fat/file.c */ -extern int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg); +extern long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations;extern int fat_setattr (struct dentry * dentry,struct iattr * attr);
fs/fat/file.c +16 -6
@@ -16,6 +16,7 @@#include <linux/blkdev.h> #include <linux/fsnotify.h> #include <linux/security.h> +#include <linux/smp_lock.h> #include "fat.h" static int fat_ioctl_get_attributes (struct inode *inode,u32 __user *user_attr)
@@ -114,19 +115,28 @@ out:return err; } -int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +long error; +struct inode *inode = filp->f_dentry->d_inode;u32 __user *user_attr = (u32 __user *)arg; +lock_kernel (); +switch (cmd) {case FAT_IOCTL_GET_ATTRIBUTES : -return fat_ioctl_get_attributes (inode, user_attr); + error =fat_ioctl_get_attributes (inode, user_attr); +break ;case FAT_IOCTL_SET_ATTRIBUTES : -return fat_ioctl_set_attributes (filp, user_attr); + error =fat_ioctl_set_attributes (filp, user_attr); +break ;default : -return -ENOTTY ;/* Inappropriate ioctl for device */ + error = -ENOTTY ;/* Inappropriate ioctl for device */ +break ; } + +unlock_kernel (); +return error; }static int fat_file_release (struct inode *inode,struct file *filp)
@@ -159,7 +169,7 @@ const struct file_operations fat_file_operations = { .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, .release = fat_file_release, - .ioctl = fat_generic_ioctl, + .unlocked_ioctl = fat_generic_ioctl, .fsync = fat_file_fsync, .splice_read = generic_file_splice_read, };
Signature · 1 line
1.6.6.1
OGAWA Hirofumi
maintainerRe: [PATCH 3/6] fat: BKL ioctl pushdown
Quoted 2 lines · John Kacur
Convert
fat_generic_ioctlandfat_dir_ioctltounlocked_ioctlsand push down the bkl into those functions.
I guess this is the part of batch ioctl conversion stuff though, those ioctl of FAT don't need BKL at all. Because all of those should already be protected by inode->i_mutex.
Removing BKL and then cleanup after this patch would be almost same with reverting this patch. So, could you just convert to unlocked_ioctl instead?
Thanks.
Quoted 178 lines
Signed-off-by John Kacur <[email protected]>--- fs/fat/dir.c | 36 ++++++++++++++++++++++++------------ fs/fat/fat.h | 3 +-- fs/fat/file.c | 22 ++++++++++++++++------ 3 files changed, 41 insertions(+), 20 deletions(-)fs/fat/dir.c +24
-12@@ -19,6 +19,7 @@#include <linux/buffer_head.h> #include <linux/compat.h> #include <asm/uaccess.h> +#include <linux/smp_lock.h> #include "fat.h" /* @@ -737,10 +738,11 @@ efault: \ FAT_IOCTL_FILLDIR_FUNC(fat_ioctl_filldir, __fat_dirent) -static int fat_ioctl_readdir (struct inode *inode,struct file *filp, +static long fat_ioctl_readdir (struct file *filp,void __user *dirent,filldir_t filldir,int short_only,int both) { +struct inode *inode = filp->f_dentry->d_inode;struct fat_ioctl_filldir_callback buf;int ret;@@ -758,9 +760,10 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *filp,return ret; } -static int fat_dir_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long fat_dir_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg) { +long error;struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg;int short_only, both;@@ -774,21 +777,31 @@ static int fat_dir_ioctl(struct inode *inode, struct file *filp, both =1 ;break ;default : -return fat_generic_ioctl (inode, filp, cmd, arg); +lock_kernel (); + error =fat_generic_ioctl (filp, cmd, arg); + goto out; } -if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ]))) -return -EFAULT ; +lock_kernel (); +if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ]))) { + error = -EFAULT ; + goto out; + }/* * Yes, we don't need this put_user() absolutely. However old * code didn't return the right value. So, app use this value, * in order to check whether it is EOF. */ -if (put_user (0 , &d1->d_reclen)) -return -EFAULT ; +if (put_user (0 , &d1->d_reclen)) { + error = -EFAULT ; + goto out; + } -return fat_ioctl_readdir (inode, filp, d1, fat_ioctl_filldir, + error =fat_ioctl_readdir (filp, d1, fat_ioctl_filldir, short_only, both); +out: +unlock_kernel (); +return error; }#ifdef CONFIG_COMPAT @@ -800,7 +813,6 @@ FAT_IOCTL_FILLDIR_FUNC(fat_compat_ioctl_filldir, compat_dirent)static long fat_compat_dir_ioctl (struct file *filp,unsigned cmd,unsigned long arg) { -struct inode *inode = filp->f_path.dentry->d_inode;struct compat_dirent __user *d1 =compat_ptr (arg);int short_only, both;@@ -827,7 +839,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd,if (put_user (0 , &d1->d_reclen))return -EFAULT ; -return fat_ioctl_readdir (inode, filp, d1, fat_compat_ioctl_filldir, +return fat_ioctl_readdir (filp, d1, fat_compat_ioctl_filldir, short_only, both); }#endif /* CONFIG_COMPAT */ @@ -836,7 +848,7 @@ const struct file_operations fat_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = fat_readdir, - .ioctl = fat_dir_ioctl, + .unlocked_ioctl = fat_dir_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = fat_compat_dir_ioctl,#endif fs/fat/fat.h +1
-2@@ -298,8 +298,7 @@ extern int fat_free_clusters(struct inode *inode, int cluster);extern int fat_count_free_clusters (struct super_block *sb);/* fat/file.c */ -extern int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg); +extern long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations;extern int fat_setattr (struct dentry * dentry,struct iattr * attr);fs/fat/file.c +16
-6@@ -16,6 +16,7 @@#include <linux/blkdev.h> #include <linux/fsnotify.h> #include <linux/security.h> +#include <linux/smp_lock.h> #include "fat.h" static int fat_ioctl_get_attributes (struct inode *inode,u32 __user *user_attr)@@ -114,19 +115,28 @@ out:return err; } -int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +long error; +struct inode *inode = filp->f_dentry->d_inode;u32 __user *user_attr = (u32 __user *)arg; +lock_kernel (); +switch (cmd) {case FAT_IOCTL_GET_ATTRIBUTES : -return fat_ioctl_get_attributes (inode, user_attr); + error =fat_ioctl_get_attributes (inode, user_attr); +break ;case FAT_IOCTL_SET_ATTRIBUTES : -return fat_ioctl_set_attributes (filp, user_attr); + error =fat_ioctl_set_attributes (filp, user_attr); +break ;default : -return -ENOTTY ;/* Inappropriate ioctl for device */ + error = -ENOTTY ;/* Inappropriate ioctl for device */ +break ; } + +unlock_kernel (); +return error; }static int fat_file_release (struct inode *inode,struct file *filp)@@ -159,7 +169,7 @@ const struct file_operations fat_file_operations = { .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, .release = fat_file_release, - .ioctl = fat_generic_ioctl, + .unlocked_ioctl = fat_generic_ioctl, .fsync = fat_file_fsync, .splice_read = generic_file_splice_read, };
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Re: [PATCH 3/6] fat: BKL ioctl pushdown
Quoted 5 lines · OGAWA Hirofumi
Quoted 2 lines · John Kacur
Convert
fat_generic_ioctlandfat_dir_ioctltounlocked_ioctlsand push down the bkl into those functions.
Quoted 7 lines
I guess this is the part of batch ioctl conversion stuff though, those ioctl of FAT don't need BKL at all. Because all of those should already be protected by
inode->i_mutex.Removing BKL and then cleanup after this patch would be almost same with reverting this patch. So, could you just convert to
unlocked_ioctlinstead?
That's probably not a good idea, without a little bit more analysis, otherwise it's quite easy to introduce subtle bugs.
Quoted 190 lines
Thanks.
Quoted 178 lines
Signed-off-by John Kacur <[email protected]>--- fs/fat/dir.c | 36 ++++++++++++++++++++++++------------ fs/fat/fat.h | 3 +-- fs/fat/file.c | 22 ++++++++++++++++------ 3 files changed, 41 insertions(+), 20 deletions(-)fs/fat/dir.c +24
-12@@ -19,6 +19,7 @@#include <linux/buffer_head.h> #include <linux/compat.h> #include <asm/uaccess.h> +#include <linux/smp_lock.h> #include "fat.h" /* @@ -737,10 +738,11 @@ efault: \ FAT_IOCTL_FILLDIR_FUNC(fat_ioctl_filldir, __fat_dirent) -static int fat_ioctl_readdir (struct inode *inode,struct file *filp, +static long fat_ioctl_readdir (struct file *filp,void __user *dirent,filldir_t filldir,int short_only,int both) { +struct inode *inode = filp->f_dentry->d_inode;struct fat_ioctl_filldir_callback buf;int ret;@@ -758,9 +760,10 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *filp,return ret; } -static int fat_dir_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long fat_dir_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg) { +long error;struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg;int short_only, both;@@ -774,21 +777,31 @@ static int fat_dir_ioctl(struct inode *inode, struct file *filp, both =1 ;break ;default : -return fat_generic_ioctl (inode, filp, cmd, arg); +lock_kernel (); + error =fat_generic_ioctl (filp, cmd, arg); + goto out; } -if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ]))) -return -EFAULT ; +lock_kernel (); +if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ]))) { + error = -EFAULT ; + goto out; + }/* * Yes, we don't need this put_user() absolutely. However old * code didn't return the right value. So, app use this value, * in order to check whether it is EOF. */ -if (put_user (0 , &d1->d_reclen)) -return -EFAULT ; +if (put_user (0 , &d1->d_reclen)) { + error = -EFAULT ; + goto out; + } -return fat_ioctl_readdir (inode, filp, d1, fat_ioctl_filldir, + error =fat_ioctl_readdir (filp, d1, fat_ioctl_filldir, short_only, both); +out: +unlock_kernel (); +return error; }#ifdef CONFIG_COMPAT @@ -800,7 +813,6 @@ FAT_IOCTL_FILLDIR_FUNC(fat_compat_ioctl_filldir, compat_dirent)static long fat_compat_dir_ioctl (struct file *filp,unsigned cmd,unsigned long arg) { -struct inode *inode = filp->f_path.dentry->d_inode;struct compat_dirent __user *d1 =compat_ptr (arg);int short_only, both;@@ -827,7 +839,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd,if (put_user (0 , &d1->d_reclen))return -EFAULT ; -return fat_ioctl_readdir (inode, filp, d1, fat_compat_ioctl_filldir, +return fat_ioctl_readdir (filp, d1, fat_compat_ioctl_filldir, short_only, both); }#endif /* CONFIG_COMPAT */ @@ -836,7 +848,7 @@ const struct file_operations fat_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = fat_readdir, - .ioctl = fat_dir_ioctl, + .unlocked_ioctl = fat_dir_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = fat_compat_dir_ioctl,#endif fs/fat/fat.h +1
-2@@ -298,8 +298,7 @@ extern int fat_free_clusters(struct inode *inode, int cluster);extern int fat_count_free_clusters (struct super_block *sb);/* fat/file.c */ -extern int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg); +extern long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations;extern int fat_setattr (struct dentry * dentry,struct iattr * attr);fs/fat/file.c +16
-6@@ -16,6 +16,7 @@#include <linux/blkdev.h> #include <linux/fsnotify.h> #include <linux/security.h> +#include <linux/smp_lock.h> #include "fat.h" static int fat_ioctl_get_attributes (struct inode *inode,u32 __user *user_attr)@@ -114,19 +115,28 @@ out:return err; } -int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +long error; +struct inode *inode = filp->f_dentry->d_inode;u32 __user *user_attr = (u32 __user *)arg; +lock_kernel (); +switch (cmd) {case FAT_IOCTL_GET_ATTRIBUTES : -return fat_ioctl_get_attributes (inode, user_attr); + error =fat_ioctl_get_attributes (inode, user_attr); +break ;case FAT_IOCTL_SET_ATTRIBUTES : -return fat_ioctl_set_attributes (filp, user_attr); + error =fat_ioctl_set_attributes (filp, user_attr); +break ;default : -return -ENOTTY ;/* Inappropriate ioctl for device */ + error = -ENOTTY ;/* Inappropriate ioctl for device */ +break ; } + +unlock_kernel (); +return error; }static int fat_file_release (struct inode *inode,struct file *filp)@@ -159,7 +169,7 @@ const struct file_operations fat_file_operations = { .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, .release = fat_file_release, - .ioctl = fat_generic_ioctl, + .unlocked_ioctl = fat_generic_ioctl, .fsync = fat_file_fsync, .splice_read = generic_file_splice_read, };Signature · 6 lines
OGAWA Hirofumi <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
OGAWA Hirofumi
maintainerRe: [PATCH 3/6] fat: BKL ioctl pushdown
Quoted 11 lines · John Kacur
Quoted 9 lines · OGAWA Hirofumi
Quoted 2 lines · John Kacur
Convert
fat_generic_ioctlandfat_dir_ioctltounlocked_ioctlsand push down the bkl into those functions.I guess this is the part of batch ioctl conversion stuff though, those ioctl of FAT don't need BKL at all. Because all of those should already be protected by
inode->i_mutex.
Quoted 6 lines
Quoted 3 lines
Removing BKL and then cleanup after this patch would be almost same with reverting this patch. So, could you just convert to
unlocked_ioctlinstead?That's probably not a good idea, without a little bit more analysis, otherwise it's quite easy to introduce subtle bugs.
What analysis? Who do it? I thought about removing BKL of FAT from several years ago. I was reviewing FAT multiple times, and I'm always testing FAT without BKL.
If you are going to do, could you do it instead of this patch?
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
PATCH 1/1 fat: convert to unlocked_ioctl
FAT does not require the BKL in its ioctl function, which is already serialized through a mutex. Since we're already touching the ioctl code, also fix the missing handling of FAT_IOCTL_GET_ATTRIBUTES in the compat code.
---
Quoted 3 lines · On Wednesday 05 May 2010 20:30:07 OGAWA Hirofumi wrote:
Quoted 2 lines · John Kacur
That's probably not a good idea, without a little bit more analysis, otherwise it's quite easy to introduce subtle bugs.
The chances are rather low if the maintainer confirms that the BKL is not needed. I double-checked and found a small bug in related code, so this does both.
Quoted 5 lines
What analysis? Who do it? I thought about removing BKL of FAT from several years ago. I was reviewing FAT multiple times, and I'm always testing FAT without BKL.
If you are going to do, could you do it instead of this patch?
The only thing the series really needs to do is to remove the usage of the deprecated ->ioctl() operation. This patch makes FAT simply use unlocked_ioctl but does not reintroduce the BKL.
Does that look better?
fs/fat/dir.c | 11 ++++++----- fs/fat/fat.h | 4 ++-- fs/fat/file.c | 19 ++++++++++++++++--- 3 files changed, 24 insertions(+), 10 deletions(-)
fs/fat/dir.c +6 -5
@@ -758,9 +758,10 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *filp,return ret; } -static int fat_dir_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long fat_dir_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg) { +struct inode *inode = filp->f_path.dentry->d_inode;struct __fat_dirent __user *d1 = (struct __fat_dirent __user *)arg;int short_only, both;
@@ -774,7 +775,7 @@ static int fat_dir_ioctl(struct inode *inode, struct file *filp, both =1 ;break ;default : -return fat_generic_ioctl (inode, filp, cmd, arg); +return fat_generic_ioctl (filp, cmd, arg); }if (!access_ok (VERIFY_WRITE , d1,sizeof (struct __fat_dirent [2 ])))
@@ -814,7 +815,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd, both =1 ;break ;default : -return -ENOIOCTLCMD ; +return fat_generic_ioctl (filp, cmd, (unsigned long )arg); }if (!access_ok (VERIFY_WRITE , d1,sizeof (struct compat_dirent [2 ])))
@@ -836,7 +837,7 @@ const struct file_operations fat_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = fat_readdir, - .ioctl = fat_dir_ioctl, + .unlocked_ioctl = fat_dir_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = fat_compat_dir_ioctl,#endif
fs/fat/fat.h +2 -2
@@ -298,8 +298,8 @@ extern int fat_free_clusters(struct inode *inode, int cluster);extern int fat_count_free_clusters (struct super_block *sb);/* fat/file.c */ -extern int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg); +extern long fat_generic_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg);extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations;extern int fat_setattr (struct dentry * dentry,struct iattr * attr);
fs/fat/file.c +16 -3
@@ -8,6 +8,7 @@#include <linux/capability.h> #include <linux/module.h> +#include <linux/compat.h> #include <linux/mount.h> #include <linux/time.h> #include <linux/buffer_head.h>
@@ -114,9 +115,9 @@ out:return err; } -int fat_generic_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long fat_generic_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_path.dentry->d_inode;u32 __user *user_attr = (u32 __user *)arg;switch (cmd) {
@@ -129,6 +130,15 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp, } } +#ifdef CONFIG_COMPAT +static long fat_generic_compat_ioctl (struct file *filp,unsigned int cmd, +unsigned long arg) + +{ +return fat_generic_ioctl (filp, cmd, (unsigned long )compat_ptr (arg)); +} +#endif +static int fat_file_release (struct inode *inode,struct file *filp) { if ((filp->f_mode & FMODE_WRITE) &&
@@ -159,7 +169,10 @@ const struct file_operations fat_file_operations = { .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, .release = fat_file_release, - .ioctl = fat_generic_ioctl, + .unlocked_ioctl = fat_generic_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = fat_generic_compat_ioctl, +#endif .fsync = fat_file_fsync, .splice_read = generic_file_splice_read, };
OGAWA Hirofumi
maintainerRe: [PATCH] fat: convert to unlocked_ioctl
Quoted 5 lines · Arnd Bergmann
FAT does not require the BKL in its ioctl function, which is already serialized through a mutex. Since we're already touching the ioctl code, also fix the missing handling of
FAT_IOCTL_GET_ATTRIBUTESin the compat code.Signed-off-by Arnd Bergmann <[email protected]>
[...]
Quoted 6 lines
The only thing the series really needs to do is to remove the usage of the deprecated ->ioctl() operation. This patch makes FAT simply use
unlocked_ioctlbut does not reintroduce the BKL.Does that look better?
Looks good to me. I'll apply this for next window after some tests.
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Re: [PATCH 3/6] fat: BKL ioctl pushdown
In reply to OGAWA HirofumiQuoted 17 lines · OGAWA Hirofumi
Quoted 15 lines · John Kacur
Quoted 12 lines · OGAWA Hirofumi
Quoted 2 lines · John Kacur
Convert
fat_generic_ioctlandfat_dir_ioctltounlocked_ioctlsand push down the bkl into those functions.I guess this is the part of batch ioctl conversion stuff though, those ioctl of FAT don't need BKL at all. Because all of those should already be protected by
inode->i_mutex.Removing BKL and then cleanup after this patch would be almost same with reverting this patch. So, could you just convert to
unlocked_ioctlinstead?
Quoted 6 lines
Quoted 2 lines
That's probably not a good idea, without a little bit more analysis, otherwise it's quite easy to introduce subtle bugs.
What analysis? Who do it? I thought about removing BKL of FAT from several years ago. I was reviewing FAT multiple times, and I'm always testing FAT without BKL.
This patch just makes explicit the hidden BKLs that FAT is already using related to ioctl. We would like to get this step done in time for the next merge window, because then we can remove that hidden source.
This step is preparation for removing the BKL from the individual functions we've pushed it down into. In other words, we'll do the analysis to remove it later if you don't want to.
Thanks.
Quoted 3 lines
If you are going to do, could you do it instead of this patch?
PATCH 4/6 ncpfs: BKL ioctl pushdown
In reply to John KacurConvert ncp_ioctl to an unlocked_ioctl and push down the bkl into it.
--- fs/ncpfs/dir.c | 2 +- fs/ncpfs/file.c | 2 +- fs/ncpfs/ioctl.c | 27 ++++++++++++++++----------- include/linux/ncp_fs.h | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-)
fs/ncpfs/dir.c +1 -1
@@ -51,7 +51,7 @@ const struct file_operations ncp_dir_operations = { .read = generic_read_dir, .readdir = ncp_readdir, - .ioctl = ncp_ioctl, + .unlocked_ioctl = ncp_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = ncp_compat_ioctl,#endif
fs/ncpfs/file.c +1 -1
@@ -295,7 +295,7 @@ const struct file_operations ncp_file_operations = .llseek = ncp_remote_llseek, .read = ncp_file_read, .write = ncp_file_write, - .ioctl = ncp_ioctl, + .unlocked_ioctl = ncp_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ncp_compat_ioctl,#endif
fs/ncpfs/ioctl.c +16 -11
@@ -20,6 +20,7 @@#include <linux/smp_lock.h> #include <linux/vmalloc.h> #include <linux/sched.h> +#include <linux/smp_lock.h> #include <linux/ncp_fs.h>
@@ -261,9 +262,9 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg) }#endif /* CONFIG_NCPFS_NLS */ -static int __ncp_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +static long __ncp_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;struct ncp_server *server =NCP_SERVER (inode);int result;struct ncp_ioctl_request request;
@@ -841,11 +842,11 @@ static int ncp_ioctl_need_write(unsigned int cmd) } } -int ncp_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long ncp_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { -int ret; +long ret; +lock_kernel ();if (ncp_ioctl_need_write (cmd)) {/* * inside the ioctl(), any failures which
@@ -853,24 +854,28 @@ int ncp_ioctl(struct inode *inode, struct file *filp,* -EACCESS, so it seems consistent to keep * that here. */ -if (mnt_want_write (filp->f_path.mnt)) -return -EACCES ; +if (mnt_want_write (filp->f_path.mnt)) { + ret = -EACCES ; + goto out; + } } - ret =__ncp_ioctl (inode, filp, cmd, arg); + ret =__ncp_ioctl (filp, cmd, arg);if (ncp_ioctl_need_write (cmd))mnt_drop_write (filp->f_path.mnt); + +out: +unlock_kernel ();return ret; }#ifdef CONFIG_COMPAT long ncp_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct inode *inode = file->f_path.dentry->d_inode; -int ret; +long ret;lock_kernel (); arg = (unsigned long )compat_ptr (arg); - ret =ncp_ioctl (inode, file, cmd, arg); + ret =ncp_ioctl (file, cmd, arg);unlock_kernel ();return ret; }
include/linux/ncp_fs.h +1 -1
@@ -210,7 +210,7 @@ int ncp_date_dos2unix(__le16 time, __le16 date);void ncp_date_unix2dos (int unix_date,__le16 * time,__le16 * date);/* linux/fs/ncpfs/ioctl.c */ -int ncp_ioctl (struct inode *,struct file *,unsigned int ,unsigned long ); +long ncp_ioctl (struct file *,unsigned int ,unsigned long );long ncp_compat_ioctl (struct file *,unsigned int ,unsigned long );/* linux/fs/ncpfs/sock.c */
Signature · 1 line
1.6.6.1
Frederic Weisbecker
AppliedRe: [PATCH 4/6] ncpfs: BKL ioctl pushdown
2010/5/5 John Kacur <[email protected]>:
Quoted 3 lines
Convert
ncp_ioctlto anunlocked_ioctland push down the bkl into it.Signed-off-by John Kacur <[email protected]>
Applied, thanks.
PATCH 5/6 smbfs: BKL ioctl pushdown
In reply to John KacurConvert smb_ioctl to an unlocked ioctl and push down the bkl into it.
--- fs/smbfs/dir.c | 2 +- fs/smbfs/file.c | 2 +- fs/smbfs/ioctl.c | 10 +++++++--- fs/smbfs/proto.h | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-)
fs/smbfs/dir.c +1 -1
@@ -39,7 +39,7 @@ const struct file_operations smb_dir_operations = { .read = generic_read_dir, .readdir = smb_readdir, - .ioctl = smb_ioctl, + .unlocked_ioctl = smb_ioctl, .open = smb_dir_open, };
fs/smbfs/file.c +1 -1
@@ -437,7 +437,7 @@ const struct file_operations smb_file_operations = .aio_read = smb_file_aio_read, .write = do_sync_write, .aio_write = smb_file_aio_write, - .ioctl = smb_ioctl, + .unlocked_ioctl = smb_ioctl, .mmap = smb_file_mmap, .open = smb_file_open, .release = smb_file_release,
fs/smbfs/ioctl.c +7 -3
@@ -19,17 +19,19 @@#include <linux/smb_mount.h> #include <asm/uaccess.h> +#include <linux/smp_lock.h> #include "proto.h" -int -smb_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long smb_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;struct smb_sb_info *server =server_from_inode (inode);struct smb_conn_opt opt;int result = -EINVAL ; +lock_kernel (); +switch (cmd) {uid16_t uid16;uid_t uid32;
@@ -63,5 +65,7 @@ smb_ioctl(struct inode *inode, struct file *filp,break ; } +unlock_kernel (); +return result; }
fs/smbfs/proto.h +1 -1
@@ -67,7 +67,7 @@ extern const struct address_space_operations smb_file_aops;extern const struct file_operations smb_file_operations;extern const struct inode_operations smb_file_inode_operations;/* ioctl.c */ -extern int smb_ioctl (struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg); +extern long smb_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);/* smbiod.c */ extern void smbiod_wake_up (void );extern int smbiod_register_server (struct smb_sb_info *server);
Signature · 1 line
1.6.6.1
Frederic Weisbecker
AppliedRe: [PATCH 5/6] smbfs: BKL ioctl pushdown
Quoted 3 lines · John Kacur
Convert
smb_ioctlto an unlocked ioctl and push down the bkl into it.Signed-off-by John Kacur <[email protected]>
Applied, thanks.
Quoted 84 lines
--- fs/smbfs/dir.c | 2 +- fs/smbfs/file.c | 2 +- fs/smbfs/ioctl.c | 10 +++++++--- fs/smbfs/proto.h | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-)fs/smbfs/dir.c +1
-1@@ -39,7 +39,7 @@ const struct file_operations smb_dir_operations = { .read = generic_read_dir, .readdir = smb_readdir, - .ioctl = smb_ioctl, + .unlocked_ioctl = smb_ioctl, .open = smb_dir_open, };fs/smbfs/file.c +1
-1@@ -437,7 +437,7 @@ const struct file_operations smb_file_operations = .aio_read = smb_file_aio_read, .write = do_sync_write, .aio_write = smb_file_aio_write, - .ioctl = smb_ioctl, + .unlocked_ioctl = smb_ioctl, .mmap = smb_file_mmap, .open = smb_file_open, .release = smb_file_release,fs/smbfs/ioctl.c +7
-3@@ -19,17 +19,19 @@#include <linux/smb_mount.h> #include <asm/uaccess.h> +#include <linux/smp_lock.h> #include "proto.h" -int -smb_ioctl (struct inode *inode,struct file *filp, -unsigned int cmd,unsigned long arg) +long smb_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;struct smb_sb_info *server =server_from_inode (inode);struct smb_conn_opt opt;int result = -EINVAL ; +lock_kernel (); +switch (cmd) {uid16_t uid16;uid_t uid32;@@ -63,5 +65,7 @@ smb_ioctl(struct inode *inode, struct file *filp,break ; } +unlock_kernel (); +return result; }fs/smbfs/proto.h +1
-1@@ -67,7 +67,7 @@ extern const struct address_space_operations smb_file_aops;extern const struct file_operations smb_file_operations;extern const struct inode_operations smb_file_inode_operations;/* ioctl.c */ -extern int smb_ioctl (struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg); +extern long smb_ioctl (struct file *filp,unsigned int cmd,unsigned long arg);/* smbiod.c */ extern void smbiod_wake_up (void );extern int smbiod_register_server (struct smb_sb_info *server);Signature · 1 line
1.6.6.1
Re: [PATCH 5/6] smbfs: BKL ioctl pushdown
In reply to John KacurQuoted 3 lines · John Kacur
Convert
smb_ioctlto an unlocked ioctl and push down the bkl into it.Signed-off-by John Kacur <[email protected]>
In fact this one doesn't apply, not a single hunk.
Against which tree have you made this patch?
Re: [PATCH 5/6] smbfs: BKL ioctl pushdown
Quoted 9 lines · Frederic Weisbecker
Quoted 3 lines · John Kacur
Convert
smb_ioctlto an unlocked ioctl and push down the bkl into it.Signed-off-by John Kacur <[email protected]>In fact this one doesn't apply, not a single hunk.
Against which tree have you made this patch?
It was just Linus's latest, after 2.6.34-rc6 at commit 7ebd467551ed6ae200d7835a84bbda0dcadaa511
PATCH 6/6 udf: BKL ioctl pushdown
In reply to John KacurConvert udf_ioctl to an unlocked_ioctl and push the BKL down into it.
--- fs/udf/dir.c | 2 +- fs/udf/file.c | 43 +++++++++++++++++++++++++++---------------- fs/udf/udfdecl.h | 3 +-- 3 files changed, 29 insertions(+), 19 deletions(-)
fs/udf/dir.c +1 -1
@@ -209,6 +209,6 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)const struct file_operations udf_dir_operations = { .read = generic_read_dir, .readdir = udf_readdir, - .ioctl = udf_ioctl, + .unlocked_ioctl = udf_ioctl, .fsync = simple_fsync, };
fs/udf/file.c +27 -16
90 lines not on this page · raw message
fs/udf/udfdecl.h +1 -2
@@ -130,8 +130,7 @@ extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, uint8_t *, uint8_t *);/* file.c */ -extern int udf_ioctl (struct inode *,struct file *,unsigned int , -unsigned long ); +extern long udf_ioctl (struct file *,unsigned int ,unsigned long );extern int udf_setattr (struct dentry *dentry,struct iattr *iattr);/* inode.c */ extern struct inode *udf_iget (struct super_block *,struct kernel_lb_addr *);
Signature · 1 line
1.6.6.1
Re: [PATCH 6/6] udf: BKL ioctl pushdown
Quoted 1 line · John Kacur
Convert
udf_ioctlto anunlocked_ioctland push the BKL down into it.
Thanks. Merged into UDF tree.
Honza
Quoted 134 lines
Signed-off-by John Kacur <[email protected]--- fs/udf/dir.c | 2 +- fs/udf/file.c | 43 +++++++++++++++++++++++++++---------------- fs/udf/udfdecl.h | 3 +-- 3 files changed, 29 insertions(+), 19 deletions(-)fs/udf/dir.c +1
-1@@ -209,6 +209,6 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)const struct file_operations udf_dir_operations = { .read = generic_read_dir, .readdir = udf_readdir, - .ioctl = udf_ioctl, + .unlocked_ioctl = udf_ioctl, .fsync = simple_fsync, };fs/udf/file.c +27
-16@@ -37,6 +37,7 @@#include <linux/quotaops.h> #include <linux/buffer_head.h> #include <linux/aio.h> +#include <linux/smp_lock.h> #include "udf_i.h" #include "udf_sb.h" @@ -144,50 +145,60 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,return retval; } -int udf_ioctl (struct inode *inode,struct file *filp,unsigned int cmd, -unsigned long arg) +long udf_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;long old_block, new_block;int result = -EINVAL ; +lock_kernel (); +if (file_permission (filp,MAY_READ ) !=0 ) { -udf_debug ("no permission to access inode %lu\n" , - inode->i_ino); -return -EPERM ; +udf_debug ("no permission to access inode %lu\n" , inode->i_ino); + result = -EPERM ; + goto out; }if (!arg) {udf_debug ("invalid argument to udf_ioctl\n" ); -return -EINVAL ; + result = -EINVAL ; + goto out; }switch (cmd) {case UDF_GETVOLIDENT :if (copy_to_user ((char __user *)arg,UDF_SB (inode->i_sb)->s_volume_ident,32 )) -return -EFAULT ; + result = -EFAULT ;else -return 0 ; + result =0 ; + goto out;case UDF_RELOCATE_BLOCKS : -if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; -if (get_user (old_block, (long __user *)arg)) -return -EFAULT ; +if (!capable (CAP_SYS_ADMIN )) { + result = -EACCES ; + goto out; + } +if (get_user (old_block, (long __user *)arg)) { + result = -EFAULT ; + goto out; + } result =udf_relocate_blocks (inode->i_sb, old_block, &new_block);if (result ==0 ) result =put_user (new_block, (long __user *)arg); -return result; + goto out;case UDF_GETEASIZE : result =put_user (UDF_I (inode)->i_lenEAttr, (int __user *)arg); -break ; + goto out;case UDF_GETEABLOCK : result =copy_to_user ((char __user *)arg,UDF_I (inode)->i_ext.i_data,UDF_I (inode)->i_lenEAttr) ? -EFAULT :0 ; -break ; + goto out; } +out: +unlock_kernel ();return result; }@@ -207,7 +218,7 @@ static int udf_release_file(struct inode *inode, struct file *filp)const struct file_operations udf_file_operations = { .read = do_sync_read, .aio_read = generic_file_aio_read, - .ioctl = udf_ioctl, + .unlocked_ioctl = udf_ioctl, .open = dquot_file_open, .mmap = generic_file_mmap, .write = do_sync_write,fs/udf/udfdecl.h +1
-2@@ -130,8 +130,7 @@ extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, uint8_t *, uint8_t *);/* file.c */ -extern int udf_ioctl (struct inode *,struct file *,unsigned int , -unsigned long ); +extern long udf_ioctl (struct file *,unsigned int ,unsigned long );extern int udf_setattr (struct dentry *dentry,struct iattr *iattr);/* inode.c */ extern struct inode *udf_iget (struct super_block *,struct kernel_lb_addr *);Signature · 1 line
1.6.6.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 6 lines · John Kacur
These patches convert ioctls to
unlocked_ioctlsby pushing down the bkl into them. I had to go outside of the files that we agreed on, because logically the ioctls in each kind of file system belong together.Frederic and Arnd, you can pull from:
git.kernel.org//pub/scm/linux/kernel/git/jkacur/jk-2.6.git linus-bkl-pushdown
Thanks John.
I will apply the patches from this set that haven't been applied yet, for .35
Quoted 25 lines
John Kacur (6):
coda: BKL ioctl pushdown
coda: Clean-up whitespace problems inpioctl.c
fat: BKL ioctl pushdown
ncpfs: BKL ioctl pushdown
smbfs: BKL ioctl pushdown
udf: BKL ioctl pushdownfs/coda/pioctl.c | 76 ++++++++++++++++++++++++++---------------------- fs/fat/dir.c | 36 +++++++++++++++------- fs/fat/fat.h | 3 +- fs/fat/file.c | 22 ++++++++++---- fs/ncpfs/dir.c | 2 +- fs/ncpfs/file.c | 2 +- fs/ncpfs/ioctl.c | 27 ++++++++++------- fs/smbfs/dir.c | 2 +- fs/smbfs/file.c | 2 +- fs/smbfs/ioctl.c | 10 ++++-- fs/smbfs/proto.h | 2 +- fs/udf/dir.c | 2 +- fs/udf/file.c | 43 +++++++++++++++++---------- fs/udf/udfdecl.h | 3 +- include/linux/ncp_fs.h | 2 +- 15 files changed, 140 insertions(+), 94 deletions(-)