Skip to content

Commit b19dd42

Browse files
arndbfweisbec
authored andcommitted
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>
1 parent c6d7ba8 commit b19dd42

7 files changed

Lines changed: 13 additions & 51 deletions

File tree

‎Documentation/filesystems/Locking‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,6 @@ prototypes:
374374
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
375375
int (*readdir) (struct file *, void *, filldir_t);
376376
unsigned int (*poll) (struct file *, struct poll_table_struct *);
377-
int (*ioctl) (struct inode *, struct file *, unsigned int,
378-
unsigned long);
379377
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
380378
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
381379
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -409,8 +407,7 @@ write: no
409407
aio_write: no
410408
readdir: no
411409
poll: no
412-
ioctl: yes (see below)
413-
unlocked_ioctl: no (see below)
410+
unlocked_ioctl: no
414411
compat_ioctl: no
415412
mmap: no
416413
open: no
@@ -453,9 +450,6 @@ move ->readdir() to inode_operations and use a separate method for directory
453450
anything that resembles union-mount we won't have a struct file for all
454451
components. And there are other reasons why the current interface is a mess...
455452

456-
->ioctl() on regular files is superceded by the ->unlocked_ioctl() that
457-
doesn't take the BKL.
458-
459453
->read on directories probably must go away - we should just enforce -EISDIR
460454
in sys_read() and friends.
461455

‎Documentation/filesystems/vfs.txt‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@ struct file_operations {
727727
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
728728
int (*readdir) (struct file *, void *, filldir_t);
729729
unsigned int (*poll) (struct file *, struct poll_table_struct *);
730-
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
731730
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
732731
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
733732
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -768,10 +767,7 @@ otherwise noted.
768767
activity on this file and (optionally) go to sleep until there
769768
is activity. Called by the select(2) and poll(2) system calls
770769

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.
775771

776772
compat_ioctl: called by the ioctl(2) system call when 32 bit system calls
777773
are used on 64 bit kernels.

‎fs/bad_inode.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ static unsigned int bad_file_poll(struct file *filp, poll_table *wait)
5555
return POLLERR;
5656
}
5757

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-
6458
static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd,
6559
unsigned long arg)
6660
{
@@ -159,7 +153,6 @@ static const struct file_operations bad_file_ops =
159153
.aio_write = bad_file_aio_write,
160154
.readdir = bad_file_readdir,
161155
.poll = bad_file_poll,
162-
.ioctl = bad_file_ioctl,
163156
.unlocked_ioctl = bad_file_unlocked_ioctl,
164157
.compat_ioctl = bad_file_compat_ioctl,
165158
.mmap = bad_file_mmap,

‎fs/compat_ioctl.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
16991699
goto out_fput;
17001700
}
17011701

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)
17041703
goto do_ioctl;
17051704
break;
17061705
}

‎fs/ioctl.c‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
* @arg: command-specific argument for ioctl
3030
*
3131
* Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise
32-
* invokes filesystem specific ->ioctl method. If neither method exists,
3332
* returns -ENOTTY.
3433
*
3534
* Returns 0 on success, -errno on error.
@@ -39,21 +38,12 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
3938
{
4039
int error = -ENOTTY;
4140

42-
if (!filp->f_op)
41+
if (!filp->f_op || !filp->f_op->unlocked_ioctl)
4342
goto out;
4443

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;
5747
out:
5848
return error;
5949
}

‎fs/proc/inode.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,28 +214,19 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
214214
{
215215
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
216216
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);
219218

220219
spin_lock(&pde->pde_unload_lock);
221220
if (!pde->proc_fops) {
222221
spin_unlock(&pde->pde_unload_lock);
223222
return rv;
224223
}
225224
pde->pde_users++;
226-
unlocked_ioctl = pde->proc_fops->unlocked_ioctl;
227-
ioctl = pde->proc_fops->ioctl;
225+
ioctl = pde->proc_fops->unlocked_ioctl;
228226
spin_unlock(&pde->pde_unload_lock);
229227

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);
239230

240231
pde_users_dec(pde);
241232
return rv;

‎include/linux/fs.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,8 @@ struct block_device_operations;
14831483

14841484
/*
14851485
* 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.
14881488
*/
14891489
struct file_operations {
14901490
struct module *owner;
@@ -1495,7 +1495,6 @@ struct file_operations {
14951495
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
14961496
int (*readdir) (struct file *, void *, filldir_t);
14971497
unsigned int (*poll) (struct file *, struct poll_table_struct *);
1498-
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
14991498
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
15001499
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
15011500
int (*mmap) (struct file *, struct vm_area_struct *);

0 commit comments

Comments
 (0)