Commit 10041d2d14688e207d0d829095147aa82c1f211b

Authored by Linus Torvalds

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

Showing 11 changed files Side-by-side Diff

Documentation/filesystems/Locking
... ... @@ -374,8 +374,6 @@
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 *);
... ... @@ -409,8 +407,7 @@
409 407 aio_write: no
410 408 readdir: no
411 409 poll: no
412   -ioctl: yes (see below)
413   -unlocked_ioctl: no (see below)
  410 +unlocked_ioctl: no
414 411 compat_ioctl: no
415 412 mmap: no
416 413 open: no
... ... @@ -452,9 +449,6 @@
452 449 ->ioctl() or kill the latter completely. One of the problems is that for
453 450 anything that resembles union-mount we won't have a struct file for all
454 451 components. And there are other reasons why the current interface is a mess...
455   -
456   -->ioctl() on regular files is superceded by the ->unlocked_ioctl() that
457   -doesn't take the BKL.
458 452  
459 453 ->read on directories probably must go away - we should just enforce -EISDIR
460 454 in sys_read() and friends.
Documentation/filesystems/vfs.txt
... ... @@ -727,7 +727,6 @@
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 *);
... ... @@ -768,10 +767,7 @@
768 767 activity on this file and (optionally) go to sleep until there
769 768 is activity. Called by the select(2) and poll(2) system calls
770 769  
771   - ioctl: called by the ioctl(2) system call
772   -
773   - unlocked_ioctl: called by the ioctl(2) system call. Filesystems that do not
774   - require the BKL should use this method instead of the ioctl() above.
  770 + unlocked_ioctl: called by the ioctl(2) system call.
775 771  
776 772 compat_ioctl: called by the ioctl(2) system call when 32 bit system calls
777 773 are used on 64 bit kernels.
drivers/media/video/v4l2-compat-ioctl32.c
... ... @@ -228,11 +228,6 @@
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 }
... ... @@ -973,7 +968,7 @@
973 968 {
974 969 long ret = -ENOIOCTLCMD;
975 970  
976   - if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl)
  971 + if (!file->f_op->unlocked_ioctl)
977 972 return ret;
978 973  
979 974 switch (cmd) {
... ... @@ -55,12 +55,6 @@
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 {
... ... @@ -159,7 +153,6 @@
159 153 .aio_write = bad_file_aio_write,
160 154 .readdir = bad_file_readdir,
161 155 .poll = bad_file_poll,
162   - .ioctl = bad_file_ioctl,
163 156 .unlocked_ioctl = bad_file_unlocked_ioctl,
164 157 .compat_ioctl = bad_file_compat_ioctl,
165 158 .mmap = bad_file_mmap,
... ... @@ -1699,8 +1699,7 @@
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 }
... ... @@ -29,7 +29,6 @@
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.
36 35  
... ... @@ -39,21 +38,12 @@
39 38 {
40 39 int error = -ENOTTY;
41 40  
42   - if (!filp->f_op)
  41 + if (!filp->f_op || !filp->f_op->unlocked_ioctl)
43 42 goto out;
44 43  
45   - if (filp->f_op->unlocked_ioctl) {
46   - error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
47   - if (error == -ENOIOCTLCMD)
48   - error = -EINVAL;
49   - goto out;
50   - } else if (filp->f_op->ioctl) {
51   - lock_kernel();
52   - error = filp->f_op->ioctl(filp->f_path.dentry->d_inode,
53   - filp, cmd, arg);
54   - unlock_kernel();
55   - }
56   -
  44 + error = filp->f_op->unlocked_ioctl(filp, cmd, arg);
  45 + if (error == -ENOIOCTLCMD)
  46 + error = -EINVAL;
57 47 out:
58 48 return error;
59 49 }
... ... @@ -824,7 +824,7 @@
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 };
... ... @@ -181,9 +181,9 @@
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,7 +255,7 @@
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,
... ... @@ -504,8 +504,7 @@
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 */
... ... @@ -214,8 +214,7 @@
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 221  
... ... @@ -223,19 +222,11 @@
223 222 return rv;
224 223 }
225 224 pde->pde_users++;
226   - unlocked_ioctl = pde->proc_fops->unlocked_ioctl;
227   - ioctl = pde->proc_fops->ioctl;
  225 + ioctl = pde->proc_fops->unlocked_ioctl;
228 226 spin_unlock(&pde->pde_unload_lock);
229 227  
230   - if (unlocked_ioctl) {
231   - rv = unlocked_ioctl(file, cmd, arg);
232   - if (rv == -ENOIOCTLCMD)
233   - rv = -EINVAL;
234   - } else if (ioctl) {
235   - WARN_ONCE(1, "Procfs ioctl handlers must use unlocked_ioctl, "
236   - "%pf will be called without the Bkl held\n", ioctl);
237   - rv = ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
238   - }
  228 + if (ioctl)
  229 + rv = ioctl(file, cmd, arg);
239 230  
240 231 pde_users_dec(pde);
241 232 return rv;
... ... @@ -1483,8 +1483,8 @@
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,7 +1495,6 @@
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 *);