Drop BKL in ext[234] ioctls
cover Drop BKL in ext[234] ioctls
Remove the BKL from the ext* ioctls.
This is a slightly updated version of the ext[2-4] patches that hit linux-fsdevel earlier.
-Andi
PATCH 1/7 Convert ext2 over to use unlocked_ioctl
I checked ext2_ioctl and could not find anything in there that would need the BKL. So convert it over to use unlocked_ioctl
--- fs/ext2/dir.c | 2 +- fs/ext2/ext2.h | 3 +-- fs/ext2/file.c | 4 ++-- fs/ext2/ioctl.c | 12 +++--------- 4 files changed, 7 insertions(+), 14 deletions(-)
fs/ext2/dir.c +1 -1
@@ -703,7 +703,7 @@ const struct file_operations ext2_dir_op .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = ext2_readdir, - .ioctl = ext2_ioctl, + .unlocked_ioctl = ext2_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext2_compat_ioctl,#endif
fs/ext2/ext2.h +1 -2
@@ -139,8 +139,7 @@ int __ext2_write_begin(struct file *file struct page **pagep, void **fsdata);/* ioctl.c */ -extern int ext2_ioctl (struct inode *,struct file *,unsigned int , -unsigned long ); +extern long ext2_ioctl (struct file *,unsigned int ,unsigned long );extern long ext2_compat_ioctl (struct file *,unsigned int ,unsigned long );/* namei.c */
fs/ext2/file.c +2 -2
@@ -48,7 +48,7 @@ const struct file_operations ext2_file_o .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = generic_file_aio_write, - .ioctl = ext2_ioctl, + .unlocked_ioctl = ext2_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext2_compat_ioctl,#endif
@@ -65,7 +65,7 @@ const struct file_operations ext2_xip_fi .llseek = generic_file_llseek, .read = xip_file_read, .write = xip_file_write, - .ioctl = ext2_ioctl, + .unlocked_ioctl = ext2_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext2_compat_ioctl,#endif
fs/ext2/ioctl.c +3 -9
@@ -17,9 +17,9 @@#include <asm/uaccess.h> -int ext2_ioctl (struct inode * inode,struct file * filp,unsigned int cmd, -unsigned long arg) +long ext2_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;struct ext2_inode_info *ei =EXT2_I (inode);unsigned int flags;unsigned short rsv_window_size;
@@ -141,9 +141,6 @@ int ext2_ioctl (struct inode * inode, st#ifdef CONFIG_COMPAT long ext2_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct inode *inode = file->f_path.dentry->d_inode; -int ret; -/* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) {case EXT2_IOC32_GETFLAGS :
@@ -161,9 +158,6 @@ long ext2_compat_ioctl(struct file *filedefault : return -ENOIOCTLCMD; } -lock_kernel (); - ret =ext2_ioctl (inode, file, cmd, (unsigned long )compat_ptr (arg)); -unlock_kernel (); -return ret; +return ext2_ioctl (file, cmd, (unsigned long )compat_ptr (arg)); }#endif
PATCH 2/7 Remove incorrect BKL comment in ext2
In reply to Andi KleenNo BKL used anywhere, so don't mention it.
--- fs/ext2/inode.c | 1 - 1 file changed, 1 deletion(-)
fs/ext2/inode.c +0 -1
@@ -569,7 +569,6 @@ static void ext2_splice_branch(struct in* * `handle' can be NULL if create == 0. * -* The BKL may not be held on entry here. Be sure to take it early. * return > 0, # of blocks mapped or allocated. * return = 0, if plain lookup failed. * return < 0, error case.
PATCH 3/7 Convert ext3 to use unlocked_ioctl v2
In reply to Andi KleenI checked ext3_ioctl and it looked largely safe to not be used without BKL. So convert it over to unlocked_ioctl.
v1->v2: drop lock kernel for online growth. resize.c seems to do enough locking
--- fs/ext3/dir.c | 2 +- fs/ext3/file.c | 2 +- fs/ext3/ioctl.c | 21 +++++++++++---------- include/linux/ext3_fs.h | 3 +-- 4 files changed, 14 insertions(+), 14 deletions(-)
fs/ext3/dir.c +1 -1
@@ -42,7 +42,7 @@ const struct file_operations ext3_dir_op .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = ext3_readdir, /* we take BKL. needed?*/ - .ioctl = ext3_ioctl, /* BKL held */ + .unlocked_ioctl = ext3_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext3_compat_ioctl,#endif
fs/ext3/file.c +1 -1
@@ -112,7 +112,7 @@ const struct file_operations ext3_file_o .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = ext3_file_write, - .ioctl = ext3_ioctl, + .unlocked_ioctl = ext3_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext3_compat_ioctl,#endif
fs/ext3/ioctl.c +3 -9
@@ -17,9 +17,9 @@#include <linux/smp_lock.h> #include <asm/uaccess.h> -int ext3_ioctl (struct inode * inode,struct file * filp,unsigned int cmd, -unsigned long arg) +long ext3_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;struct ext3_inode_info *ei =EXT3_I (inode);unsigned int flags;unsigned short rsv_window_size;
@@ -263,9 +270,6 @@ flags_err:#ifdef CONFIG_COMPAT long ext3_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct inode *inode = file->f_path.dentry->d_inode; -int ret; -/* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) {case EXT3_IOC32_GETFLAGS :
@@ -305,9 +309,6 @@ long ext3_compat_ioctl(struct file *filedefault : return -ENOIOCTLCMD; } -lock_kernel (); - ret =ext3_ioctl (inode, file, cmd, (unsigned long )compat_ptr (arg)); -unlock_kernel (); -return ret; +return ext3_ioctl (file, cmd, (unsigned long )compat_ptr (arg)); }#endif
include/linux/ext3_fs.h +1 -2
@@ -838,8 +838,7 @@ extern void ext3_get_inode_flags(structextern void ext3_set_aops (struct inode *inode);/* ioctl.c */ -extern int ext3_ioctl (struct inode *,struct file *,unsigned int , -unsigned long ); +extern long ext3_ioctl (struct file *,unsigned int ,unsigned long );extern long ext3_compat_ioctl (struct file *,unsigned int ,unsigned long );/* namei.c */
PATCH 4/7 ext3: Remove incorrect BKL comment
In reply to Andi KleenThere is no BKL held on entry in ->fsync nor in the low level ext3_sync_file.
--- fs/ext3/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext3/dir.c +1 -1
@@ -46,7 +46,7 @@ const struct file_operations ext3_dir_op#ifdef CONFIG_COMPAT .compat_ioctl = ext3_compat_ioctl, #endif - .fsync = ext3_sync_file, /* BKL held */ + .fsync = ext3_sync_file, .release = ext3_release_dir, };
PATCH 5/7 Remove incorrect comment refering to lock_kernel() from jbd/jbd2
In reply to Andi KleenNone of the callers of this function does actually take the BKL as far as I can see. So remove the comment refering to the BKL.
--- fs/jbd/recovery.c | 2 +- fs/jbd2/recovery.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jbd/recovery.c +1 -1
@@ -354,7 +354,7 @@ static int do_one_pass(journal_t *journastruct buffer_head * obh;struct buffer_head * nbh; -cond_resched ();/* We're under lock_kernel() */ +cond_resched ();/* If we already know where to stop the log traversal, * check right now that we haven't gone past the end of
fs/jbd2/recovery.c +1 -1
@@ -364,7 +364,7 @@ static int do_one_pass(journal_t *journastruct buffer_head * obh;struct buffer_head * nbh; -cond_resched ();/* We're under lock_kernel() */ +cond_resched ();/* If we already know where to stop the log traversal, * check right now that we haven't gone past the end of
PATCH 6/7 Convert ext4 to use unlocked_ioctl v2
In reply to Andi KleenI checked ext4_ioctl and it looked largely safe to not be used without BKL. So convert it over to unlocked_ioctl.
v1->v2: drop BKL for online grow. resize.c seems to do enough locking
--- fs/ext4/dir.c | 2 +- fs/ext4/file.c | 2 +- fs/ext4/ioctl.c | 20 +++++++++++--------- include/linux/ext4_fs.h | 3 +-- 4 files changed, 14 insertions(+), 13 deletions(-)
fs/ext4/dir.c +1 -1
@@ -42,7 +42,7 @@ const struct file_operations ext4_dir_op .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = ext4_readdir, /* we take BKL. needed?*/ - .ioctl = ext4_ioctl, /* BKL held */ + .unlocked_ioctl = ext4_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext4_compat_ioctl,#endif
fs/ext4/file.c +1 -1
@@ -112,7 +112,7 @@ const struct file_operations ext4_file_o .write = do_sync_write, .aio_read = generic_file_aio_read, .aio_write = ext4_file_write, - .ioctl = ext4_ioctl, + .unlocked_ioctl = ext4_ioctl,#ifdef CONFIG_COMPAT .compat_ioctl = ext4_compat_ioctl,#endif
fs/ext4/ioctl.c +3 -9
@@ -17,9 +17,9 @@#include <linux/smp_lock.h> #include <asm/uaccess.h> -int ext4_ioctl (struct inode * inode,struct file * filp,unsigned int cmd, -unsigned long arg) +long ext4_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) { +struct inode *inode = filp->f_dentry->d_inode;struct ext4_inode_info *ei =EXT4_I (inode);unsigned int flags;unsigned short rsv_window_size;
@@ -262,9 +270,6 @@ flags_err:#ifdef CONFIG_COMPAT long ext4_compat_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct inode *inode = file->f_path.dentry->d_inode; -int ret; -/* These are just misnamed, they actually get/put from/to user an int */ switch (cmd) {case EXT4_IOC32_GETFLAGS :
@@ -304,9 +309,6 @@ long ext4_compat_ioctl(struct file *filedefault : return -ENOIOCTLCMD; } -lock_kernel (); - ret =ext4_ioctl (inode, file, cmd, (unsigned long )compat_ptr (arg)); -unlock_kernel (); -return ret; +return ext4_ioctl (file, cmd, (unsigned long )compat_ptr (arg)); }#endif
include/linux/ext4_fs.h +1 -2
@@ -939,8 +939,7 @@ extern int ext4_block_truncate_page(hand struct address_space *mapping, loff_t from);/* ioctl.c */ -extern int ext4_ioctl (struct inode *,struct file *,unsigned int , -unsigned long ); +extern long ext4_ioctl (struct file *,unsigned int ,unsigned long );extern long ext4_compat_ioctl (struct file *,unsigned int ,unsigned long );/* namei.c */
PATCH 7/7 Remove incorrect BKL comments in ext4
In reply to Andi Kleen--- fs/ext4/dir.c | 2 +- fs/ext4/inode.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
fs/ext4/dir.c +1 -1
@@ -46,7 +46,7 @@ const struct file_operations ext4_dir_op#ifdef CONFIG_COMPAT .compat_ioctl = ext4_compat_ioctl, #endif - .fsync = ext4_sync_file, /* BKL held */ + .fsync = ext4_sync_file, .release = ext4_release_dir, };
fs/ext4/inode.c +0 -1
@@ -778,7 +778,6 @@ err_out:* * `handle' can be NULL if create == 0. * -* The BKL may not be held on entry here. Be sure to take it early. * return > 0, # of blocks mapped or allocated. * return = 0, if plain lookup failed. * return < 0, error case.
Theodore Tso
maintainerQuoted 5 lines · Andi Kleen
Remove the BKL from the ext* ioctls.
This is a slightly updated version of the ext[2-4] patches that hit linux-fsdevel earlier.
Thanks, I've included these patches into the ext4 tree, and should hopefully be pulled into the next -mm tree.
- Ted