Merge branch 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing

* 'bkl/ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing:
bkl: Remove locked .ioctl file operation
v4l: Remove reference to bkl ioctl in compat ioctl handling
logfs: kill BKL

+19 -63
+1 -7
Documentation/filesystems/Locking
··· 374 374 ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 375 375 int (*readdir) (struct file *, void *, filldir_t); 376 376 unsigned int (*poll) (struct file *, struct poll_table_struct *); 377 - int (*ioctl) (struct inode *, struct file *, unsigned int, 378 - unsigned long); 379 377 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 380 378 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 381 379 int (*mmap) (struct file *, struct vm_area_struct *); ··· 407 409 aio_write: no 408 410 readdir: no 409 411 poll: no 410 - ioctl: yes (see below) 411 - unlocked_ioctl: no (see below) 412 + unlocked_ioctl: no 412 413 compat_ioctl: no 413 414 mmap: no 414 415 open: no ··· 449 452 ->ioctl() or kill the latter completely. One of the problems is that for 450 453 anything that resembles union-mount we won't have a struct file for all 451 454 components. And there are other reasons why the current interface is a mess... 452 - 453 - ->ioctl() on regular files is superceded by the ->unlocked_ioctl() that 454 - doesn't take the BKL. 455 455 456 456 ->read on directories probably must go away - we should just enforce -EISDIR 457 457 in sys_read() and friends.
+1 -5
Documentation/filesystems/vfs.txt
··· 727 727 ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 728 728 int (*readdir) (struct file *, void *, filldir_t); 729 729 unsigned int (*poll) (struct file *, struct poll_table_struct *); 730 - int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); 731 730 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 732 731 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 733 732 int (*mmap) (struct file *, struct vm_area_struct *); ··· 767 768 activity on this file and (optionally) go to sleep until there 768 769 is activity. Called by the select(2) and poll(2) system calls 769 770 770 - ioctl: called by the ioctl(2) system call 771 - 772 - unlocked_ioctl: called by the ioctl(2) system call. Filesystems that do not 773 - require the BKL should use this method instead of the ioctl() above. 771 + unlocked_ioctl: called by the ioctl(2) system call. 774 772 775 773 compat_ioctl: called by the ioctl(2) system call when 32 bit system calls 776 774 are used on 64 bit kernels.
+1 -6
drivers/media/video/v4l2-compat-ioctl32.c
··· 228 228 229 229 if (file->f_op->unlocked_ioctl) 230 230 ret = file->f_op->unlocked_ioctl(file, cmd, arg); 231 - else if (file->f_op->ioctl) { 232 - lock_kernel(); 233 - ret = file->f_op->ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 234 - unlock_kernel(); 235 - } 236 231 237 232 return ret; 238 233 } ··· 968 973 { 969 974 long ret = -ENOIOCTLCMD; 970 975 971 - if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl) 976 + if (!file->f_op->unlocked_ioctl) 972 977 return ret; 973 978 974 979 switch (cmd) {
-7
fs/bad_inode.c
··· 55 55 return POLLERR; 56 56 } 57 57 58 - static int bad_file_ioctl (struct inode *inode, struct file *filp, 59 - unsigned int cmd, unsigned long arg) 60 - { 61 - return -EIO; 62 - } 63 - 64 58 static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd, 65 59 unsigned long arg) 66 60 { ··· 153 159 .aio_write = bad_file_aio_write, 154 160 .readdir = bad_file_readdir, 155 161 .poll = bad_file_poll, 156 - .ioctl = bad_file_ioctl, 157 162 .unlocked_ioctl = bad_file_unlocked_ioctl, 158 163 .compat_ioctl = bad_file_compat_ioctl, 159 164 .mmap = bad_file_mmap,
+1 -2
fs/compat_ioctl.c
··· 1699 1699 goto out_fput; 1700 1700 } 1701 1701 1702 - if (!filp->f_op || 1703 - (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl)) 1702 + if (!filp->f_op || !filp->f_op->unlocked_ioctl) 1704 1703 goto do_ioctl; 1705 1704 break; 1706 1705 }
+4 -14
fs/ioctl.c
··· 29 29 * @arg: command-specific argument for ioctl 30 30 * 31 31 * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise 32 - * invokes filesystem specific ->ioctl method. If neither method exists, 33 32 * returns -ENOTTY. 34 33 * 35 34 * Returns 0 on success, -errno on error. ··· 38 39 { 39 40 int error = -ENOTTY; 40 41 41 - if (!filp->f_op) 42 + if (!filp->f_op || !filp->f_op->unlocked_ioctl) 42 43 goto out; 43 44 44 - if (filp->f_op->unlocked_ioctl) { 45 - error = filp->f_op->unlocked_ioctl(filp, cmd, arg); 46 - if (error == -ENOIOCTLCMD) 47 - error = -EINVAL; 48 - goto out; 49 - } else if (filp->f_op->ioctl) { 50 - lock_kernel(); 51 - error = filp->f_op->ioctl(filp->f_path.dentry->d_inode, 52 - filp, cmd, arg); 53 - unlock_kernel(); 54 - } 55 - 45 + error = filp->f_op->unlocked_ioctl(filp, cmd, arg); 46 + if (error == -ENOIOCTLCMD) 47 + error = -EINVAL; 56 48 out: 57 49 return error; 58 50 }
+1 -1
fs/logfs/dir.c
··· 824 824 }; 825 825 const struct file_operations logfs_dir_fops = { 826 826 .fsync = logfs_fsync, 827 - .ioctl = logfs_ioctl, 827 + .unlocked_ioctl = logfs_ioctl, 828 828 .readdir = logfs_readdir, 829 829 .read = generic_read_dir, 830 830 };
+3 -3
fs/logfs/file.c
··· 181 181 } 182 182 183 183 184 - int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 185 - unsigned long arg) 184 + long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 186 185 { 186 + struct inode *inode = file->f_path.dentry->d_inode; 187 187 struct logfs_inode *li = logfs_inode(inode); 188 188 unsigned int oldflags, flags; 189 189 int err; ··· 255 255 .aio_read = generic_file_aio_read, 256 256 .aio_write = generic_file_aio_write, 257 257 .fsync = logfs_fsync, 258 - .ioctl = logfs_ioctl, 258 + .unlocked_ioctl = logfs_ioctl, 259 259 .llseek = generic_file_llseek, 260 260 .mmap = generic_file_readonly_mmap, 261 261 .open = generic_file_open,
+1 -2
fs/logfs/logfs.h
··· 504 504 extern const struct file_operations logfs_reg_fops; 505 505 extern const struct address_space_operations logfs_reg_aops; 506 506 int logfs_readpage(struct file *file, struct page *page); 507 - int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 508 - unsigned long arg); 507 + long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 509 508 int logfs_fsync(struct file *file, int datasync); 510 509 511 510 /* gc.c */
+4 -13
fs/proc/inode.c
··· 214 214 { 215 215 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 216 216 long rv = -ENOTTY; 217 - long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); 218 - int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long); 217 + long (*ioctl)(struct file *, unsigned int, unsigned long); 219 218 220 219 spin_lock(&pde->pde_unload_lock); 221 220 if (!pde->proc_fops) { ··· 222 223 return rv; 223 224 } 224 225 pde->pde_users++; 225 - unlocked_ioctl = pde->proc_fops->unlocked_ioctl; 226 - ioctl = pde->proc_fops->ioctl; 226 + ioctl = pde->proc_fops->unlocked_ioctl; 227 227 spin_unlock(&pde->pde_unload_lock); 228 228 229 - if (unlocked_ioctl) { 230 - rv = unlocked_ioctl(file, cmd, arg); 231 - if (rv == -ENOIOCTLCMD) 232 - rv = -EINVAL; 233 - } else if (ioctl) { 234 - WARN_ONCE(1, "Procfs ioctl handlers must use unlocked_ioctl, " 235 - "%pf will be called without the Bkl held\n", ioctl); 236 - rv = ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 237 - } 229 + if (ioctl) 230 + rv = ioctl(file, cmd, arg); 238 231 239 232 pde_users_dec(pde); 240 233 return rv;
+2 -3
include/linux/fs.h
··· 1483 1483 1484 1484 /* 1485 1485 * NOTE: 1486 - * read, write, poll, fsync, readv, writev, unlocked_ioctl and compat_ioctl 1487 - * can be called without the big kernel lock held in all filesystems. 1486 + * all file operations except setlease can be called without 1487 + * the big kernel lock held in all filesystems. 1488 1488 */ 1489 1489 struct file_operations { 1490 1490 struct module *owner; ··· 1495 1495 ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1496 1496 int (*readdir) (struct file *, void *, filldir_t); 1497 1497 unsigned int (*poll) (struct file *, struct poll_table_struct *); 1498 - int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); 1499 1498 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1500 1499 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1501 1500 int (*mmap) (struct file *, struct vm_area_struct *);