diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 20:52:35 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 20:52:35 -0400 |
| commit | 10041d2d14688e207d0d829095147aa82c1f211b (patch) | |
| tree | 57ef361d05e6bbffe3ec490ca9110878a6e969e2 /fs | |
| parent | 4914c7f881845367b9198631a014ab466329b9e5 (diff) | |
| parent | b19dd42faf413b4705d4adb38521e82d73fa4249 (diff) | |
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
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/bad_inode.c | 7 | ||||
| -rw-r--r-- | fs/compat_ioctl.c | 3 | ||||
| -rw-r--r-- | fs/ioctl.c | 18 | ||||
| -rw-r--r-- | fs/logfs/dir.c | 2 | ||||
| -rw-r--r-- | fs/logfs/file.c | 6 | ||||
| -rw-r--r-- | fs/logfs/logfs.h | 3 | ||||
| -rw-r--r-- | fs/proc/inode.c | 17 |
7 files changed, 14 insertions, 42 deletions
diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 52e59bf4aa5..f024d8aadde 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c | |||
| @@ -55,12 +55,6 @@ static unsigned int bad_file_poll(struct file *filp, poll_table *wait) | |||
| 55 | return POLLERR; | 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 | static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd, | 58 | static long bad_file_unlocked_ioctl(struct file *file, unsigned cmd, |
| 65 | unsigned long arg) | 59 | unsigned long arg) |
| 66 | { | 60 | { |
| @@ -159,7 +153,6 @@ static const struct file_operations bad_file_ops = | |||
| 159 | .aio_write = bad_file_aio_write, | 153 | .aio_write = bad_file_aio_write, |
| 160 | .readdir = bad_file_readdir, | 154 | .readdir = bad_file_readdir, |
| 161 | .poll = bad_file_poll, | 155 | .poll = bad_file_poll, |
| 162 | .ioctl = bad_file_ioctl, | ||
| 163 | .unlocked_ioctl = bad_file_unlocked_ioctl, | 156 | .unlocked_ioctl = bad_file_unlocked_ioctl, |
| 164 | .compat_ioctl = bad_file_compat_ioctl, | 157 | .compat_ioctl = bad_file_compat_ioctl, |
| 165 | .mmap = bad_file_mmap, | 158 | .mmap = bad_file_mmap, |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 70227e0dc01..03e59aa318e 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
| @@ -1699,8 +1699,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 1699 | goto out_fput; | 1699 | goto out_fput; |
| 1700 | } | 1700 | } |
| 1701 | 1701 | ||
| 1702 | if (!filp->f_op || | 1702 | if (!filp->f_op || !filp->f_op->unlocked_ioctl) |
| 1703 | (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl)) | ||
| 1704 | goto do_ioctl; | 1703 | goto do_ioctl; |
| 1705 | break; | 1704 | break; |
| 1706 | } | 1705 | } |
diff --git a/fs/ioctl.c b/fs/ioctl.c index 2d140a71386..f855ea4fc88 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | * @arg: command-specific argument for ioctl | 29 | * @arg: command-specific argument for ioctl |
| 30 | * | 30 | * |
| 31 | * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise | 31 | * Invokes filesystem specific ->unlocked_ioctl, if one exists; otherwise |
| 32 | * invokes filesystem specific ->ioctl method. If neither method exists, | ||
| 33 | * returns -ENOTTY. | 32 | * returns -ENOTTY. |
| 34 | * | 33 | * |
| 35 | * Returns 0 on success, -errno on error. | 34 | * Returns 0 on success, -errno on error. |
| @@ -39,21 +38,12 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd, | |||
| 39 | { | 38 | { |
| 40 | int error = -ENOTTY; | 39 | int error = -ENOTTY; |
| 41 | 40 | ||
| 42 | if (!filp->f_op) | 41 | if (!filp->f_op || !filp->f_op->unlocked_ioctl) |
| 43 | goto out; | 42 | goto out; |
| 44 | 43 | ||
| 45 | if (filp->f_op->unlocked_ioctl) { | 44 | error = filp->f_op->unlocked_ioctl(filp, cmd, arg); |
| 46 | error = filp->f_op->unlocked_ioctl(filp, cmd, arg); | 45 | if (error == -ENOIOCTLCMD) |
| 47 | if (error == -ENOIOCTLCMD) | 46 | error = -EINVAL; |
| 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 | |||
| 57 | out: | 47 | out: |
| 58 | return error; | 48 | return error; |
| 59 | } | 49 | } |
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c index 675cc49197f..9777eb5b552 100644 --- a/fs/logfs/dir.c +++ b/fs/logfs/dir.c | |||
| @@ -824,7 +824,7 @@ const struct inode_operations logfs_dir_iops = { | |||
| 824 | }; | 824 | }; |
| 825 | const struct file_operations logfs_dir_fops = { | 825 | const struct file_operations logfs_dir_fops = { |
| 826 | .fsync = logfs_fsync, | 826 | .fsync = logfs_fsync, |
| 827 | .ioctl = logfs_ioctl, | 827 | .unlocked_ioctl = logfs_ioctl, |
| 828 | .readdir = logfs_readdir, | 828 | .readdir = logfs_readdir, |
| 829 | .read = generic_read_dir, | 829 | .read = generic_read_dir, |
| 830 | }; | 830 | }; |
diff --git a/fs/logfs/file.c b/fs/logfs/file.c index 4dd0f7c06e3..e86376b87af 100644 --- a/fs/logfs/file.c +++ b/fs/logfs/file.c | |||
| @@ -181,9 +181,9 @@ static int logfs_releasepage(struct page *page, gfp_t only_xfs_uses_this) | |||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | 183 | ||
| 184 | int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 184 | long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 185 | unsigned long arg) | ||
| 186 | { | 185 | { |
| 186 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 187 | struct logfs_inode *li = logfs_inode(inode); | 187 | struct logfs_inode *li = logfs_inode(inode); |
| 188 | unsigned int oldflags, flags; | 188 | unsigned int oldflags, flags; |
| 189 | int err; | 189 | int err; |
| @@ -255,7 +255,7 @@ const struct file_operations logfs_reg_fops = { | |||
| 255 | .aio_read = generic_file_aio_read, | 255 | .aio_read = generic_file_aio_read, |
| 256 | .aio_write = generic_file_aio_write, | 256 | .aio_write = generic_file_aio_write, |
| 257 | .fsync = logfs_fsync, | 257 | .fsync = logfs_fsync, |
| 258 | .ioctl = logfs_ioctl, | 258 | .unlocked_ioctl = logfs_ioctl, |
| 259 | .llseek = generic_file_llseek, | 259 | .llseek = generic_file_llseek, |
| 260 | .mmap = generic_file_readonly_mmap, | 260 | .mmap = generic_file_readonly_mmap, |
| 261 | .open = generic_file_open, | 261 | .open = generic_file_open, |
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h index 5e3b7207795..b8786264d24 100644 --- a/fs/logfs/logfs.h +++ b/fs/logfs/logfs.h | |||
| @@ -504,8 +504,7 @@ extern const struct inode_operations logfs_reg_iops; | |||
| 504 | extern const struct file_operations logfs_reg_fops; | 504 | extern const struct file_operations logfs_reg_fops; |
| 505 | extern const struct address_space_operations logfs_reg_aops; | 505 | extern const struct address_space_operations logfs_reg_aops; |
| 506 | int logfs_readpage(struct file *file, struct page *page); | 506 | int logfs_readpage(struct file *file, struct page *page); |
| 507 | int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 507 | long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
| 508 | unsigned long arg); | ||
| 509 | int logfs_fsync(struct file *file, int datasync); | 508 | int logfs_fsync(struct file *file, int datasync); |
| 510 | 509 | ||
| 511 | /* gc.c */ | 510 | /* gc.c */ |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 23561cda724..9c2b5f48487 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
| @@ -214,8 +214,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne | |||
| 214 | { | 214 | { |
| 215 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 215 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); |
| 216 | long rv = -ENOTTY; | 216 | long rv = -ENOTTY; |
| 217 | long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); | 217 | long (*ioctl)(struct file *, unsigned int, unsigned long); |
| 218 | int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long); | ||
| 219 | 218 | ||
| 220 | spin_lock(&pde->pde_unload_lock); | 219 | spin_lock(&pde->pde_unload_lock); |
| 221 | if (!pde->proc_fops) { | 220 | if (!pde->proc_fops) { |
| @@ -223,19 +222,11 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne | |||
| 223 | return rv; | 222 | return rv; |
| 224 | } | 223 | } |
| 225 | pde->pde_users++; | 224 | pde->pde_users++; |
| 226 | unlocked_ioctl = pde->proc_fops->unlocked_ioctl; | 225 | ioctl = pde->proc_fops->unlocked_ioctl; |
| 227 | ioctl = pde->proc_fops->ioctl; | ||
| 228 | spin_unlock(&pde->pde_unload_lock); | 226 | spin_unlock(&pde->pde_unload_lock); |
| 229 | 227 | ||
| 230 | if (unlocked_ioctl) { | 228 | if (ioctl) |
| 231 | rv = unlocked_ioctl(file, cmd, arg); | 229 | rv = 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 | } | ||
| 239 | 230 | ||
| 240 | pde_users_dec(pde); | 231 | pde_users_dec(pde); |
| 241 | return rv; | 232 | return rv; |
