Commit b19dd42faf413b4705d4adb38521e82d73fa4249

Authored by Arnd Bergmann
Committed by Frederic Weisbecker
1 parent c6d7ba8b12

bkl: Remove locked .ioctl file operation

The last user is gone, so we can safely remove this

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: John Kacur <jkacur@redhat.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>

Showing 7 changed files with 13 additions and 51 deletions 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.
... ... @@ -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 }
... ... @@ -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 *);