2010-04-16 03:56:43

by Frederic Weisbecker

[permalink] [raw]
Subject: [GIT PULL] Preparation for BKL'ed ioctl removal

Linus,

In order to stop the bkl contagion in ioctl and push the
bkl from Vfs to the drivers that don't implement a proper
unlock_ioctl, this patch proposes to add a new "locked_ioctl"
field in struct file_operation.

This field is never called from vfs and requires to assign a
new "deprecated_ioctl" helper to the unlocked_ioctl field.
This deprecated_ioctl() helper then calls the locked_ioctl()
callback with the bkl held.

The point of doing this is to change every users of fops::ioctl
to the new scheme. Once there is no more users of the ioctl field,
we'll then be able to remove it.

Also this change brings a new config BKL which is always
enabled for now. Every drivers that use the bkl through
explicit lock_kernel() calls or by using deprecated_ioctl()
will have to select CONFIG_BKL.

Once we get no more uses of the bkl from the core features but
only on individual drivers, config BKL can be turned off
by default and selected by those drivers if needed, relegating
the bkl as an obsolete library for poor old drivers.

And given the work happening currently (tty mutex, vfs pushdowns,
procfs bkl removal, llseek janitorials, etc...), this may happen
sooner than was expected.

Now the point of having this patch in 2.6.34 is to turn
the old ioctl implementations to the new scheme in a set
of patches that relevant maintainers can apply to their
tree (or apply by ourself for unmaintained areas) for .35
Otherwise we would need to queue everything in a single
tree that may bring conflicts in the next merge window.

This single patch has very few chances to bring any regressions.

Please pull the bkl/ioctl branch that can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
bkl/ioctl

Thanks,
Frederic
---

Arnd Bergmann (1):
vfs: Introduce CONFIG_BKL and deprecated_ioctl


fs/ioctl.c | 22 ++++++++++++++++++++++
include/linux/fs.h | 3 +++
include/linux/smp_lock.h | 4 ++++
kernel/Kconfig.locks | 10 ++++++++++
4 files changed, 39 insertions(+), 0 deletions(-)

---
commit 588a2267f7b2919ae73380e0932cc6a202787036
Author: Arnd Bergmann <[email protected]>
Date: Thu Apr 1 14:42:38 2010 +0200

vfs: Introduce CONFIG_BKL and deprecated_ioctl

This is a preparation for the removal of the big kernel lock that
introduces new interfaces for device drivers still using it.

We can start marking those device drivers as 'depends on CONFIG_BKL'
now, and make that symbol optional later, when the point has come
at which we are able to build a kernel without the BKL.

Similarly, device drivers that currently make use of the implicit
BKL locking around the ioctl function can now get annotated by
changing

.ioctl = foo_ioctl,

to

.locked_ioctl = foo_ioctl,
.unlocked_ioctl = deprecated_ioctl,

As soon as no driver remains using the old ioctl callback, it can
get removed.

[fweisbec: move config bkl from Kconfig.debug to Kconfig.locks,
rename default_ioctl to deprecated_ioctl]

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 6c75110..e6d6a75 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -58,6 +58,28 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
return error;
}

+#ifdef CONFIG_BKL
+/*
+ * deprecated_ioctl - call locked_ioctl with BKL held
+ *
+ * Setting only the ioctl operation but not unlocked_ioctl will become
+ * invalid in the future, all drivers that are not converted to unlocked_ioctl
+ * should set .unlocked_ioctl = deprecated_ioctl now.
+ */
+long deprecated_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ int error = -ENOTTY;
+ if (filp->f_op->locked_ioctl) {
+ lock_kernel();
+ error = filp->f_op->locked_ioctl(filp->f_path.dentry->d_inode,
+ filp, cmd, arg);
+ unlock_kernel();
+ }
+ return error;
+}
+EXPORT_SYMBOL_GPL(default_ioctl);
+#endif
+
static int ioctl_fibmap(struct file *filp, int __user *p)
{
struct address_space *mapping = filp->f_mapping;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 39d57bc..6b65b26 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1492,6 +1492,9 @@ struct file_operations {
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+#ifdef CONFIG_BKL
+ int (*locked_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+#endif
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index 2ea1dd1..c8693e1 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -62,4 +62,8 @@ static inline void cycle_kernel_lock(void)
#define kernel_locked() 1

#endif /* CONFIG_LOCK_KERNEL */
+
+loff_t default_llseek(struct file *file, loff_t offset, int origin);
+long deprecated_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
#endif /* __LINUX_SMPLOCK_H */
diff --git a/kernel/Kconfig.locks b/kernel/Kconfig.locks
index 88c92fb..9a80413 100644
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -200,3 +200,13 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE

config MUTEX_SPIN_ON_OWNER
def_bool SMP && !DEBUG_MUTEXES && !HAVE_DEFAULT_NO_SPIN_MUTEXES
+
+config BKL
+ def_bool y
+ help
+ This is the traditional lock that is used in old code instead
+ of proper locking. All drivers that use the BKL should depend
+ on this symbol.
+ This configuration option will become user-selectable in the
+ future, as soon as it is possible to build a kernel without
+ it.


2010-04-22 00:47:59

by Frederic Weisbecker

[permalink] [raw]
Subject: [GIT PULL v2] Preparation for BKL'ed ioctl removal

Linus,

In this v2, I've removed the declaration of default_llseek
from smp_lock.h, as this export can be made later (we
want to make any use of default_llseek() depend on
CONFIG_BKL as well, but that can wait).

Please pull the bkl/ioctl-v2 branch that can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
bkl/ioctl-v2

Thanks,
Frederic
---

Arnd Bergmann (1):
vfs: Introduce CONFIG_BKL and deprecated_ioctl


fs/ioctl.c | 22 ++++++++++++++++++++++
include/linux/fs.h | 3 +++
include/linux/smp_lock.h | 3 +++
kernel/Kconfig.locks | 10 ++++++++++
4 files changed, 38 insertions(+), 0 deletions(-)

---
commit 333f5fb46d15d057f0d69da0dd8b0a3db89bf34f
Author: Arnd Bergmann <[email protected]>
Date: Thu Apr 1 14:42:38 2010 +0200

vfs: Introduce CONFIG_BKL and deprecated_ioctl

This is a preparation for the removal of the big kernel lock that
introduces new interfaces for device drivers still using it.

We can start marking those device drivers as 'depends on CONFIG_BKL'
now, and make that symbol optional later, when the point has come
at which we are able to build a kernel without the BKL.

Similarly, device drivers that currently make use of the implicit
BKL locking around the ioctl function can now get annotated by
changing

.ioctl = foo_ioctl,

to

.locked_ioctl = foo_ioctl,
.unlocked_ioctl = deprecated_ioctl,

As soon as no driver remains using the old ioctl callback, it can
get removed.

[fweisbec: move config bkl from Kconfig.debug to Kconfig.locks,
rename default_ioctl to deprecated_ioctl]

v2: Remove default_llseek() declaration from smp_lock.h, we
don't need to prepare it to be modularized right now.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 6c75110..e6d6a75 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -58,6 +58,28 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
return error;
}

+#ifdef CONFIG_BKL
+/*
+ * deprecated_ioctl - call locked_ioctl with BKL held
+ *
+ * Setting only the ioctl operation but not unlocked_ioctl will become
+ * invalid in the future, all drivers that are not converted to unlocked_ioctl
+ * should set .unlocked_ioctl = deprecated_ioctl now.
+ */
+long deprecated_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ int error = -ENOTTY;
+ if (filp->f_op->locked_ioctl) {
+ lock_kernel();
+ error = filp->f_op->locked_ioctl(filp->f_path.dentry->d_inode,
+ filp, cmd, arg);
+ unlock_kernel();
+ }
+ return error;
+}
+EXPORT_SYMBOL_GPL(default_ioctl);
+#endif
+
static int ioctl_fibmap(struct file *filp, int __user *p)
{
struct address_space *mapping = filp->f_mapping;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 39d57bc..6b65b26 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1492,6 +1492,9 @@ struct file_operations {
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+#ifdef CONFIG_BKL
+ int (*locked_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+#endif
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index 2ea1dd1..3ed34da 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -62,4 +62,7 @@ static inline void cycle_kernel_lock(void)
#define kernel_locked() 1

#endif /* CONFIG_LOCK_KERNEL */
+
+long deprecated_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
#endif /* __LINUX_SMPLOCK_H */
diff --git a/kernel/Kconfig.locks b/kernel/Kconfig.locks
index 88c92fb..9a80413 100644
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -200,3 +200,13 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE

config MUTEX_SPIN_ON_OWNER
def_bool SMP && !DEBUG_MUTEXES && !HAVE_DEFAULT_NO_SPIN_MUTEXES
+
+config BKL
+ def_bool y
+ help
+ This is the traditional lock that is used in old code instead
+ of proper locking. All drivers that use the BKL should depend
+ on this symbol.
+ This configuration option will become user-selectable in the
+ future, as soon as it is possible to build a kernel without
+ it.

2010-04-24 15:25:38

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Thu, Apr 22, 2010 at 02:48:02AM +0200, Frederic Weisbecker wrote:
> Linus,
>
> In this v2, I've removed the declaration of default_llseek
> from smp_lock.h, as this export can be made later (we
> want to make any use of default_llseek() depend on
> CONFIG_BKL as well, but that can wait).
>
> Please pull the bkl/ioctl-v2 branch that can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> bkl/ioctl-v2
>
> Thanks,
> Frederic



Hi Linus,

This is the second version of this pull request and you don't seem to be
pulling it either.

Could you please tell us what kind of hesitation or problems you may have
with this?

If you think it's too late to merge this, we can still cook it for 2.6.35
and apply every dependent ioctl conversion in the same tree, this will have
the drawback that we can't push dependent patches to the relevant maintainers
trees (that said I guess that a good part of the drivers that still implement ioctl
are about unmaintained areas).

Or may be you don't like the core idea of this patch.

Either way please tell us so that we can go ahead with this and choose a
direction that looks more appropriate for you.

Thanks,
Frederic.

2010-04-24 18:38:46

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Sat, 24 Apr 2010, Frederic Weisbecker wrote:
>
> This is the second version of this pull request and you don't seem to be
> pulling it either.

I don't see the point, frankly. Especially not outside the merge window,
but quite frankly, I don't see it in general. The whole thing seems to be
designed to be inconvenient, and to have a config option that I
fundamentally don't believe in (CONFIG_BKL).

Linus

2010-04-24 18:49:33

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal


On Sat, 24 Apr 2010, Linus Torvalds wrote:
>
> I don't see the point, frankly. Especially not outside the merge window,
> but quite frankly, I don't see it in general. The whole thing seems to be
> designed to be inconvenient, and to have a config option that I
> fundamentally don't believe in (CONFIG_BKL).

More detail: it still leaves that old "ioctl" function pointer that needs
the BKL and is ungreppable. So the whole and only point of the patch is to
make our current mess even _more_ complex, with three different cases. No,
thank you.

Quite frankly, if you want to get rid of the BKL in ioctl's and make them
easily greppable, then I would suggest a simple renaming: rename the
current '->ioctl()' thing to '->bkl_ioctl()', and mark it deprecated. No
new config options, no new games. Just rename it. No need to mark things
with CONFIG_BKL, when you can just see it by virtue of them using
'bkl_ioctl'.

Linus

2010-04-24 19:54:23

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Saturday 24 April 2010 20:47:17 Linus Torvalds wrote:
> On Sat, 24 Apr 2010, Linus Torvalds wrote:
> >
> > I don't see the point, frankly. Especially not outside the merge window,
> > but quite frankly, I don't see it in general. The whole thing seems to be
> > designed to be inconvenient, and to have a config option that I
> > fundamentally don't believe in (CONFIG_BKL).
>
> More detail: it still leaves that old "ioctl" function pointer that needs
> the BKL and is ungreppable. So the whole and only point of the patch is to
> make our current mess even more complex, with three different cases. No,
> thank you.
>
> Quite frankly, if you want to get rid of the BKL in ioctl's and make them
> easily greppable, then I would suggest a simple renaming: rename the
> current '->ioctl()' thing to '->bkl_ioctl()', and mark it deprecated. No
> new config options, no new games. Just rename it. No need to mark things
> with CONFIG_BKL, when you can just see it by virtue of them using
> 'bkl_ioctl'.

We want to do the rename in the next merge window and remove the old
->ioctl(), this patch is just a preparation for this so we can start
queuing the patches for the rename in maintainer trees.
The addition of the deprecated_ioctl() helper is not essential but
let's us move all BKL users into loadable modules next.

The CONFIG_BKL stuff is not a requirement for doing this, but something
we /also/ want to do in the next merge window, i.e. mark all BKL users
as CONFIG_BKL, not just the ones that use the locked_ioctl (or bkl_ioctl).

I agree that it's now a bit late for this, but when I initially suggested
this (before -rc3, IIRC), that would have given us the chance to queue up
all the patches with a dependency on this for the next merge window.
Now the current outlook is probably that we do a lot of the preparation
work like this patch in 2.6.35-rc1, which moves the merge of the interesting
parts out to the 2.6.36 timeframe.

Arnd

2010-04-24 20:04:06

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Sat, 24 Apr 2010, Arnd Bergmann wrote:
>
> The CONFIG_BKL stuff is not a requirement for doing this, but something
> we /also/ want to do in the next merge window, i.e. mark all BKL users
> as CONFIG_BKL, not just the ones that use the locked_ioctl (or bkl_ioctl).

.. and I think that's simply fundamentally wrong. What does it buy us,
except for another really annoying config option? It sure as hell doesn't
buy us any code-size (what, a couple of bytes).

Quite frankly, if you want to just prepare to rename things one by one,
then you might as well just have a single line

#define bkl_ioctl ioctl

and then you can do

.bkl_ioctl = driver_ioctl

but the thing is - what does that _buy_ us without the ability to grep for
and cause compile errors for drivers that haven't done this? Nothing.

So seriously - I'd _much_ rather just get one single large patch that just
renames everything. None of this crap that makes no sense.

Linus

2010-04-24 20:41:23

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Saturday 24 April 2010 22:01:18 Linus Torvalds wrote:
> On Sat, 24 Apr 2010, Arnd Bergmann wrote:
> >
> > The CONFIG_BKL stuff is not a requirement for doing this, but something
> > we also want to do in the next merge window, i.e. mark all BKL users
> > as CONFIG_BKL, not just the ones that use the locked_ioctl (or bkl_ioctl).
>
> .. and I think that's simply fundamentally wrong. What does it buy us,
> except for another really annoying config option? It sure as hell doesn't
> buy us any code-size (what, a couple of bytes).

With CONFIG_BKL disabled, we gain a few cyles in the scheduler,
since we no longer need to check if the BKL was held and needs to
be released. Not much, but better than just a few bytes of object size.

With CONFIG_BKL=m, what we gain is visibility: Doing an lsmod will
show you if bkl.ko is loaded and what other modules are using it.
My hope is that this will motivate people to remove it from the
remaining modules.
One of the crazier ideas was to automatically taint the kernel when
bkl.ko gets loaded. This does not gain us anything besides making a
statement.

> Quite frankly, if you want to just prepare to rename things one by one,
> then you might as well just have a single line
>
> #define bkl_ioctl ioctl
>
> and then you can do
>
> .bkl_ioctl = driver_ioctl
>
> but the thing is - what does that buy us without the ability to grep for
> and cause compile errors for drivers that haven't done this? Nothing.

Being able to grep is not the reason for this patch. The reason is that
we're trying to eliminate the BKL from all non-obscure code in the kernel
and one of the nasty ones is fs/ioctl.c, which always gets compiled in.
The trick with bkl.ko requires that any code calling lock_kernel() needs
to be a module, so the deprecated_ioctl() helper will have to be part
of bkl.ko as well.

> So seriously - I'd much rather just get one single large patch that just
> renames everything. None of this crap that makes no sense.

Ok. We'll go back to my intial approach for ioctl then, doing it all at
once. The reason for the staged approach was to avoid bisect breakage
and conflicts with maintainer updates, but since most of the remaining
users at this point are really unmaintained (or staging drivers), there's
probably not much to worry about here.

There will be one patch that does three things:
- add a deprecated_ioctl() function
- rename fops->ioctl to fops->bkl_ioctl
- set fops->unlocked_ioctl=deprecated_ioctl for any file_operations instance
that uses bkl_ioctl
Is this ok for you?

Regarding the CONFIG_BKL option, should that also be done as another patch
changing all the Kconfig files? My preference would be to have one patch
adding the Kconfig option first, giving the maintainers the choice to either
mark their code 'depends on BKL' or to remove the dependency by changing
their code.

Arnd

2010-04-24 22:17:45

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Sat, 24 Apr 2010, Arnd Bergmann wrote:
>
> With CONFIG_BKL disabled, we gain a few cyles in the scheduler,

That has _nothing_ to do with the ioctl's though.

Stop mixing things up.

There are two totally independent issues:

- making the BKL ioctl's be explicit and findable

- eventually getting rid of the BKL entirely

and I think you guys are totally mixing things up, and making things WORSE
in the process.

The notion of having _three_ different "ioctl()" function pointers just
makes me want to gag. And there is absolutely _zero_ reason for it. Tjhere
is no way in hell that we want to have every subsystem maintainer try to
independently do their own ioctl's. Most of the drivers that have those
things are basically unmaintained or on the back burner anyway.

So don't make the current ugly ioctl situation worse. Not even as a
stop-gap, because there is absolutely _zero_ upside to making yet another
new crazy temporary ioctl interface.

And don't try to conflate the issue of ioctl and BKL. There are still
code-paths that do lock_kernel() without the ioctl's, so the whole ioctl
renaming has _zero_ to do with CONFIG_BKL.

Linus

2010-04-25 17:39:25

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Sat, Apr 24, 2010 at 03:15:23PM -0700, Linus Torvalds wrote:
>
>
> On Sat, 24 Apr 2010, Arnd Bergmann wrote:
> >
> > With CONFIG_BKL disabled, we gain a few cyles in the scheduler,
>
> That has _nothing_ to do with the ioctl's though.
>
> Stop mixing things up.
>
> There are two totally independent issues:
>
> - making the BKL ioctl's be explicit and findable
>
> - eventually getting rid of the BKL entirely
>
> and I think you guys are totally mixing things up, and making things WORSE
> in the process.
>
> The notion of having _three_ different "ioctl()" function pointers just
> makes me want to gag. And there is absolutely _zero_ reason for it. Tjhere
> is no way in hell that we want to have every subsystem maintainer try to
> independently do their own ioctl's. Most of the drivers that have those
> things are basically unmaintained or on the back burner anyway.
>
> So don't make the current ugly ioctl situation worse. Not even as a
> stop-gap, because there is absolutely _zero_ upside to making yet another
> new crazy temporary ioctl interface.


Our final goal was not to have three different ioctl interfaces. This state was
only deemed to be temporary. This was the only way to make the change
smoother and don't conflict with other trees with a single monolithic patch.

But if you are ok with a single one, then we are going this way and we'll send it for
the next merge window.


> And don't try to conflate the issue of ioctl and BKL. There are still
> code-paths that do lock_kernel() without the ioctl's, so the whole ioctl
> renaming has _zero_ to do with CONFIG_BKL.


It's true, but once it gets pushed down/dropped from every core parts (which
is what we are working on currently in parallel), lock_kernel() and .bkl_ioctl
is only going to be used by unmaintained drivers. This is the time where having
a CONFIG_BKL is going to make sense. And it won't be a question of saving some
bytes but improve efficiency of schedule() for those who don't need such old or
unmaintained drivers.

May be we should only start to focus on this new config once this state is reached.

And to prepare for that, are you ok with this scheme of:

- .ioctl = foo,
+ .unlocked_ioctl = bkl_ioctl,
+ .bkl_ioctl = foo,

...done at the same time as the big rename patch.
This will prepare to remove the bkl from vfs and build it conditionally
from the bkl lib, once the bkl is out the core?

2010-04-25 17:52:04

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Sun, 25 Apr 2010, Frederic Weisbecker wrote:
>
> And to prepare for that, are you ok with this scheme of:
>
> - .ioctl = foo,
> + .unlocked_ioctl = bkl_ioctl,
> + .bkl_ioctl = foo,
>
> ...done at the same time as the big rename patch.

Seriously, why not just

- .ioctl = foo,
+ .bkl_ioctl = foo

because that line of

+ .unlocked_ioctl = bkl_ioctl,

is just total and utter _garbage_. There is zero reason for it.

In the long run (this is a year from now, when we rename "unlocked_ioctl"
back to just "ioctl"), the vfs_ioctl code will just do

struct file_operations *fops = filp->f_op;

if (!fops)
return -ENOTTY;

if (fops->ioctl) {
int error = fops->ioctl(...)
if (error == -ENOIOCTLCMD)
error = -EINVAL;
return error;
}
#ifdef CONFIG_BKL
if (fops->bkl_ioctl) {
int error;
lock_kernel();
error = fops->bkl_ioctl(...)
unlock_kernel();
return error;
}
#endif
return -ENOTTY;

and we're all done.

At NO point is there any advantage to that "bkl_ioctl" crap. It doesn't
help the legacy drivers (which won't even _compile_ unless CONFIG_BKL is
set anyway), it doesn't help the core code, it doesn't help _anybody_.

Not today, not tomorrow, not with CONFIG_BKL, and not without.

Linus

2010-04-25 18:05:30

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Sun, Apr 25, 2010 at 10:49:51AM -0700, Linus Torvalds wrote:
>
>
> On Sun, 25 Apr 2010, Frederic Weisbecker wrote:
> >
> > And to prepare for that, are you ok with this scheme of:
> >
> > - .ioctl = foo,
> > + .unlocked_ioctl = bkl_ioctl,
> > + .bkl_ioctl = foo,
> >
> > ...done at the same time as the big rename patch.
>
> Seriously, why not just
>
> - .ioctl = foo,
> + .bkl_ioctl = foo
>
> because that line of
>
> + .unlocked_ioctl = bkl_ioctl,
>
> is just total and utter _garbage_. There is zero reason for it.
>
> In the long run (this is a year from now, when we rename "unlocked_ioctl"
> back to just "ioctl"), the vfs_ioctl code will just do
>
> struct file_operations *fops = filp->f_op;
>
> if (!fops)
> return -ENOTTY;
>
> if (fops->ioctl) {
> int error = fops->ioctl(...)
> if (error == -ENOIOCTLCMD)
> error = -EINVAL;
> return error;
> }
> #ifdef CONFIG_BKL
> if (fops->bkl_ioctl) {
> int error;
> lock_kernel();
> error = fops->bkl_ioctl(...)
> unlock_kernel();
> return error;
> }
> #endif
> return -ENOTTY;
>
> and we're all done.
>
> At NO point is there any advantage to that "bkl_ioctl" crap. It doesn't
> help the legacy drivers (which won't even _compile_ unless CONFIG_BKL is
> set anyway), it doesn't help the core code, it doesn't help _anybody_.
>
> Not today, not tomorrow, not with CONFIG_BKL, and not without.
>
> Linus


Well, we won't be able to get this bkl.ko but the desired effect of
having it was rather psychological than practical, as Arnd explained:
to make the dependency more visible and pull concerned people
into dropping the bkl from the drivers they are using.

But other than that, the final effect remains pretty the same so
it's not a big deal.

I'm ok with that.

Thanks for clarifying the situation!

2010-04-26 07:26:29

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal


* Frederic Weisbecker <[email protected]> wrote:

> > And don't try to conflate the issue of ioctl and BKL. There are still
> > code-paths that do lock_kernel() without the ioctl's, so the whole ioctl
> > renaming has _zero_ to do with CONFIG_BKL.
>
> It's true, but once it gets pushed down/dropped from every core parts (which
> is what we are working on currently in parallel), lock_kernel() and
> .bkl_ioctl is only going to be used by unmaintained drivers. This is the
> time where having a CONFIG_BKL is going to make sense. And it won't be a
> question of saving some bytes but improve efficiency of schedule() for those
> who don't need such old or unmaintained drivers.

The scheduler will be helped most by getting rid of the BKL altogether. We are
in reaching distance of that now ...

CONFIG_BKL would really just elongate the migration period, unnecessarily so.

> May be we should only start to focus on this new config once this state is
> reached.

Once that state is achived we can just get rid of the BKL and mass-push
per-driver mutexes into those remaining drivers - in a possibly scripted way.
Something like:

foo-driver.c

DEFINE_MUTEX(foo_mutex);

foo_ioctl()
{
mutex_lock(&foo_mutex);
...
mutex_unlock(&foo_mutex);
}

foo_open()
{
mutex_lock(&foo_mutex);
...
mutex_unlock(&foo_mutex);
}

This could be done all automated for a hundred old drivers if need to be.
There would be no bkl_ioctl's left.

That, even if it looks somewhat coarse is still better than having _yet
another_ 'temporary transition'. The Big Kernel Lock was supposed to be
transitionary to begin with. It's been 10+ years and counting :-)

Ingo

2010-04-26 08:31:08

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Sunday 25 April 2010 19:49:51 Linus Torvalds wrote:
> In the long run (this is a year from now, when we rename "unlocked_ioctl"
> back to just "ioctl"), the vfs_ioctl code will just do
>
> struct file_operations *fops = filp->f_op;
>
> if (!fops)
> return -ENOTTY;
>
> if (fops->ioctl) {
> int error = fops->ioctl(...)
> if (error == -ENOIOCTLCMD)
> error = -EINVAL;
> return error;
> }
> #ifdef CONFIG_BKL
> if (fops->bkl_ioctl) {
> int error;
> lock_kernel();
> error = fops->bkl_ioctl(...)
> unlock_kernel();
> return error;
> }
> #endif
> return -ENOTTY;

We could also stop playing games with with this and just kill the
locked variant of ioctl right away. No rename to bkl_ioctl, no
helper functions.

It's served it's purpose and we now have the list of 157 files
that still use fops->ioctl, so if we just push the BKL into those
files and make them use unlocked_ioctl, we will be able to remove
->ioctl for good. We can do the rename of ->unlocked_ioctl to
->ioctl right after that if you like, or in a year from now, I
don't care.

Arnd

2010-04-26 11:29:42

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Monday 26 April 2010, Ingo Molnar wrote:
> This could be done all automated for a hundred old drivers if need to be.
> There would be no bkl_ioctl's left.

I don't think it can be fully automated. For the majority of the modules,
your approach would work fine, but there are still the well-known
pitfalls in corner cases:

- recursive uses in functions outside of ioctl (possibly none left
after the TTY layer is done, but who knows)
- lock-order problems with other mutexes (see DRM)
- code that depends on autorelease to allow one ioctl while another
is sleeping. (a small number of drivers)

Semi-automated should be fine though. These rules are relatively
easy to check, so we can mass-convert all the trivial cases.

Examples for nontrivial modules are mostly file systems, see ncpfs,
afs, hpfs, ...

> That, even if it looks somewhat coarse is still better than having _yet
> another_ 'temporary transition'. The Big Kernel Lock was supposed to be
> transitionary to begin with. It's been 10+ years and counting :-)

I think the immediate goal should be to get the BKL out of everthing
that's either used by real people or that's reasonably easy to do.
We have patches for almost all of these now [1], and I've been running
a kernel with CONFIG_BKL=n for a few weeks now. As we progress
through the remaining modules, an increasing number of systems can
run without this.

I see the next steps as:
1. make it possible to build a kernel without BKL, by removing the BKL
from all core components for good, and making all users depend on
CONFIG_BKL. Make it default y and put it under CONFIG_DEBUG.

2. Remove the BKL from all modules that are either easy to convert
to a private mutex or that are relevant to real users (e.g.
definitely DRM, but maybe not hpfs).

3. Change CONFIG_BKL to "default n, depends on DEPRECATED"

4. Remove the remaining modules that nobody knows how to fix
or cares about. Possibly the number of modules here is close
to zero.

5. Remove the implementation of the BKL, since no users are left.

Getting stage 1 done for 2.6.36 or even 2.6.35 should be possible but
still needs a lot of work. I think we should focus on that for now
and then see how much is left to do for the other stages.

This is still a temporary transition, but since we can't do all at
once, I don't see better way.

Arnd

[1] http://kernelnewbies.org/BigKernelLock

2010-04-26 18:11:14

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Mon, 26 Apr 2010, Arnd Bergmann wrote:
>
> We could also stop playing games with with this and just kill the
> locked variant of ioctl right away. No rename to bkl_ioctl, no
> helper functions.

I wouldn't mind that. But we've not found people to do it so far, so...

Anyway, I spent some time automating the ioctl -> bkl_ioctl conversion.
The following is the end result. Comments?

Regardless of _what_ we do, renaming 'ioctl' to 'bkl_ioctl' is a good
thing. It means that we can reliably grep for these usages, whether it is
then to later introduce a CONFIG_BKL or if it is to get rid of the
bkl_ioctl entirely.

NOTE! This has gone through a "allmodconfig" (with staging drivers), but
only on x86-64. There are quite probably missing architecture conversions
and/or drivers. But this should be the bulk of them.

It doesn't look that bad. Just about 100 files affected.

Linus
---
commit 5312f12ed68dd43acca09ce646fdce3896a292bb
Author: Linus Torvalds <[email protected]>
Date: Mon Apr 26 10:55:23 2010 -0700

Rename 'struct file_operations' 'ioctl' fn pointer to 'bkl_ioctl'

This makes it much easier to grep for the use of implicit BKL usage in
the traditional 'ioctl' function pointer.

The patch was mostly auto-generated with the following shell scripting:

# Create an approximate file list of ioctl initializers
git grep -w -20 file_operations |
grep '\.ioctl[ ]*=' |
sed 's/-[ ]*\.ioctl.*$//' |
sort -u > f

# Run a sed script to replace 'ioctl' with 'bkl_ioctl'
cat f | while read i; do
j="$i.sed"
sed 's/\.ioctl([ ]*)=/.bkl_ioctl\1=/' < $i > $j
mv $j $i
done

followed by some similarly trivial scripting to then mostly fix up
places that tried to align all the initializers with tabs or spaces.

Finally, some manual fixup, and testing of the end result with a
allmodconfig make (with 'staging' drivers explicitly enabled).

Signed-off-by: Linus Torvalds <[email protected]>
---
arch/cris/arch-v10/drivers/ds1302.c | 2 +-
arch/cris/arch-v10/drivers/gpio.c | 2 +-
arch/cris/arch-v10/drivers/i2c.c | 2 +-
arch/cris/arch-v10/drivers/pcf8563.c | 2 +-
arch/cris/arch-v10/drivers/sync_serial.c | 2 +-
arch/cris/arch-v32/drivers/cryptocop.c | 2 +-
arch/cris/arch-v32/drivers/i2c.c | 2 +-
arch/cris/arch-v32/drivers/mach-a3/gpio.c | 2 +-
arch/cris/arch-v32/drivers/mach-fs/gpio.c | 2 +-
arch/cris/arch-v32/drivers/pcf8563.c | 2 +-
arch/cris/arch-v32/drivers/sync_serial.c | 2 +-
arch/ia64/kernel/perfmon.c | 2 +-
arch/ia64/sn/kernel/sn2/sn_hwperf.c | 2 +-
arch/m68k/bvme6000/rtc.c | 2 +-
arch/m68k/mvme16x/rtc.c | 2 +-
arch/um/drivers/harddog_kern.c | 2 +-
arch/um/drivers/hostaudio_kern.c | 4 ++--
arch/um/drivers/mmapper_kern.c | 2 +-
drivers/block/pktcdvd.c | 2 +-
drivers/char/apm-emulation.c | 2 +-
drivers/char/applicom.c | 2 +-
drivers/char/ds1620.c | 2 +-
drivers/char/dtlk.c | 2 +-
drivers/char/generic_nvram.c | 2 +-
drivers/char/genrtc.c | 2 +-
drivers/char/hpet.c | 2 +-
drivers/char/i8k.c | 2 +-
drivers/char/ipmi/ipmi_devintf.c | 2 +-
drivers/char/ipmi/ipmi_watchdog.c | 2 +-
drivers/char/nvram.c | 2 +-
drivers/char/nwflash.c | 2 +-
drivers/char/raw.c | 4 ++--
drivers/hwmon/fschmd.c | 2 +-
drivers/hwmon/w83793.c | 2 +-
drivers/input/misc/hp_sdc_rtc.c | 2 +-
drivers/isdn/capi/capi.c | 2 +-
drivers/isdn/divert/divert_procfs.c | 2 +-
drivers/isdn/i4l/isdn_common.c | 2 +-
drivers/isdn/mISDN/timerdev.c | 2 +-
drivers/macintosh/nvram.c | 2 +-
drivers/macintosh/via-pmu.c | 2 +-
drivers/media/dvb/dvb-core/dmxdev.c | 4 ++--
drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 2 +-
drivers/media/dvb/dvb-core/dvb_frontend.c | 2 +-
drivers/media/dvb/dvb-core/dvb_net.c | 2 +-
drivers/media/dvb/firewire/firedtv-ci.c | 2 +-
drivers/media/dvb/ttpci/av7110.c | 2 +-
drivers/media/dvb/ttpci/av7110_av.c | 4 ++--
drivers/media/dvb/ttpci/av7110_ca.c | 2 +-
drivers/media/video/v4l2-compat-ioctl32.c | 6 +++---
drivers/media/video/v4l2-dev.c | 2 +-
drivers/mtd/mtdchar.c | 2 +-
drivers/pcmcia/pcmcia_ioctl.c | 2 +-
drivers/rtc/rtc-m41t80.c | 2 +-
drivers/sbus/char/openprom.c | 2 +-
drivers/scsi/3w-9xxx.c | 2 +-
drivers/scsi/3w-sas.c | 2 +-
drivers/scsi/3w-xxxx.c | 2 +-
drivers/scsi/aacraid/linit.c | 2 +-
drivers/scsi/dpt_i2o.c | 2 +-
drivers/scsi/gdth.c | 2 +-
drivers/scsi/megaraid.c | 2 +-
drivers/scsi/megaraid/megaraid_mm.c | 2 +-
drivers/scsi/osst.c | 2 +-
drivers/scsi/sg.c | 2 +-
drivers/staging/crystalhd/crystalhd_lnx.c | 2 +-
drivers/staging/dt3155/dt3155_drv.c | 4 ++--
drivers/staging/poch/poch.c | 2 +-
drivers/staging/vme/devices/vme_user.c | 2 +-
drivers/usb/mon/mon_bin.c | 2 +-
drivers/usb/mon/mon_stat.c | 2 +-
fs/autofs/root.c | 2 +-
fs/autofs4/root.c | 2 +-
fs/bad_inode.c | 2 +-
fs/coda/pioctl.c | 2 +-
fs/coda/psdev.c | 2 +-
fs/compat_ioctl.c | 2 +-
fs/ecryptfs/file.c | 9 +++++----
fs/fat/dir.c | 2 +-
fs/fat/file.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/ioctl.c | 4 ++--
fs/logfs/dir.c | 2 +-
fs/logfs/file.c | 2 +-
fs/ncpfs/dir.c | 2 +-
fs/ncpfs/file.c | 2 +-
fs/ntfs/dir.c | 2 +-
fs/ntfs/file.c | 2 +-
fs/proc/inode.c | 8 ++++----
fs/smbfs/dir.c | 2 +-
fs/smbfs/file.c | 2 +-
fs/udf/dir.c | 2 +-
fs/udf/file.c | 2 +-
include/linux/fs.h | 2 +-
net/sunrpc/cache.c | 4 ++--
net/sunrpc/rpc_pipe.c | 2 +-
sound/oss/dmasound/dmasound_core.c | 4 ++--
sound/oss/msnd_pinnacle.c | 2 +-
sound/oss/sh_dac_audio.c | 2 +-
sound/oss/swarm_cs4297a.c | 4 ++--
sound/oss/vwsnd.c | 4 ++--
102 files changed, 121 insertions(+), 120 deletions(-)

diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 77630df..a921861 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -376,7 +376,7 @@ print_rtc_status(void)

static const struct file_operations rtc_fops = {
.owner = THIS_MODULE,
- .ioctl = rtc_ioctl,
+ .bkl_ioctl = rtc_ioctl,
};

/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index 4b0f65f..54db6cb 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -715,7 +715,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
- .ioctl = gpio_ioctl,
+ .bkl_ioctl = gpio_ioctl,
.write = gpio_write,
.open = gpio_open,
.release = gpio_release,
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
index a8737a8..2e7eb8a 100644
--- a/arch/cris/arch-v10/drivers/i2c.c
+++ b/arch/cris/arch-v10/drivers/i2c.c
@@ -619,7 +619,7 @@ i2c_ioctl(struct inode *inode, struct file *file,

static const struct file_operations i2c_fops = {
.owner = THIS_MODULE,
- .ioctl = i2c_ioctl,
+ .bkl_ioctl = i2c_ioctl,
.open = i2c_open,
.release = i2c_release,
};
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index 1e90c1a..1a1f0f3 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -62,7 +62,7 @@ static int voltage_low;

static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE,
- .ioctl = pcf8563_ioctl,
+ .bkl_ioctl = pcf8563_ioctl,
};

unsigned char
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c
index 109dcd8..04e7339 100644
--- a/arch/cris/arch-v10/drivers/sync_serial.c
+++ b/arch/cris/arch-v10/drivers/sync_serial.c
@@ -248,7 +248,7 @@ static const struct file_operations sync_serial_fops = {
.write = sync_serial_write,
.read = sync_serial_read,
.poll = sync_serial_poll,
- .ioctl = sync_serial_ioctl,
+ .bkl_ioctl = sync_serial_ioctl,
.open = sync_serial_open,
.release = sync_serial_release
};
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index b70fb34..9022dae 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -282,7 +282,7 @@ const struct file_operations cryptocop_fops = {
.owner = THIS_MODULE,
.open = cryptocop_open,
.release = cryptocop_release,
- .ioctl = cryptocop_ioctl
+ .bkl_ioctl = cryptocop_ioctl
};


diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 5068263..6cfe2cf 100644
--- a/arch/cris/arch-v32/drivers/i2c.c
+++ b/arch/cris/arch-v32/drivers/i2c.c
@@ -689,7 +689,7 @@ i2c_ioctl(struct inode *inode, struct file *file,

static const struct file_operations i2c_fops = {
.owner = THIS_MODULE,
- .ioctl = i2c_ioctl,
+ .bkl_ioctl = i2c_ioctl,
.open = i2c_open,
.release = i2c_release,
};
diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
index 97357cf..0031713 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
@@ -879,7 +879,7 @@ static int gpio_pwm_ioctl(struct gpio_private *priv, unsigned int cmd,
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
- .ioctl = gpio_ioctl,
+ .bkl_ioctl = gpio_ioctl,
.write = gpio_write,
.open = gpio_open,
.release = gpio_release,
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
index d89ab80..72ffbfa 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
@@ -858,7 +858,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
- .ioctl = gpio_ioctl,
+ .bkl_ioctl = gpio_ioctl,
.write = gpio_write,
.open = gpio_open,
.release = gpio_release,
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index f447850..223081a 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -58,7 +58,7 @@ static int voltage_low;

static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE,
- .ioctl = pcf8563_ioctl
+ .bkl_ioctl = pcf8563_ioctl
};

unsigned char
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index 4889f19..8ce4f32 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -245,7 +245,7 @@ static const struct file_operations sync_serial_fops = {
.write = sync_serial_write,
.read = sync_serial_read,
.poll = sync_serial_poll,
- .ioctl = sync_serial_ioctl,
+ .bkl_ioctl = sync_serial_ioctl,
.open = sync_serial_open,
.release = sync_serial_release
};
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index ab985f7..0c4326c 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2178,7 +2178,7 @@ static const struct file_operations pfm_file_ops = {
.read = pfm_read,
.write = pfm_write,
.poll = pfm_poll,
- .ioctl = pfm_ioctl,
+ .bkl_ioctl = pfm_ioctl,
.open = pfm_no_open, /* special open code to disallow open via /proc */
.fasync = pfm_fasync,
.release = pfm_close,
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 55ac3c4..ffc65e1 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -864,7 +864,7 @@ error:
}

static const struct file_operations sn_hwperf_fops = {
- .ioctl = sn_hwperf_ioctl,
+ .bkl_ioctl = sn_hwperf_ioctl,
};

static struct miscdevice sn_hwperf_dev = {
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index b46ea17..fb939c6 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -163,7 +163,7 @@ static int rtc_release(struct inode *inode, struct file *file)
*/

static const struct file_operations rtc_fops = {
- .ioctl = rtc_ioctl,
+ .bkl_ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
};
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 8da9c25..9cebd9f 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -150,7 +150,7 @@ static int rtc_release(struct inode *inode, struct file *file)
*/

static const struct file_operations rtc_fops = {
- .ioctl = rtc_ioctl,
+ .bkl_ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
};
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index d332503..6cb24a1 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -151,7 +151,7 @@ static int harddog_ioctl(struct inode *inode, struct file *file,
static const struct file_operations harddog_fops = {
.owner = THIS_MODULE,
.write = harddog_write,
- .ioctl = harddog_ioctl,
+ .bkl_ioctl = harddog_ioctl,
.open = harddog_open,
.release = harddog_release,
};
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 368219c..cbc7366 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -289,7 +289,7 @@ static const struct file_operations hostaudio_fops = {
.read = hostaudio_read,
.write = hostaudio_write,
.poll = hostaudio_poll,
- .ioctl = hostaudio_ioctl,
+ .bkl_ioctl = hostaudio_ioctl,
.mmap = NULL,
.open = hostaudio_open,
.release = hostaudio_release,
@@ -298,7 +298,7 @@ static const struct file_operations hostaudio_fops = {
static const struct file_operations hostmixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = hostmixer_ioctl_mixdev,
+ .bkl_ioctl = hostmixer_ioctl_mixdev,
.open = hostmixer_open_mixdev,
.release = hostmixer_release,
};
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index d22f9e5..50f7976 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -90,7 +90,7 @@ static const struct file_operations mmapper_fops = {
.owner = THIS_MODULE,
.read = mmapper_read,
.write = mmapper_write,
- .ioctl = mmapper_ioctl,
+ .bkl_ioctl = mmapper_ioctl,
.mmap = mmapper_mmap,
.open = mmapper_open,
.release = mmapper_release,
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index ddf1942..d0bb5c7 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -3023,7 +3023,7 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm


static const struct file_operations pkt_ctl_fops = {
- .ioctl = pkt_ctl_ioctl,
+ .bkl_ioctl = pkt_ctl_ioctl,
.owner = THIS_MODULE,
};

diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 4f568cb..a7d3df3 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -397,7 +397,7 @@ static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = apm_read,
.poll = apm_poll,
- .ioctl = apm_ioctl,
+ .bkl_ioctl = apm_ioctl,
.open = apm_open,
.release = apm_release,
};
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a7424bf..8a845bd 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = {
.llseek = no_llseek,
.read = ac_read,
.write = ac_write,
- .ioctl = ac_ioctl,
+ .bkl_ioctl = ac_ioctl,
};

static struct miscdevice ac_miscdev = {
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index 61f0146..de8f7ba 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -344,7 +344,7 @@ static const struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
.open = ds1620_open,
.read = ds1620_read,
- .ioctl = ds1620_ioctl,
+ .bkl_ioctl = ds1620_ioctl,
};

static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 045c930..da15fb9 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops =
.read = dtlk_read,
.write = dtlk_write,
.poll = dtlk_poll,
- .ioctl = dtlk_ioctl,
+ .bkl_ioctl = dtlk_ioctl,
.open = dtlk_open,
.release = dtlk_release,
};
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index fda4181..0947ad9 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -121,7 +121,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .ioctl = nvram_ioctl,
+ .bkl_ioctl = nvram_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 31e7c91..414ca68 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -482,7 +482,7 @@ static const struct file_operations gen_rtc_fops = {
.read = gen_rtc_read,
.poll = gen_rtc_poll,
#endif
- .ioctl = gen_rtc_ioctl,
+ .bkl_ioctl = gen_rtc_ioctl,
.open = gen_rtc_open,
.release = gen_rtc_release,
};
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 9ded667..09c33d1 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -654,7 +654,7 @@ static const struct file_operations hpet_fops = {
.llseek = no_llseek,
.read = hpet_read,
.poll = hpet_poll,
- .ioctl = hpet_ioctl,
+ .bkl_ioctl = hpet_ioctl,
.open = hpet_open,
.release = hpet_release,
.fasync = hpet_fasync,
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index fc8cf7a..2a211d5 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -91,7 +91,7 @@ static const struct file_operations i8k_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
- .ioctl = i8k_ioctl,
+ .bkl_ioctl = i8k_ioctl,
};

struct smm_regs {
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 65545de..57b2990 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -826,7 +826,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,

static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
- .ioctl = ipmi_ioctl,
+ .bkl_ioctl = ipmi_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl,
#endif
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index a4d57e3..e8d478e 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -880,7 +880,7 @@ static const struct file_operations ipmi_wdog_fops = {
.read = ipmi_read,
.poll = ipmi_poll,
.write = ipmi_write,
- .ioctl = ipmi_ioctl,
+ .bkl_ioctl = ipmi_ioctl,
.open = ipmi_open,
.release = ipmi_close,
.fasync = ipmi_fasync,
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 47e8f7b..2688c4e 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -422,7 +422,7 @@ static const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = nvram_read,
.write = nvram_write,
- .ioctl = nvram_ioctl,
+ .bkl_ioctl = nvram_ioctl,
.open = nvram_open,
.release = nvram_release,
};
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index f808109..636b9f8 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -631,7 +631,7 @@ static const struct file_operations flash_fops =
.llseek = flash_llseek,
.read = flash_read,
.write = flash_write,
- .ioctl = flash_ioctl,
+ .bkl_ioctl = flash_ioctl,
};

static struct miscdevice flash_miscdev =
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 8756ab0..e0ece78 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -251,12 +251,12 @@ static const struct file_operations raw_fops = {
.fsync = blkdev_fsync,
.open = raw_open,
.release= raw_release,
- .ioctl = raw_ioctl,
+ .bkl_ioctl = raw_ioctl,
.owner = THIS_MODULE,
};

static const struct file_operations raw_ctl_fops = {
- .ioctl = raw_ctl_ioctl,
+ .bkl_ioctl = raw_ctl_ioctl,
.open = raw_open,
.owner = THIS_MODULE,
};
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index 0627f7a..fa60ff2 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -924,7 +924,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_release,
.write = watchdog_write,
- .ioctl = watchdog_ioctl,
+ .bkl_ioctl = watchdog_ioctl,
};


diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 612807d..6f63623 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1395,7 +1395,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_close,
.write = watchdog_write,
- .ioctl = watchdog_ioctl,
+ .bkl_ioctl = watchdog_ioctl,
};

/*
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ad730e1..0fdfd20 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -664,7 +664,7 @@ static const struct file_operations hp_sdc_rtc_fops = {
.llseek = no_llseek,
.read = hp_sdc_rtc_read,
.poll = hp_sdc_rtc_poll,
- .ioctl = hp_sdc_rtc_ioctl,
+ .bkl_ioctl = hp_sdc_rtc_ioctl,
.open = hp_sdc_rtc_open,
.fasync = hp_sdc_rtc_fasync,
};
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index ee58375..6bc9766 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1026,7 +1026,7 @@ static const struct file_operations capi_fops =
.read = capi_read,
.write = capi_write,
.poll = capi_poll,
- .ioctl = capi_ioctl,
+ .bkl_ioctl = capi_ioctl,
.open = capi_open,
.release = capi_release,
};
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 9f49d90..ae0244f 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -265,7 +265,7 @@ static const struct file_operations isdn_fops =
.read = isdn_divert_read,
.write = isdn_divert_write,
.poll = isdn_divert_poll,
- .ioctl = isdn_divert_ioctl,
+ .bkl_ioctl = isdn_divert_ioctl,
.open = isdn_divert_open,
.release = isdn_divert_close,
};
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 70044ee..08ba72d 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1838,7 +1838,7 @@ static const struct file_operations isdn_fops =
.read = isdn_read,
.write = isdn_write,
.poll = isdn_poll,
- .ioctl = isdn_ioctl,
+ .bkl_ioctl = isdn_ioctl,
.open = isdn_open,
.release = isdn_close,
};
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 8785004..fc7d777 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -263,7 +263,7 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
static const struct file_operations mISDN_fops = {
.read = mISDN_read,
.poll = mISDN_poll,
- .ioctl = mISDN_ioctl,
+ .bkl_ioctl = mISDN_ioctl,
.open = mISDN_open,
.release = mISDN_close,
};
diff --git a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c
index c876349..6a3115f 100644
--- a/drivers/macintosh/nvram.c
+++ b/drivers/macintosh/nvram.c
@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .ioctl = nvram_ioctl,
+ .bkl_ioctl = nvram_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 4276484..1cac03c 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2341,7 +2341,7 @@ static const struct file_operations pmu_device_fops = {
.read = pmu_read,
.write = pmu_write,
.poll = pmu_fpoll,
- .ioctl = pmu_ioctl,
+ .bkl_ioctl = pmu_ioctl,
.open = pmu_open,
.release = pmu_release,
};
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 9ddc579..a6c4f2f 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -1139,7 +1139,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_demux_fops = {
.owner = THIS_MODULE,
.read = dvb_demux_read,
- .ioctl = dvb_demux_ioctl,
+ .bkl_ioctl = dvb_demux_ioctl,
.open = dvb_demux_open,
.release = dvb_demux_release,
.poll = dvb_demux_poll,
@@ -1208,7 +1208,7 @@ static const struct file_operations dvb_dvr_fops = {
.owner = THIS_MODULE,
.read = dvb_dvr_read,
.write = dvb_dvr_write,
- .ioctl = dvb_dvr_ioctl,
+ .bkl_ioctl = dvb_dvr_ioctl,
.open = dvb_dvr_open,
.release = dvb_dvr_release,
.poll = dvb_dvr_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index cb22da5..4609c7e 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1611,7 +1611,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_en50221_io_read,
.write = dvb_ca_en50221_io_write,
- .ioctl = dvb_ca_en50221_io_ioctl,
+ .bkl_ioctl = dvb_ca_en50221_io_ioctl,
.open = dvb_ca_en50221_io_open,
.release = dvb_ca_en50221_io_release,
.poll = dvb_ca_en50221_io_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 55ea260..5ebf731 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -2022,7 +2022,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)

static const struct file_operations dvb_frontend_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.poll = dvb_frontend_poll,
.open = dvb_frontend_open,
.release = dvb_frontend_release
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 441c064..7ae8ef1 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1459,7 +1459,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)

static const struct file_operations dvb_net_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_net_ioctl,
+ .bkl_ioctl = dvb_net_ioctl,
.open = dvb_generic_open,
.release = dvb_net_close,
};
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index 853e04b..9378618 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -217,7 +217,7 @@ static unsigned int fdtv_ca_io_poll(struct file *file, poll_table *wait)

static const struct file_operations fdtv_ca_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
.poll = fdtv_ca_io_poll,
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 3891559..0e606af 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -727,7 +727,7 @@ static int dvb_osd_ioctl(struct inode *inode, struct file *file,

static const struct file_operations dvb_osd_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
};
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 5388481..62d3b1f 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1517,7 +1517,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_video_fops = {
.owner = THIS_MODULE,
.write = dvb_video_write,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_video_open,
.release = dvb_video_release,
.poll = dvb_video_poll,
@@ -1535,7 +1535,7 @@ static struct dvb_device dvbdev_video = {
static const struct file_operations dvb_audio_fops = {
.owner = THIS_MODULE,
.write = dvb_audio_write,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_audio_open,
.release = dvb_audio_release,
.poll = dvb_audio_poll,
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index ac7779c..94e0668 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -350,7 +350,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_read,
.write = dvb_ca_write,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_ca_open,
.release = dvb_generic_release,
.poll = dvb_ca_poll,
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index f77f84b..befb4ea 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -228,9 +228,9 @@ static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

if (file->f_op->unlocked_ioctl)
ret = file->f_op->unlocked_ioctl(file, cmd, arg);
- else if (file->f_op->ioctl) {
+ else if (file->f_op->bkl_ioctl) {
lock_kernel();
- ret = file->f_op->ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ ret = file->f_op->bkl_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
unlock_kernel();
}

@@ -973,7 +973,7 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
{
long ret = -ENOIOCTLCMD;

- if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl)
+ if (!file->f_op->bkl_ioctl && !file->f_op->unlocked_ioctl)
return ret;

switch (cmd) {
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7090699..c48143a 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -330,7 +330,7 @@ static const struct file_operations v4l2_fops = {
.open = v4l2_open,
.get_unmapped_area = v4l2_get_unmapped_area,
.mmap = v4l2_mmap,
- .ioctl = v4l2_ioctl,
+ .bkl_ioctl = v4l2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l2_compat_ioctl32,
#endif
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 5b081cb..57b48c4 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -942,7 +942,7 @@ static const struct file_operations mtd_fops = {
.llseek = mtd_lseek,
.read = mtd_read,
.write = mtd_write,
- .ioctl = mtd_ioctl,
+ .bkl_ioctl = mtd_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mtd_compat_ioctl,
#endif
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 104e73d..ca84016 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -1037,7 +1037,7 @@ static const struct file_operations ds_fops = {
.owner = THIS_MODULE,
.open = ds_open,
.release = ds_release,
- .ioctl = ds_ioctl,
+ .bkl_ioctl = ds_ioctl,
.read = ds_read,
.write = ds_write,
.poll = ds_poll,
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 60fe266..e662d61 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -736,7 +736,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
static const struct file_operations wdt_fops = {
.owner = THIS_MODULE,
.read = wdt_read,
- .ioctl = wdt_ioctl,
+ .bkl_ioctl = wdt_ioctl,
.write = wdt_write,
.open = wdt_open,
.release = wdt_release,
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index fc2f676..1fdc1a9 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -709,7 +709,7 @@ static int openprom_release(struct inode * inode, struct file * file)
static const struct file_operations openprom_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = openprom_ioctl,
+ .bkl_ioctl = openprom_ioctl,
.compat_ioctl = openprom_compat_ioctl,
.open = openprom_open,
.release = openprom_release,
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index e9788f5..32da0ef 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -218,7 +218,7 @@ static struct device_attribute *twa_host_attrs[] = {
/* File operations struct for character device */
static const struct file_operations twa_fops = {
.owner = THIS_MODULE,
- .ioctl = twa_chrdev_ioctl,
+ .bkl_ioctl = twa_chrdev_ioctl,
.open = twa_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 54c5ffb..3cac9e4 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -884,7 +884,7 @@ out:
/* File operations struct for character device */
static const struct file_operations twl_fops = {
.owner = THIS_MODULE,
- .ioctl = twl_chrdev_ioctl,
+ .bkl_ioctl = twl_chrdev_ioctl,
.open = twl_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 5faf903..2713dd5 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1051,7 +1051,7 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
/* File operations struct for character device */
static const struct file_operations tw_fops = {
.owner = THIS_MODULE,
- .ioctl = tw_chrdev_ioctl,
+ .bkl_ioctl = tw_chrdev_ioctl,
.open = tw_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index e9373a2..c2b037d 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1029,7 +1029,7 @@ ssize_t aac_get_serial_number(struct device *device, char *buf)

static const struct file_operations aac_cfg_fops = {
.owner = THIS_MODULE,
- .ioctl = aac_cfg_ioctl,
+ .bkl_ioctl = aac_cfg_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = aac_compat_cfg_ioctl,
#endif
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 0435d04..6ec5682 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -119,7 +119,7 @@ static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long);
#endif

static const struct file_operations adpt_fops = {
- .ioctl = adpt_ioctl,
+ .bkl_ioctl = adpt_ioctl,
.open = adpt_open,
.release = adpt_close,
#ifdef CONFIG_COMPAT
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 35a4b30..69c1629 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -369,7 +369,7 @@ MODULE_LICENSE("GPL");

/* ioctl interface */
static const struct file_operations gdth_fops = {
- .ioctl = gdth_ioctl,
+ .bkl_ioctl = gdth_ioctl,
.open = gdth_open,
.release = gdth_close,
};
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 4bf7edc..49a3501 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -96,7 +96,7 @@ static struct mega_hbas mega_hbas[MAX_CONTROLLERS];
*/
static const struct file_operations megadev_fops = {
.owner = THIS_MODULE,
- .ioctl = megadev_ioctl,
+ .bkl_ioctl = megadev_ioctl,
.open = megadev_open,
};

diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 36e0b7d..9bd7787 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -70,7 +70,7 @@ static wait_queue_head_t wait_q;

static const struct file_operations lsi_fops = {
.open = mraid_mm_open,
- .ioctl = mraid_mm_ioctl,
+ .bkl_ioctl = mraid_mm_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mraid_mm_compat_ioctl,
#endif
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index b219118..a1a78bb 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5613,7 +5613,7 @@ static const struct file_operations osst_fops = {
.owner = THIS_MODULE,
.read = osst_read,
.write = osst_write,
- .ioctl = osst_ioctl,
+ .bkl_ioctl = osst_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = osst_compat_ioctl,
#endif
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index dee1c96..93d043e 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1322,7 +1322,7 @@ static const struct file_operations sg_fops = {
.read = sg_read,
.write = sg_write,
.poll = sg_poll,
- .ioctl = sg_ioctl,
+ .bkl_ioctl = sg_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = sg_compat_ioctl,
#endif
diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index 54bad65..3d6b773 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -345,7 +345,7 @@ static int chd_dec_close(struct inode *in, struct file *fd)

static const struct file_operations chd_dec_fops = {
.owner = THIS_MODULE,
- .ioctl = chd_dec_ioctl,
+ .bkl_ioctl = chd_dec_ioctl,
.open = chd_dec_open,
.release = chd_dec_close,
};
diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index e2c44ec..09fb197 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -843,9 +843,9 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
*****************************************************/
static struct file_operations dt3155_fops = {
read: dt3155_read,
- ioctl: dt3155_ioctl,
+ bkl_ioctl: dt3155_ioctl,
mmap: dt3155_mmap,
- poll: dt3155_poll,
+ poll: dt3155_poll,
open: dt3155_open,
release: dt3155_close
};
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index f940a34..edc8c58 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -1037,7 +1037,7 @@ static struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
- .ioctl = poch_ioctl,
+ .bkl_ioctl = poch_ioctl,
.poll = poch_poll,
.mmap = poch_mmap
};
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 1ab9a98..7ba7149 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = {
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
- .ioctl = vme_user_ioctl,
+ .bkl_ioctl = vme_user_ioctl,
};


diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index ddf7f9a..9ce7c74 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1239,7 +1239,7 @@ static const struct file_operations mon_fops_binary = {
.read = mon_bin_read,
/* .write = mon_text_write, */
.poll = mon_bin_poll,
- .ioctl = mon_bin_ioctl,
+ .bkl_ioctl = mon_bin_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mon_bin_compat_ioctl,
#endif
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 1becdc3..091e7fb 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -63,6 +63,6 @@ const struct file_operations mon_fops_stat = {
.read = mon_stat_read,
/* .write = mon_stat_write, */
/* .poll = mon_stat_poll, */
- /* .ioctl = mon_stat_ioctl, */
+ /* .bkl_ioctl = mon_stat_ioctl, */
.release = mon_stat_release,
};
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 8713c7c..b838f68 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -30,7 +30,7 @@ static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned
const struct file_operations autofs_root_operations = {
.read = generic_read_dir,
.readdir = autofs_root_readdir,
- .ioctl = autofs_root_ioctl,
+ .bkl_ioctl = autofs_root_ioctl,
};

const struct inode_operations autofs_root_inode_operations = {
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 109a6c6..e764eb1 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -38,7 +38,7 @@ const struct file_operations autofs4_root_operations = {
.read = generic_read_dir,
.readdir = dcache_readdir,
.llseek = dcache_dir_lseek,
- .ioctl = autofs4_root_ioctl,
+ .bkl_ioctl = autofs4_root_ioctl,
};

const struct file_operations autofs4_dir_operations = {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index a05287a..3fd4ada 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -160,7 +160,7 @@ static const struct file_operations bad_file_ops =
.aio_write = bad_file_aio_write,
.readdir = bad_file_readdir,
.poll = bad_file_poll,
- .ioctl = bad_file_ioctl,
+ .bkl_ioctl = bad_file_ioctl,
.unlocked_ioctl = bad_file_unlocked_ioctl,
.compat_ioctl = bad_file_compat_ioctl,
.mmap = bad_file_mmap,
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index 773f2ce..72184f0 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -37,7 +37,7 @@ const struct inode_operations coda_ioctl_inode_operations =

const struct file_operations coda_ioctl_operations = {
.owner = THIS_MODULE,
- .ioctl = coda_pioctl,
+ .bkl_ioctl = coda_pioctl,
};

/* the coda pioctl inode ops */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index be4392c..70a98a8 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -344,7 +344,7 @@ static const struct file_operations coda_psdev_fops = {
.read = coda_psdev_read,
.write = coda_psdev_write,
.poll = coda_psdev_poll,
- .ioctl = coda_psdev_ioctl,
+ .bkl_ioctl = coda_psdev_ioctl,
.open = coda_psdev_open,
.release = coda_psdev_release,
};
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c32a1b6..3561d04 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1733,7 +1733,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
}

if (!filp->f_op ||
- (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
+ (!filp->f_op->bkl_ioctl && !filp->f_op->unlocked_ioctl))
goto do_ioctl;
break;
}
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index e7440a6..a5fa728 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -299,7 +299,7 @@ static int ecryptfs_ioctl(struct inode *inode, struct file *file,

const struct file_operations ecryptfs_dir_fops = {
.readdir = ecryptfs_readdir,
- .ioctl = ecryptfs_ioctl,
+ .bkl_ioctl = ecryptfs_ioctl,
.open = ecryptfs_open,
.flush = ecryptfs_flush,
.release = ecryptfs_release,
@@ -315,7 +315,7 @@ const struct file_operations ecryptfs_main_fops = {
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.readdir = ecryptfs_readdir,
- .ioctl = ecryptfs_ioctl,
+ .bkl_ioctl = ecryptfs_ioctl,
.mmap = generic_file_mmap,
.open = ecryptfs_open,
.flush = ecryptfs_flush,
@@ -334,8 +334,9 @@ ecryptfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,

if (ecryptfs_file_to_private(file))
lower_file = ecryptfs_file_to_lower(file);
- if (lower_file && lower_file->f_op && lower_file->f_op->ioctl)
- rc = lower_file->f_op->ioctl(ecryptfs_inode_to_lower(inode),
+ /* This is some seriously buggy crap. What about the non-BKL ioctl? */
+ if (lower_file && lower_file->f_op && lower_file->f_op->bkl_ioctl)
+ rc = lower_file->f_op->bkl_ioctl(ecryptfs_inode_to_lower(inode),
lower_file, cmd, arg);
else
rc = -ENOTTY;
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 530b4ca..f5473d4 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -836,7 +836,7 @@ const struct file_operations fat_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.readdir = fat_readdir,
- .ioctl = fat_dir_ioctl,
+ .bkl_ioctl = fat_dir_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = fat_compat_dir_ioctl,
#endif
diff --git a/fs/fat/file.c b/fs/fat/file.c
index e8c159d..1ddabe7 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -159,7 +159,7 @@ const struct file_operations fat_file_operations = {
.aio_write = generic_file_aio_write,
.mmap = generic_file_mmap,
.release = fat_file_release,
- .ioctl = fat_generic_ioctl,
+ .bkl_ioctl = fat_generic_ioctl,
.fsync = fat_file_fsync,
.splice_read = generic_file_splice_read,
};
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 5f40236..d30ab33 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -494,7 +494,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
const struct file_operations hfsplus_dir_operations = {
.read = generic_read_dir,
.readdir = hfsplus_readdir,
- .ioctl = hfsplus_ioctl,
+ .bkl_ioctl = hfsplus_ioctl,
.llseek = generic_file_llseek,
.release = hfsplus_dir_release,
};
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 1bcf597..c0a5c46 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -285,7 +285,7 @@ static const struct file_operations hfsplus_file_operations = {
.fsync = file_fsync,
.open = hfsplus_file_open,
.release = hfsplus_file_release,
- .ioctl = hfsplus_ioctl,
+ .bkl_ioctl = hfsplus_ioctl,
};

struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 7faefb4..921f727 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -47,9 +47,9 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
if (error == -ENOIOCTLCMD)
error = -EINVAL;
goto out;
- } else if (filp->f_op->ioctl) {
+ } else if (filp->f_op->bkl_ioctl) {
lock_kernel();
- error = filp->f_op->ioctl(filp->f_path.dentry->d_inode,
+ error = filp->f_op->bkl_ioctl(filp->f_path.dentry->d_inode,
filp, cmd, arg);
unlock_kernel();
}
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 2396a85..02e7719 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -821,7 +821,7 @@ const struct inode_operations logfs_dir_iops = {
};
const struct file_operations logfs_dir_fops = {
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .bkl_ioctl = logfs_ioctl,
.readdir = logfs_readdir,
.read = generic_read_dir,
};
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 370f367..4618614 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -243,7 +243,7 @@ const struct file_operations logfs_reg_fops = {
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .bkl_ioctl = logfs_ioctl,
.llseek = generic_file_llseek,
.mmap = generic_file_readonly_mmap,
.open = generic_file_open,
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 7edfcd4..ba898f9 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -51,7 +51,7 @@ const struct file_operations ncp_dir_operations =
{
.read = generic_read_dir,
.readdir = ncp_readdir,
- .ioctl = ncp_ioctl,
+ .bkl_ioctl = ncp_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ncp_compat_ioctl,
#endif
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 1daabb9..1138914 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -295,7 +295,7 @@ const struct file_operations ncp_file_operations =
.llseek = ncp_remote_llseek,
.read = ncp_file_read,
.write = ncp_file_write,
- .ioctl = ncp_ioctl,
+ .bkl_ioctl = ncp_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ncp_compat_ioctl,
#endif
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index fe44d3f..8cf00ab 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1570,7 +1570,7 @@ const struct file_operations ntfs_dir_ops = {
/*.aio_fsync = ,*/ /* Sync all outstanding async
i/o operations on a kiocb. */
#endif /* NTFS_RW */
- /*.ioctl = ,*/ /* Perform function on the
+ /*.bkl_ioctl = ,*/ /* Perform function on the
mounted filesystem. */
.open = ntfs_dir_open, /* Open directory. */
};
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 8804f09..50a7f6d 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -2221,7 +2221,7 @@ const struct file_operations ntfs_file_ops = {
i/o operations on a
kiocb. */
#endif /* NTFS_RW */
- /*.ioctl = ,*/ /* Perform function on the
+ /*.bkl_ioctl = ,*/ /* Perform function on the
mounted filesystem. */
.mmap = generic_file_mmap, /* Mmap file. */
.open = ntfs_file_open, /* Open file. */
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index d35b232..8e8f813 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -215,7 +215,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
long rv = -ENOTTY;
long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);
- int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long);
+ int (*bkl_ioctl)(struct inode *, struct file *, unsigned int, unsigned long);

spin_lock(&pde->pde_unload_lock);
if (!pde->proc_fops) {
@@ -224,16 +224,16 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
}
pde->pde_users++;
unlocked_ioctl = pde->proc_fops->unlocked_ioctl;
- ioctl = pde->proc_fops->ioctl;
+ bkl_ioctl = pde->proc_fops->bkl_ioctl;
spin_unlock(&pde->pde_unload_lock);

if (unlocked_ioctl) {
rv = unlocked_ioctl(file, cmd, arg);
if (rv == -ENOIOCTLCMD)
rv = -EINVAL;
- } else if (ioctl) {
+ } else if (bkl_ioctl) {
lock_kernel();
- rv = ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ rv = bkl_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
unlock_kernel();
}

diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 3e4803b..a2eac18 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -39,7 +39,7 @@ const struct file_operations smb_dir_operations =
{
.read = generic_read_dir,
.readdir = smb_readdir,
- .ioctl = smb_ioctl,
+ .bkl_ioctl = smb_ioctl,
.open = smb_dir_open,
};

diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index dbf6548..dbdb834 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -437,7 +437,7 @@ const struct file_operations smb_file_operations =
.aio_read = smb_file_aio_read,
.write = do_sync_write,
.aio_write = smb_file_aio_write,
- .ioctl = smb_ioctl,
+ .bkl_ioctl = smb_ioctl,
.mmap = smb_file_mmap,
.open = smb_file_open,
.release = smb_file_release,
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index f0f2a43..d4f8f0c 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -209,6 +209,6 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
const struct file_operations udf_dir_operations = {
.read = generic_read_dir,
.readdir = udf_readdir,
- .ioctl = udf_ioctl,
+ .bkl_ioctl = udf_ioctl,
.fsync = simple_fsync,
};
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 4b6a46c..443066b 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -207,7 +207,7 @@ static int udf_release_file(struct inode *inode, struct file *filp)
const struct file_operations udf_file_operations = {
.read = do_sync_read,
.aio_read = generic_file_aio_read,
- .ioctl = udf_ioctl,
+ .bkl_ioctl = udf_ioctl,
.open = dquot_file_open,
.mmap = generic_file_mmap,
.write = do_sync_write,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 44f35ae..1a82f78 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1491,7 +1491,7 @@ struct file_operations {
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
- int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+ int (*bkl_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 39bddba..278deab 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1359,7 +1359,7 @@ static const struct file_operations cache_file_operations_procfs = {
.read = cache_read_procfs,
.write = cache_write_procfs,
.poll = cache_poll_procfs,
- .ioctl = cache_ioctl_procfs, /* for FIONREAD */
+ .bkl_ioctl = cache_ioctl_procfs, /* for FIONREAD */
.open = cache_open_procfs,
.release = cache_release_procfs,
};
@@ -1553,7 +1553,7 @@ const struct file_operations cache_file_operations_pipefs = {
.read = cache_read_pipefs,
.write = cache_write_pipefs,
.poll = cache_poll_pipefs,
- .ioctl = cache_ioctl_pipefs, /* for FIONREAD */
+ .bkl_ioctl = cache_ioctl_pipefs, /* for FIONREAD */
.open = cache_open_pipefs,
.release = cache_release_pipefs,
};
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 20e30c6..b6dd719 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -337,7 +337,7 @@ static const struct file_operations rpc_pipe_fops = {
.read = rpc_pipe_read,
.write = rpc_pipe_write,
.poll = rpc_pipe_poll,
- .ioctl = rpc_pipe_ioctl,
+ .bkl_ioctl = rpc_pipe_ioctl,
.open = rpc_pipe_open,
.release = rpc_pipe_release,
};
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index 3f3c3f7..3c43220 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -366,7 +366,7 @@ static const struct file_operations mixer_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = mixer_ioctl,
+ .bkl_ioctl = mixer_ioctl,
.open = mixer_open,
.release = mixer_release,
};
@@ -1125,7 +1125,7 @@ static const struct file_operations sq_fops =
.llseek = no_llseek,
.write = sq_write,
.poll = sq_poll,
- .ioctl = sq_ioctl,
+ .bkl_ioctl = sq_ioctl,
.open = sq_open,
.release = sq_release,
};
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
index a1e3f96..0070ddc 100644
--- a/sound/oss/msnd_pinnacle.c
+++ b/sound/oss/msnd_pinnacle.c
@@ -1105,7 +1105,7 @@ static const struct file_operations dev_fileops = {
.owner = THIS_MODULE,
.read = dev_read,
.write = dev_write,
- .ioctl = dev_ioctl,
+ .bkl_ioctl = dev_ioctl,
.open = dev_open,
.release = dev_release,
};
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c
index 4153752..c21d1da 100644
--- a/sound/oss/sh_dac_audio.c
+++ b/sound/oss/sh_dac_audio.c
@@ -238,7 +238,7 @@ static int dac_audio_release(struct inode *inode, struct file *file)
const struct file_operations dac_audio_fops = {
.read = dac_audio_read,
.write = dac_audio_write,
- .ioctl = dac_audio_ioctl,
+ .bkl_ioctl = dac_audio_ioctl,
.open = dac_audio_open,
.release = dac_audio_release,
};
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index 3136c88..57006ae 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -1580,7 +1580,7 @@ static int cs4297a_ioctl_mixdev(struct inode *inode, struct file *file,
static const struct file_operations cs4297a_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = cs4297a_ioctl_mixdev,
+ .bkl_ioctl = cs4297a_ioctl_mixdev,
.open = cs4297a_open_mixdev,
.release = cs4297a_release_mixdev,
};
@@ -2496,7 +2496,7 @@ static const struct file_operations cs4297a_audio_fops = {
.read = cs4297a_read,
.write = cs4297a_write,
.poll = cs4297a_poll,
- .ioctl = cs4297a_ioctl,
+ .bkl_ioctl = cs4297a_ioctl,
.mmap = cs4297a_mmap,
.open = cs4297a_open,
.release = cs4297a_release,
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 20b3b32..300720c 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -3044,7 +3044,7 @@ static const struct file_operations vwsnd_audio_fops = {
.read = vwsnd_audio_read,
.write = vwsnd_audio_write,
.poll = vwsnd_audio_poll,
- .ioctl = vwsnd_audio_ioctl,
+ .bkl_ioctl = vwsnd_audio_ioctl,
.mmap = vwsnd_audio_mmap,
.open = vwsnd_audio_open,
.release = vwsnd_audio_release,
@@ -3231,7 +3231,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
static const struct file_operations vwsnd_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = vwsnd_mixer_ioctl,
+ .bkl_ioctl = vwsnd_mixer_ioctl,
.open = vwsnd_mixer_open,
.release = vwsnd_mixer_release,
};

2010-04-26 19:14:01

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Monday 26 April 2010 20:08:39 Linus Torvalds wrote:
> I wouldn't mind that. But we've not found people to do it so far, so...

I'll have another go at this tonight, see how far I get doing it
the simplest way for each file.

> NOTE! This has gone through a "allmodconfig" (with staging drivers), but
> only on x86-64. There are quite probably missing architecture conversions
> and/or drivers. But this should be the bulk of them.

Yes, looks good. I've compared it to a previous series of mine that
changed all the files in a different way. A number of those changes
have found their way into your tree by now, and there were only
two left that you didn't catch (see below), and one false positive
where I patched a struct v4l2_file_operations.

> It doesn't look that bad. Just about 100 files affected.

The v4l2_file_operations is actually another can of worms, I count
77 more files with a locked ioctl function in there. I'll put that on
the list of things to do before the BKL is gone.

Arnd

---
Subject: Missing bits from ->ioctl to ->bkl_ioctl conversion

Feel free to fold this into your patch.

Signed-off-by: Arnd Bergmann <[email protected]>

diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 3de2f32..4890683 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -722,7 +722,7 @@ struct file_operations {
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
- int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+ int (*bkl_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index c1070e3..7295781 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -835,11 +835,11 @@ au1550_ioctl_mixdev(struct inode *inode, struct file *file,
}

static /*const */ struct file_operations au1550_mixer_fops = {
- owner:THIS_MODULE,
- llseek:au1550_llseek,
- ioctl:au1550_ioctl_mixdev,
- open:au1550_open_mixdev,
- release:au1550_release_mixdev,
+ .owner = THIS_MODULE,
+ .llseek = au1550_llseek,
+ .bkl_ioctl = au1550_ioctl_mixdev,
+ .open = au1550_open_mixdev,
+ .release = au1550_release_mixdev,
};

static int

2010-04-26 20:38:32

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Mon, 26 Apr 2010, Arnd Bergmann wrote:
>
> Yes, looks good. I've compared it to a previous series of mine that
> changed all the files in a different way. A number of those changes
> have found their way into your tree by now, and there were only
> two left that you didn't catch (see below), and one false positive
> where I patched a struct v4l2_file_operations.

Yeah, those v4l2_file_operations were annoying. I didn't notice at first,
so my first automated script renamed all of them too (because I had just
grepped for 'file_operations', without the '-w', and so..).

> > It doesn't look that bad. Just about 100 files affected.
>
> The v4l2_file_operations is actually another can of worms, I count
> 77 more files with a locked ioctl function in there. I'll put that on
> the list of things to do before the BKL is gone.

Yes, but that - along with the sound drivers, that also have their own
ioctl interface that gets driven under the BKL - are independent patches.

Your patch did one of the au1550_ac97 'struct file_operations', but missed
another one. I had missed both, because they had that crazy old-style
initializer, and didn't trigger a compile on x86-64. But I fixed the other
one too.

So now the thing looks like the appended.

Linus
---
commit 6a0ac48e0ac12430a72189c06af02a16f4c4b3f2
Author: Linus Torvalds <[email protected]>
Date: Mon Apr 26 10:55:23 2010 -0700

Rename 'struct file_operations' 'ioctl' fn pointer to 'bkl_ioctl'

This makes it much easier to grep for the use of implicit BKL usage in
the traditional 'ioctl' function pointer.

The patch was mostly auto-generated with the following shell scripting:

# Create an approximate file list of ioctl initializers
git grep -w -20 file_operations |
grep '\.ioctl[ ]*=' |
sed 's/-[ ]*\.ioctl.*$//' |
sort -u > f

# Run a sed script to replace 'ioctl' with 'bkl_ioctl'
cat f | while read i; do
j="$i.sed"
sed 's/\.ioctl([ ]*)=/.bkl_ioctl\1=/' < $i > $j
mv $j $i
done

followed by some similarly trivial scripting to then mostly fix up
places that tried to align all the initializers with tabs or spaces.

Finally, some manual fixup, and testing of the end result with a
allmodconfig make (with 'staging' drivers explicitly enabled).

[ Two missing conversions added by Arnd Bergmann ]

Signed-off-by: Arnd Bergmann <[email protected]> [ vfs.txt and au1550_ac97.c ]
Signed-off-by: Linus Torvalds <[email protected]>
---
Documentation/filesystems/vfs.txt | 2 +-
arch/cris/arch-v10/drivers/ds1302.c | 2 +-
arch/cris/arch-v10/drivers/gpio.c | 2 +-
arch/cris/arch-v10/drivers/i2c.c | 2 +-
arch/cris/arch-v10/drivers/pcf8563.c | 2 +-
arch/cris/arch-v10/drivers/sync_serial.c | 2 +-
arch/cris/arch-v32/drivers/cryptocop.c | 2 +-
arch/cris/arch-v32/drivers/i2c.c | 2 +-
arch/cris/arch-v32/drivers/mach-a3/gpio.c | 2 +-
arch/cris/arch-v32/drivers/mach-fs/gpio.c | 2 +-
arch/cris/arch-v32/drivers/pcf8563.c | 2 +-
arch/cris/arch-v32/drivers/sync_serial.c | 2 +-
arch/ia64/kernel/perfmon.c | 2 +-
arch/ia64/sn/kernel/sn2/sn_hwperf.c | 2 +-
arch/m68k/bvme6000/rtc.c | 2 +-
arch/m68k/mvme16x/rtc.c | 2 +-
arch/um/drivers/harddog_kern.c | 2 +-
arch/um/drivers/hostaudio_kern.c | 4 +-
arch/um/drivers/mmapper_kern.c | 2 +-
drivers/block/pktcdvd.c | 2 +-
drivers/char/apm-emulation.c | 2 +-
drivers/char/applicom.c | 2 +-
drivers/char/ds1620.c | 2 +-
drivers/char/dtlk.c | 2 +-
drivers/char/generic_nvram.c | 2 +-
drivers/char/genrtc.c | 2 +-
drivers/char/hpet.c | 2 +-
drivers/char/i8k.c | 2 +-
drivers/char/ipmi/ipmi_devintf.c | 2 +-
drivers/char/ipmi/ipmi_watchdog.c | 2 +-
drivers/char/nvram.c | 2 +-
drivers/char/nwflash.c | 2 +-
drivers/char/raw.c | 4 +-
drivers/hwmon/fschmd.c | 2 +-
drivers/hwmon/w83793.c | 2 +-
drivers/input/misc/hp_sdc_rtc.c | 2 +-
drivers/isdn/capi/capi.c | 2 +-
drivers/isdn/divert/divert_procfs.c | 2 +-
drivers/isdn/i4l/isdn_common.c | 2 +-
drivers/isdn/mISDN/timerdev.c | 2 +-
drivers/macintosh/nvram.c | 2 +-
drivers/macintosh/via-pmu.c | 2 +-
drivers/media/dvb/dvb-core/dmxdev.c | 4 +-
drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 2 +-
drivers/media/dvb/dvb-core/dvb_frontend.c | 2 +-
drivers/media/dvb/dvb-core/dvb_net.c | 2 +-
drivers/media/dvb/firewire/firedtv-ci.c | 2 +-
drivers/media/dvb/ttpci/av7110.c | 2 +-
drivers/media/dvb/ttpci/av7110_av.c | 4 +-
drivers/media/dvb/ttpci/av7110_ca.c | 2 +-
drivers/media/video/v4l2-compat-ioctl32.c | 6 ++--
drivers/media/video/v4l2-dev.c | 2 +-
drivers/mtd/mtdchar.c | 2 +-
drivers/pcmcia/pcmcia_ioctl.c | 2 +-
drivers/rtc/rtc-m41t80.c | 2 +-
drivers/sbus/char/openprom.c | 2 +-
drivers/scsi/3w-9xxx.c | 2 +-
drivers/scsi/3w-sas.c | 2 +-
drivers/scsi/3w-xxxx.c | 2 +-
drivers/scsi/aacraid/linit.c | 2 +-
drivers/scsi/dpt_i2o.c | 2 +-
drivers/scsi/gdth.c | 2 +-
drivers/scsi/megaraid.c | 2 +-
drivers/scsi/megaraid/megaraid_mm.c | 2 +-
drivers/scsi/osst.c | 2 +-
drivers/scsi/sg.c | 2 +-
drivers/staging/crystalhd/crystalhd_lnx.c | 2 +-
drivers/staging/dt3155/dt3155_drv.c | 4 +-
drivers/staging/poch/poch.c | 2 +-
drivers/staging/vme/devices/vme_user.c | 2 +-
drivers/usb/mon/mon_bin.c | 2 +-
drivers/usb/mon/mon_stat.c | 2 +-
fs/autofs/root.c | 2 +-
fs/autofs4/root.c | 2 +-
fs/bad_inode.c | 2 +-
fs/coda/pioctl.c | 2 +-
fs/coda/psdev.c | 2 +-
fs/compat_ioctl.c | 2 +-
fs/ecryptfs/file.c | 9 ++++---
fs/fat/dir.c | 2 +-
fs/fat/file.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/ioctl.c | 4 +-
fs/logfs/dir.c | 2 +-
fs/logfs/file.c | 2 +-
fs/ncpfs/dir.c | 2 +-
fs/ncpfs/file.c | 2 +-
fs/ntfs/dir.c | 2 +-
fs/ntfs/file.c | 2 +-
fs/proc/inode.c | 8 +++---
fs/smbfs/dir.c | 2 +-
fs/smbfs/file.c | 2 +-
fs/udf/dir.c | 2 +-
fs/udf/file.c | 2 +-
include/linux/fs.h | 2 +-
net/sunrpc/cache.c | 4 +-
net/sunrpc/rpc_pipe.c | 2 +-
sound/oss/au1550_ac97.c | 28 +++++++++++++-------------
sound/oss/dmasound/dmasound_core.c | 4 +-
sound/oss/msnd_pinnacle.c | 2 +-
sound/oss/sh_dac_audio.c | 2 +-
sound/oss/swarm_cs4297a.c | 4 +-
sound/oss/vwsnd.c | 4 +-
104 files changed, 136 insertions(+), 135 deletions(-)

diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 3de2f32..4890683 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -722,7 +722,7 @@ struct file_operations {
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
- int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+ int (*bkl_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 77630df..a921861 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -376,7 +376,7 @@ print_rtc_status(void)

static const struct file_operations rtc_fops = {
.owner = THIS_MODULE,
- .ioctl = rtc_ioctl,
+ .bkl_ioctl = rtc_ioctl,
};

/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index 4b0f65f..54db6cb 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -715,7 +715,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
- .ioctl = gpio_ioctl,
+ .bkl_ioctl = gpio_ioctl,
.write = gpio_write,
.open = gpio_open,
.release = gpio_release,
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
index a8737a8..2e7eb8a 100644
--- a/arch/cris/arch-v10/drivers/i2c.c
+++ b/arch/cris/arch-v10/drivers/i2c.c
@@ -619,7 +619,7 @@ i2c_ioctl(struct inode *inode, struct file *file,

static const struct file_operations i2c_fops = {
.owner = THIS_MODULE,
- .ioctl = i2c_ioctl,
+ .bkl_ioctl = i2c_ioctl,
.open = i2c_open,
.release = i2c_release,
};
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index 1e90c1a..1a1f0f3 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -62,7 +62,7 @@ static int voltage_low;

static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE,
- .ioctl = pcf8563_ioctl,
+ .bkl_ioctl = pcf8563_ioctl,
};

unsigned char
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c
index 109dcd8..04e7339 100644
--- a/arch/cris/arch-v10/drivers/sync_serial.c
+++ b/arch/cris/arch-v10/drivers/sync_serial.c
@@ -248,7 +248,7 @@ static const struct file_operations sync_serial_fops = {
.write = sync_serial_write,
.read = sync_serial_read,
.poll = sync_serial_poll,
- .ioctl = sync_serial_ioctl,
+ .bkl_ioctl = sync_serial_ioctl,
.open = sync_serial_open,
.release = sync_serial_release
};
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index b70fb34..9022dae 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -282,7 +282,7 @@ const struct file_operations cryptocop_fops = {
.owner = THIS_MODULE,
.open = cryptocop_open,
.release = cryptocop_release,
- .ioctl = cryptocop_ioctl
+ .bkl_ioctl = cryptocop_ioctl
};


diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 5068263..6cfe2cf 100644
--- a/arch/cris/arch-v32/drivers/i2c.c
+++ b/arch/cris/arch-v32/drivers/i2c.c
@@ -689,7 +689,7 @@ i2c_ioctl(struct inode *inode, struct file *file,

static const struct file_operations i2c_fops = {
.owner = THIS_MODULE,
- .ioctl = i2c_ioctl,
+ .bkl_ioctl = i2c_ioctl,
.open = i2c_open,
.release = i2c_release,
};
diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
index 97357cf..0031713 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
@@ -879,7 +879,7 @@ static int gpio_pwm_ioctl(struct gpio_private *priv, unsigned int cmd,
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
- .ioctl = gpio_ioctl,
+ .bkl_ioctl = gpio_ioctl,
.write = gpio_write,
.open = gpio_open,
.release = gpio_release,
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
index d89ab80..72ffbfa 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
@@ -858,7 +858,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
- .ioctl = gpio_ioctl,
+ .bkl_ioctl = gpio_ioctl,
.write = gpio_write,
.open = gpio_open,
.release = gpio_release,
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index f447850..223081a 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -58,7 +58,7 @@ static int voltage_low;

static const struct file_operations pcf8563_fops = {
.owner = THIS_MODULE,
- .ioctl = pcf8563_ioctl
+ .bkl_ioctl = pcf8563_ioctl
};

unsigned char
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index 4889f19..8ce4f32 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -245,7 +245,7 @@ static const struct file_operations sync_serial_fops = {
.write = sync_serial_write,
.read = sync_serial_read,
.poll = sync_serial_poll,
- .ioctl = sync_serial_ioctl,
+ .bkl_ioctl = sync_serial_ioctl,
.open = sync_serial_open,
.release = sync_serial_release
};
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index ab985f7..0c4326c 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2178,7 +2178,7 @@ static const struct file_operations pfm_file_ops = {
.read = pfm_read,
.write = pfm_write,
.poll = pfm_poll,
- .ioctl = pfm_ioctl,
+ .bkl_ioctl = pfm_ioctl,
.open = pfm_no_open, /* special open code to disallow open via /proc */
.fasync = pfm_fasync,
.release = pfm_close,
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 55ac3c4..ffc65e1 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -864,7 +864,7 @@ error:
}

static const struct file_operations sn_hwperf_fops = {
- .ioctl = sn_hwperf_ioctl,
+ .bkl_ioctl = sn_hwperf_ioctl,
};

static struct miscdevice sn_hwperf_dev = {
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index b46ea17..fb939c6 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -163,7 +163,7 @@ static int rtc_release(struct inode *inode, struct file *file)
*/

static const struct file_operations rtc_fops = {
- .ioctl = rtc_ioctl,
+ .bkl_ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
};
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 8da9c25..9cebd9f 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -150,7 +150,7 @@ static int rtc_release(struct inode *inode, struct file *file)
*/

static const struct file_operations rtc_fops = {
- .ioctl = rtc_ioctl,
+ .bkl_ioctl = rtc_ioctl,
.open = rtc_open,
.release = rtc_release,
};
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index d332503..6cb24a1 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -151,7 +151,7 @@ static int harddog_ioctl(struct inode *inode, struct file *file,
static const struct file_operations harddog_fops = {
.owner = THIS_MODULE,
.write = harddog_write,
- .ioctl = harddog_ioctl,
+ .bkl_ioctl = harddog_ioctl,
.open = harddog_open,
.release = harddog_release,
};
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 368219c..cbc7366 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -289,7 +289,7 @@ static const struct file_operations hostaudio_fops = {
.read = hostaudio_read,
.write = hostaudio_write,
.poll = hostaudio_poll,
- .ioctl = hostaudio_ioctl,
+ .bkl_ioctl = hostaudio_ioctl,
.mmap = NULL,
.open = hostaudio_open,
.release = hostaudio_release,
@@ -298,7 +298,7 @@ static const struct file_operations hostaudio_fops = {
static const struct file_operations hostmixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = hostmixer_ioctl_mixdev,
+ .bkl_ioctl = hostmixer_ioctl_mixdev,
.open = hostmixer_open_mixdev,
.release = hostmixer_release,
};
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index d22f9e5..50f7976 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -90,7 +90,7 @@ static const struct file_operations mmapper_fops = {
.owner = THIS_MODULE,
.read = mmapper_read,
.write = mmapper_write,
- .ioctl = mmapper_ioctl,
+ .bkl_ioctl = mmapper_ioctl,
.mmap = mmapper_mmap,
.open = mmapper_open,
.release = mmapper_release,
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index ddf1942..d0bb5c7 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -3023,7 +3023,7 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm


static const struct file_operations pkt_ctl_fops = {
- .ioctl = pkt_ctl_ioctl,
+ .bkl_ioctl = pkt_ctl_ioctl,
.owner = THIS_MODULE,
};

diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 4f568cb..a7d3df3 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -397,7 +397,7 @@ static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = apm_read,
.poll = apm_poll,
- .ioctl = apm_ioctl,
+ .bkl_ioctl = apm_ioctl,
.open = apm_open,
.release = apm_release,
};
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a7424bf..8a845bd 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = {
.llseek = no_llseek,
.read = ac_read,
.write = ac_write,
- .ioctl = ac_ioctl,
+ .bkl_ioctl = ac_ioctl,
};

static struct miscdevice ac_miscdev = {
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index 61f0146..de8f7ba 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -344,7 +344,7 @@ static const struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
.open = ds1620_open,
.read = ds1620_read,
- .ioctl = ds1620_ioctl,
+ .bkl_ioctl = ds1620_ioctl,
};

static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 045c930..da15fb9 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops =
.read = dtlk_read,
.write = dtlk_write,
.poll = dtlk_poll,
- .ioctl = dtlk_ioctl,
+ .bkl_ioctl = dtlk_ioctl,
.open = dtlk_open,
.release = dtlk_release,
};
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index fda4181..0947ad9 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -121,7 +121,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .ioctl = nvram_ioctl,
+ .bkl_ioctl = nvram_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 31e7c91..414ca68 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -482,7 +482,7 @@ static const struct file_operations gen_rtc_fops = {
.read = gen_rtc_read,
.poll = gen_rtc_poll,
#endif
- .ioctl = gen_rtc_ioctl,
+ .bkl_ioctl = gen_rtc_ioctl,
.open = gen_rtc_open,
.release = gen_rtc_release,
};
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 9ded667..09c33d1 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -654,7 +654,7 @@ static const struct file_operations hpet_fops = {
.llseek = no_llseek,
.read = hpet_read,
.poll = hpet_poll,
- .ioctl = hpet_ioctl,
+ .bkl_ioctl = hpet_ioctl,
.open = hpet_open,
.release = hpet_release,
.fasync = hpet_fasync,
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index fc8cf7a..2a211d5 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -91,7 +91,7 @@ static const struct file_operations i8k_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
- .ioctl = i8k_ioctl,
+ .bkl_ioctl = i8k_ioctl,
};

struct smm_regs {
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 65545de..57b2990 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -826,7 +826,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,

static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
- .ioctl = ipmi_ioctl,
+ .bkl_ioctl = ipmi_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl,
#endif
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index a4d57e3..e8d478e 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -880,7 +880,7 @@ static const struct file_operations ipmi_wdog_fops = {
.read = ipmi_read,
.poll = ipmi_poll,
.write = ipmi_write,
- .ioctl = ipmi_ioctl,
+ .bkl_ioctl = ipmi_ioctl,
.open = ipmi_open,
.release = ipmi_close,
.fasync = ipmi_fasync,
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 47e8f7b..2688c4e 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -422,7 +422,7 @@ static const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = nvram_read,
.write = nvram_write,
- .ioctl = nvram_ioctl,
+ .bkl_ioctl = nvram_ioctl,
.open = nvram_open,
.release = nvram_release,
};
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index f808109..636b9f8 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -631,7 +631,7 @@ static const struct file_operations flash_fops =
.llseek = flash_llseek,
.read = flash_read,
.write = flash_write,
- .ioctl = flash_ioctl,
+ .bkl_ioctl = flash_ioctl,
};

static struct miscdevice flash_miscdev =
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 8756ab0..e0ece78 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -251,12 +251,12 @@ static const struct file_operations raw_fops = {
.fsync = blkdev_fsync,
.open = raw_open,
.release= raw_release,
- .ioctl = raw_ioctl,
+ .bkl_ioctl = raw_ioctl,
.owner = THIS_MODULE,
};

static const struct file_operations raw_ctl_fops = {
- .ioctl = raw_ctl_ioctl,
+ .bkl_ioctl = raw_ctl_ioctl,
.open = raw_open,
.owner = THIS_MODULE,
};
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index 0627f7a..fa60ff2 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -924,7 +924,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_release,
.write = watchdog_write,
- .ioctl = watchdog_ioctl,
+ .bkl_ioctl = watchdog_ioctl,
};


diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 612807d..6f63623 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1395,7 +1395,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_close,
.write = watchdog_write,
- .ioctl = watchdog_ioctl,
+ .bkl_ioctl = watchdog_ioctl,
};

/*
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ad730e1..0fdfd20 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -664,7 +664,7 @@ static const struct file_operations hp_sdc_rtc_fops = {
.llseek = no_llseek,
.read = hp_sdc_rtc_read,
.poll = hp_sdc_rtc_poll,
- .ioctl = hp_sdc_rtc_ioctl,
+ .bkl_ioctl = hp_sdc_rtc_ioctl,
.open = hp_sdc_rtc_open,
.fasync = hp_sdc_rtc_fasync,
};
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index ee58375..6bc9766 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1026,7 +1026,7 @@ static const struct file_operations capi_fops =
.read = capi_read,
.write = capi_write,
.poll = capi_poll,
- .ioctl = capi_ioctl,
+ .bkl_ioctl = capi_ioctl,
.open = capi_open,
.release = capi_release,
};
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 9f49d90..ae0244f 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -265,7 +265,7 @@ static const struct file_operations isdn_fops =
.read = isdn_divert_read,
.write = isdn_divert_write,
.poll = isdn_divert_poll,
- .ioctl = isdn_divert_ioctl,
+ .bkl_ioctl = isdn_divert_ioctl,
.open = isdn_divert_open,
.release = isdn_divert_close,
};
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 70044ee..08ba72d 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1838,7 +1838,7 @@ static const struct file_operations isdn_fops =
.read = isdn_read,
.write = isdn_write,
.poll = isdn_poll,
- .ioctl = isdn_ioctl,
+ .bkl_ioctl = isdn_ioctl,
.open = isdn_open,
.release = isdn_close,
};
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 8785004..fc7d777 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -263,7 +263,7 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
static const struct file_operations mISDN_fops = {
.read = mISDN_read,
.poll = mISDN_poll,
- .ioctl = mISDN_ioctl,
+ .bkl_ioctl = mISDN_ioctl,
.open = mISDN_open,
.release = mISDN_close,
};
diff --git a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c
index c876349..6a3115f 100644
--- a/drivers/macintosh/nvram.c
+++ b/drivers/macintosh/nvram.c
@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .ioctl = nvram_ioctl,
+ .bkl_ioctl = nvram_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 4276484..1cac03c 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2341,7 +2341,7 @@ static const struct file_operations pmu_device_fops = {
.read = pmu_read,
.write = pmu_write,
.poll = pmu_fpoll,
- .ioctl = pmu_ioctl,
+ .bkl_ioctl = pmu_ioctl,
.open = pmu_open,
.release = pmu_release,
};
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 9ddc579..a6c4f2f 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -1139,7 +1139,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_demux_fops = {
.owner = THIS_MODULE,
.read = dvb_demux_read,
- .ioctl = dvb_demux_ioctl,
+ .bkl_ioctl = dvb_demux_ioctl,
.open = dvb_demux_open,
.release = dvb_demux_release,
.poll = dvb_demux_poll,
@@ -1208,7 +1208,7 @@ static const struct file_operations dvb_dvr_fops = {
.owner = THIS_MODULE,
.read = dvb_dvr_read,
.write = dvb_dvr_write,
- .ioctl = dvb_dvr_ioctl,
+ .bkl_ioctl = dvb_dvr_ioctl,
.open = dvb_dvr_open,
.release = dvb_dvr_release,
.poll = dvb_dvr_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index cb22da5..4609c7e 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1611,7 +1611,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_en50221_io_read,
.write = dvb_ca_en50221_io_write,
- .ioctl = dvb_ca_en50221_io_ioctl,
+ .bkl_ioctl = dvb_ca_en50221_io_ioctl,
.open = dvb_ca_en50221_io_open,
.release = dvb_ca_en50221_io_release,
.poll = dvb_ca_en50221_io_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 55ea260..5ebf731 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -2022,7 +2022,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)

static const struct file_operations dvb_frontend_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.poll = dvb_frontend_poll,
.open = dvb_frontend_open,
.release = dvb_frontend_release
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 441c064..7ae8ef1 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1459,7 +1459,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)

static const struct file_operations dvb_net_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_net_ioctl,
+ .bkl_ioctl = dvb_net_ioctl,
.open = dvb_generic_open,
.release = dvb_net_close,
};
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index 853e04b..9378618 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -217,7 +217,7 @@ static unsigned int fdtv_ca_io_poll(struct file *file, poll_table *wait)

static const struct file_operations fdtv_ca_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
.poll = fdtv_ca_io_poll,
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 3891559..0e606af 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -727,7 +727,7 @@ static int dvb_osd_ioctl(struct inode *inode, struct file *file,

static const struct file_operations dvb_osd_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
};
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 5388481..62d3b1f 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1517,7 +1517,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_video_fops = {
.owner = THIS_MODULE,
.write = dvb_video_write,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_video_open,
.release = dvb_video_release,
.poll = dvb_video_poll,
@@ -1535,7 +1535,7 @@ static struct dvb_device dvbdev_video = {
static const struct file_operations dvb_audio_fops = {
.owner = THIS_MODULE,
.write = dvb_audio_write,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_audio_open,
.release = dvb_audio_release,
.poll = dvb_audio_poll,
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index ac7779c..94e0668 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -350,7 +350,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_read,
.write = dvb_ca_write,
- .ioctl = dvb_generic_ioctl,
+ .bkl_ioctl = dvb_generic_ioctl,
.open = dvb_ca_open,
.release = dvb_generic_release,
.poll = dvb_ca_poll,
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index f77f84b..befb4ea 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -228,9 +228,9 @@ static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

if (file->f_op->unlocked_ioctl)
ret = file->f_op->unlocked_ioctl(file, cmd, arg);
- else if (file->f_op->ioctl) {
+ else if (file->f_op->bkl_ioctl) {
lock_kernel();
- ret = file->f_op->ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ ret = file->f_op->bkl_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
unlock_kernel();
}

@@ -973,7 +973,7 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
{
long ret = -ENOIOCTLCMD;

- if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl)
+ if (!file->f_op->bkl_ioctl && !file->f_op->unlocked_ioctl)
return ret;

switch (cmd) {
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7090699..c48143a 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -330,7 +330,7 @@ static const struct file_operations v4l2_fops = {
.open = v4l2_open,
.get_unmapped_area = v4l2_get_unmapped_area,
.mmap = v4l2_mmap,
- .ioctl = v4l2_ioctl,
+ .bkl_ioctl = v4l2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l2_compat_ioctl32,
#endif
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 5b081cb..57b48c4 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -942,7 +942,7 @@ static const struct file_operations mtd_fops = {
.llseek = mtd_lseek,
.read = mtd_read,
.write = mtd_write,
- .ioctl = mtd_ioctl,
+ .bkl_ioctl = mtd_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mtd_compat_ioctl,
#endif
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 104e73d..ca84016 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -1037,7 +1037,7 @@ static const struct file_operations ds_fops = {
.owner = THIS_MODULE,
.open = ds_open,
.release = ds_release,
- .ioctl = ds_ioctl,
+ .bkl_ioctl = ds_ioctl,
.read = ds_read,
.write = ds_write,
.poll = ds_poll,
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 60fe266..e662d61 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -736,7 +736,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
static const struct file_operations wdt_fops = {
.owner = THIS_MODULE,
.read = wdt_read,
- .ioctl = wdt_ioctl,
+ .bkl_ioctl = wdt_ioctl,
.write = wdt_write,
.open = wdt_open,
.release = wdt_release,
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index fc2f676..1fdc1a9 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -709,7 +709,7 @@ static int openprom_release(struct inode * inode, struct file * file)
static const struct file_operations openprom_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = openprom_ioctl,
+ .bkl_ioctl = openprom_ioctl,
.compat_ioctl = openprom_compat_ioctl,
.open = openprom_open,
.release = openprom_release,
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index e9788f5..32da0ef 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -218,7 +218,7 @@ static struct device_attribute *twa_host_attrs[] = {
/* File operations struct for character device */
static const struct file_operations twa_fops = {
.owner = THIS_MODULE,
- .ioctl = twa_chrdev_ioctl,
+ .bkl_ioctl = twa_chrdev_ioctl,
.open = twa_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 54c5ffb..3cac9e4 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -884,7 +884,7 @@ out:
/* File operations struct for character device */
static const struct file_operations twl_fops = {
.owner = THIS_MODULE,
- .ioctl = twl_chrdev_ioctl,
+ .bkl_ioctl = twl_chrdev_ioctl,
.open = twl_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 5faf903..2713dd5 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1051,7 +1051,7 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
/* File operations struct for character device */
static const struct file_operations tw_fops = {
.owner = THIS_MODULE,
- .ioctl = tw_chrdev_ioctl,
+ .bkl_ioctl = tw_chrdev_ioctl,
.open = tw_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index e9373a2..c2b037d 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1029,7 +1029,7 @@ ssize_t aac_get_serial_number(struct device *device, char *buf)

static const struct file_operations aac_cfg_fops = {
.owner = THIS_MODULE,
- .ioctl = aac_cfg_ioctl,
+ .bkl_ioctl = aac_cfg_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = aac_compat_cfg_ioctl,
#endif
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 0435d04..6ec5682 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -119,7 +119,7 @@ static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long);
#endif

static const struct file_operations adpt_fops = {
- .ioctl = adpt_ioctl,
+ .bkl_ioctl = adpt_ioctl,
.open = adpt_open,
.release = adpt_close,
#ifdef CONFIG_COMPAT
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 35a4b30..69c1629 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -369,7 +369,7 @@ MODULE_LICENSE("GPL");

/* ioctl interface */
static const struct file_operations gdth_fops = {
- .ioctl = gdth_ioctl,
+ .bkl_ioctl = gdth_ioctl,
.open = gdth_open,
.release = gdth_close,
};
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 4bf7edc..49a3501 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -96,7 +96,7 @@ static struct mega_hbas mega_hbas[MAX_CONTROLLERS];
*/
static const struct file_operations megadev_fops = {
.owner = THIS_MODULE,
- .ioctl = megadev_ioctl,
+ .bkl_ioctl = megadev_ioctl,
.open = megadev_open,
};

diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 36e0b7d..9bd7787 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -70,7 +70,7 @@ static wait_queue_head_t wait_q;

static const struct file_operations lsi_fops = {
.open = mraid_mm_open,
- .ioctl = mraid_mm_ioctl,
+ .bkl_ioctl = mraid_mm_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mraid_mm_compat_ioctl,
#endif
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index b219118..a1a78bb 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5613,7 +5613,7 @@ static const struct file_operations osst_fops = {
.owner = THIS_MODULE,
.read = osst_read,
.write = osst_write,
- .ioctl = osst_ioctl,
+ .bkl_ioctl = osst_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = osst_compat_ioctl,
#endif
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index dee1c96..93d043e 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1322,7 +1322,7 @@ static const struct file_operations sg_fops = {
.read = sg_read,
.write = sg_write,
.poll = sg_poll,
- .ioctl = sg_ioctl,
+ .bkl_ioctl = sg_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = sg_compat_ioctl,
#endif
diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index 54bad65..3d6b773 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -345,7 +345,7 @@ static int chd_dec_close(struct inode *in, struct file *fd)

static const struct file_operations chd_dec_fops = {
.owner = THIS_MODULE,
- .ioctl = chd_dec_ioctl,
+ .bkl_ioctl = chd_dec_ioctl,
.open = chd_dec_open,
.release = chd_dec_close,
};
diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index e2c44ec..09fb197 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -843,9 +843,9 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
*****************************************************/
static struct file_operations dt3155_fops = {
read: dt3155_read,
- ioctl: dt3155_ioctl,
+ bkl_ioctl: dt3155_ioctl,
mmap: dt3155_mmap,
- poll: dt3155_poll,
+ poll: dt3155_poll,
open: dt3155_open,
release: dt3155_close
};
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index f940a34..edc8c58 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -1037,7 +1037,7 @@ static struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
- .ioctl = poch_ioctl,
+ .bkl_ioctl = poch_ioctl,
.poll = poch_poll,
.mmap = poch_mmap
};
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 1ab9a98..7ba7149 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = {
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
- .ioctl = vme_user_ioctl,
+ .bkl_ioctl = vme_user_ioctl,
};


diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index ddf7f9a..9ce7c74 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1239,7 +1239,7 @@ static const struct file_operations mon_fops_binary = {
.read = mon_bin_read,
/* .write = mon_text_write, */
.poll = mon_bin_poll,
- .ioctl = mon_bin_ioctl,
+ .bkl_ioctl = mon_bin_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mon_bin_compat_ioctl,
#endif
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 1becdc3..091e7fb 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -63,6 +63,6 @@ const struct file_operations mon_fops_stat = {
.read = mon_stat_read,
/* .write = mon_stat_write, */
/* .poll = mon_stat_poll, */
- /* .ioctl = mon_stat_ioctl, */
+ /* .bkl_ioctl = mon_stat_ioctl, */
.release = mon_stat_release,
};
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 8713c7c..b838f68 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -30,7 +30,7 @@ static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned
const struct file_operations autofs_root_operations = {
.read = generic_read_dir,
.readdir = autofs_root_readdir,
- .ioctl = autofs_root_ioctl,
+ .bkl_ioctl = autofs_root_ioctl,
};

const struct inode_operations autofs_root_inode_operations = {
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 109a6c6..e764eb1 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -38,7 +38,7 @@ const struct file_operations autofs4_root_operations = {
.read = generic_read_dir,
.readdir = dcache_readdir,
.llseek = dcache_dir_lseek,
- .ioctl = autofs4_root_ioctl,
+ .bkl_ioctl = autofs4_root_ioctl,
};

const struct file_operations autofs4_dir_operations = {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index a05287a..3fd4ada 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -160,7 +160,7 @@ static const struct file_operations bad_file_ops =
.aio_write = bad_file_aio_write,
.readdir = bad_file_readdir,
.poll = bad_file_poll,
- .ioctl = bad_file_ioctl,
+ .bkl_ioctl = bad_file_ioctl,
.unlocked_ioctl = bad_file_unlocked_ioctl,
.compat_ioctl = bad_file_compat_ioctl,
.mmap = bad_file_mmap,
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index 773f2ce..72184f0 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -37,7 +37,7 @@ const struct inode_operations coda_ioctl_inode_operations =

const struct file_operations coda_ioctl_operations = {
.owner = THIS_MODULE,
- .ioctl = coda_pioctl,
+ .bkl_ioctl = coda_pioctl,
};

/* the coda pioctl inode ops */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index be4392c..70a98a8 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -344,7 +344,7 @@ static const struct file_operations coda_psdev_fops = {
.read = coda_psdev_read,
.write = coda_psdev_write,
.poll = coda_psdev_poll,
- .ioctl = coda_psdev_ioctl,
+ .bkl_ioctl = coda_psdev_ioctl,
.open = coda_psdev_open,
.release = coda_psdev_release,
};
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c32a1b6..3561d04 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1733,7 +1733,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
}

if (!filp->f_op ||
- (!filp->f_op->ioctl && !filp->f_op->unlocked_ioctl))
+ (!filp->f_op->bkl_ioctl && !filp->f_op->unlocked_ioctl))
goto do_ioctl;
break;
}
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index e7440a6..a5fa728 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -299,7 +299,7 @@ static int ecryptfs_ioctl(struct inode *inode, struct file *file,

const struct file_operations ecryptfs_dir_fops = {
.readdir = ecryptfs_readdir,
- .ioctl = ecryptfs_ioctl,
+ .bkl_ioctl = ecryptfs_ioctl,
.open = ecryptfs_open,
.flush = ecryptfs_flush,
.release = ecryptfs_release,
@@ -315,7 +315,7 @@ const struct file_operations ecryptfs_main_fops = {
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.readdir = ecryptfs_readdir,
- .ioctl = ecryptfs_ioctl,
+ .bkl_ioctl = ecryptfs_ioctl,
.mmap = generic_file_mmap,
.open = ecryptfs_open,
.flush = ecryptfs_flush,
@@ -334,8 +334,9 @@ ecryptfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,

if (ecryptfs_file_to_private(file))
lower_file = ecryptfs_file_to_lower(file);
- if (lower_file && lower_file->f_op && lower_file->f_op->ioctl)
- rc = lower_file->f_op->ioctl(ecryptfs_inode_to_lower(inode),
+ /* This is some seriously buggy crap. What about the non-BKL ioctl? */
+ if (lower_file && lower_file->f_op && lower_file->f_op->bkl_ioctl)
+ rc = lower_file->f_op->bkl_ioctl(ecryptfs_inode_to_lower(inode),
lower_file, cmd, arg);
else
rc = -ENOTTY;
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 530b4ca..f5473d4 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -836,7 +836,7 @@ const struct file_operations fat_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.readdir = fat_readdir,
- .ioctl = fat_dir_ioctl,
+ .bkl_ioctl = fat_dir_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = fat_compat_dir_ioctl,
#endif
diff --git a/fs/fat/file.c b/fs/fat/file.c
index e8c159d..1ddabe7 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -159,7 +159,7 @@ const struct file_operations fat_file_operations = {
.aio_write = generic_file_aio_write,
.mmap = generic_file_mmap,
.release = fat_file_release,
- .ioctl = fat_generic_ioctl,
+ .bkl_ioctl = fat_generic_ioctl,
.fsync = fat_file_fsync,
.splice_read = generic_file_splice_read,
};
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 5f40236..d30ab33 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -494,7 +494,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
const struct file_operations hfsplus_dir_operations = {
.read = generic_read_dir,
.readdir = hfsplus_readdir,
- .ioctl = hfsplus_ioctl,
+ .bkl_ioctl = hfsplus_ioctl,
.llseek = generic_file_llseek,
.release = hfsplus_dir_release,
};
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 1bcf597..c0a5c46 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -285,7 +285,7 @@ static const struct file_operations hfsplus_file_operations = {
.fsync = file_fsync,
.open = hfsplus_file_open,
.release = hfsplus_file_release,
- .ioctl = hfsplus_ioctl,
+ .bkl_ioctl = hfsplus_ioctl,
};

struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 7faefb4..921f727 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -47,9 +47,9 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
if (error == -ENOIOCTLCMD)
error = -EINVAL;
goto out;
- } else if (filp->f_op->ioctl) {
+ } else if (filp->f_op->bkl_ioctl) {
lock_kernel();
- error = filp->f_op->ioctl(filp->f_path.dentry->d_inode,
+ error = filp->f_op->bkl_ioctl(filp->f_path.dentry->d_inode,
filp, cmd, arg);
unlock_kernel();
}
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 2396a85..02e7719 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -821,7 +821,7 @@ const struct inode_operations logfs_dir_iops = {
};
const struct file_operations logfs_dir_fops = {
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .bkl_ioctl = logfs_ioctl,
.readdir = logfs_readdir,
.read = generic_read_dir,
};
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 370f367..4618614 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -243,7 +243,7 @@ const struct file_operations logfs_reg_fops = {
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
.fsync = logfs_fsync,
- .ioctl = logfs_ioctl,
+ .bkl_ioctl = logfs_ioctl,
.llseek = generic_file_llseek,
.mmap = generic_file_readonly_mmap,
.open = generic_file_open,
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 7edfcd4..ba898f9 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -51,7 +51,7 @@ const struct file_operations ncp_dir_operations =
{
.read = generic_read_dir,
.readdir = ncp_readdir,
- .ioctl = ncp_ioctl,
+ .bkl_ioctl = ncp_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ncp_compat_ioctl,
#endif
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 1daabb9..1138914 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -295,7 +295,7 @@ const struct file_operations ncp_file_operations =
.llseek = ncp_remote_llseek,
.read = ncp_file_read,
.write = ncp_file_write,
- .ioctl = ncp_ioctl,
+ .bkl_ioctl = ncp_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ncp_compat_ioctl,
#endif
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index fe44d3f..8cf00ab 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1570,7 +1570,7 @@ const struct file_operations ntfs_dir_ops = {
/*.aio_fsync = ,*/ /* Sync all outstanding async
i/o operations on a kiocb. */
#endif /* NTFS_RW */
- /*.ioctl = ,*/ /* Perform function on the
+ /*.bkl_ioctl = ,*/ /* Perform function on the
mounted filesystem. */
.open = ntfs_dir_open, /* Open directory. */
};
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 8804f09..50a7f6d 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -2221,7 +2221,7 @@ const struct file_operations ntfs_file_ops = {
i/o operations on a
kiocb. */
#endif /* NTFS_RW */
- /*.ioctl = ,*/ /* Perform function on the
+ /*.bkl_ioctl = ,*/ /* Perform function on the
mounted filesystem. */
.mmap = generic_file_mmap, /* Mmap file. */
.open = ntfs_file_open, /* Open file. */
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index d35b232..8e8f813 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -215,7 +215,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
long rv = -ENOTTY;
long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);
- int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long);
+ int (*bkl_ioctl)(struct inode *, struct file *, unsigned int, unsigned long);

spin_lock(&pde->pde_unload_lock);
if (!pde->proc_fops) {
@@ -224,16 +224,16 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
}
pde->pde_users++;
unlocked_ioctl = pde->proc_fops->unlocked_ioctl;
- ioctl = pde->proc_fops->ioctl;
+ bkl_ioctl = pde->proc_fops->bkl_ioctl;
spin_unlock(&pde->pde_unload_lock);

if (unlocked_ioctl) {
rv = unlocked_ioctl(file, cmd, arg);
if (rv == -ENOIOCTLCMD)
rv = -EINVAL;
- } else if (ioctl) {
+ } else if (bkl_ioctl) {
lock_kernel();
- rv = ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ rv = bkl_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
unlock_kernel();
}

diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 3e4803b..a2eac18 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -39,7 +39,7 @@ const struct file_operations smb_dir_operations =
{
.read = generic_read_dir,
.readdir = smb_readdir,
- .ioctl = smb_ioctl,
+ .bkl_ioctl = smb_ioctl,
.open = smb_dir_open,
};

diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index dbf6548..dbdb834 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -437,7 +437,7 @@ const struct file_operations smb_file_operations =
.aio_read = smb_file_aio_read,
.write = do_sync_write,
.aio_write = smb_file_aio_write,
- .ioctl = smb_ioctl,
+ .bkl_ioctl = smb_ioctl,
.mmap = smb_file_mmap,
.open = smb_file_open,
.release = smb_file_release,
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index f0f2a43..d4f8f0c 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -209,6 +209,6 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
const struct file_operations udf_dir_operations = {
.read = generic_read_dir,
.readdir = udf_readdir,
- .ioctl = udf_ioctl,
+ .bkl_ioctl = udf_ioctl,
.fsync = simple_fsync,
};
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 4b6a46c..443066b 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -207,7 +207,7 @@ static int udf_release_file(struct inode *inode, struct file *filp)
const struct file_operations udf_file_operations = {
.read = do_sync_read,
.aio_read = generic_file_aio_read,
- .ioctl = udf_ioctl,
+ .bkl_ioctl = udf_ioctl,
.open = dquot_file_open,
.mmap = generic_file_mmap,
.write = do_sync_write,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 44f35ae..1a82f78 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1491,7 +1491,7 @@ struct file_operations {
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
- int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+ int (*bkl_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 39bddba..278deab 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1359,7 +1359,7 @@ static const struct file_operations cache_file_operations_procfs = {
.read = cache_read_procfs,
.write = cache_write_procfs,
.poll = cache_poll_procfs,
- .ioctl = cache_ioctl_procfs, /* for FIONREAD */
+ .bkl_ioctl = cache_ioctl_procfs, /* for FIONREAD */
.open = cache_open_procfs,
.release = cache_release_procfs,
};
@@ -1553,7 +1553,7 @@ const struct file_operations cache_file_operations_pipefs = {
.read = cache_read_pipefs,
.write = cache_write_pipefs,
.poll = cache_poll_pipefs,
- .ioctl = cache_ioctl_pipefs, /* for FIONREAD */
+ .bkl_ioctl = cache_ioctl_pipefs, /* for FIONREAD */
.open = cache_open_pipefs,
.release = cache_release_pipefs,
};
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 20e30c6..b6dd719 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -337,7 +337,7 @@ static const struct file_operations rpc_pipe_fops = {
.read = rpc_pipe_read,
.write = rpc_pipe_write,
.poll = rpc_pipe_poll,
- .ioctl = rpc_pipe_ioctl,
+ .bkl_ioctl = rpc_pipe_ioctl,
.open = rpc_pipe_open,
.release = rpc_pipe_release,
};
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index c1070e3..2280ef7 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -835,11 +835,11 @@ au1550_ioctl_mixdev(struct inode *inode, struct file *file,
}

static /*const */ struct file_operations au1550_mixer_fops = {
- owner:THIS_MODULE,
- llseek:au1550_llseek,
- ioctl:au1550_ioctl_mixdev,
- open:au1550_open_mixdev,
- release:au1550_release_mixdev,
+ .owner = THIS_MODULE,
+ .llseek = au1550_llseek,
+ .bkl_ioctl = au1550_ioctl_mixdev,
+ .open = au1550_open_mixdev,
+ .release = au1550_release_mixdev,
};

static int
@@ -1885,15 +1885,15 @@ au1550_release(struct inode *inode, struct file *file)
}

static /*const */ struct file_operations au1550_audio_fops = {
- owner: THIS_MODULE,
- llseek: au1550_llseek,
- read: au1550_read,
- write: au1550_write,
- poll: au1550_poll,
- ioctl: au1550_ioctl,
- mmap: au1550_mmap,
- open: au1550_open,
- release: au1550_release,
+ .owner = THIS_MODULE,
+ .llseek = au1550_llseek,
+ .read = au1550_read,
+ .write = au1550_write,
+ .poll = au1550_poll,
+ .bkl_ioctl = au1550_ioctl,
+ .mmap = au1550_mmap,
+ .open = au1550_open,
+ .release = au1550_release,
};

MODULE_AUTHOR("Advanced Micro Devices (AMD), [email protected]");
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index 3f3c3f7..3c43220 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -366,7 +366,7 @@ static const struct file_operations mixer_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = mixer_ioctl,
+ .bkl_ioctl = mixer_ioctl,
.open = mixer_open,
.release = mixer_release,
};
@@ -1125,7 +1125,7 @@ static const struct file_operations sq_fops =
.llseek = no_llseek,
.write = sq_write,
.poll = sq_poll,
- .ioctl = sq_ioctl,
+ .bkl_ioctl = sq_ioctl,
.open = sq_open,
.release = sq_release,
};
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
index a1e3f96..0070ddc 100644
--- a/sound/oss/msnd_pinnacle.c
+++ b/sound/oss/msnd_pinnacle.c
@@ -1105,7 +1105,7 @@ static const struct file_operations dev_fileops = {
.owner = THIS_MODULE,
.read = dev_read,
.write = dev_write,
- .ioctl = dev_ioctl,
+ .bkl_ioctl = dev_ioctl,
.open = dev_open,
.release = dev_release,
};
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c
index 4153752..c21d1da 100644
--- a/sound/oss/sh_dac_audio.c
+++ b/sound/oss/sh_dac_audio.c
@@ -238,7 +238,7 @@ static int dac_audio_release(struct inode *inode, struct file *file)
const struct file_operations dac_audio_fops = {
.read = dac_audio_read,
.write = dac_audio_write,
- .ioctl = dac_audio_ioctl,
+ .bkl_ioctl = dac_audio_ioctl,
.open = dac_audio_open,
.release = dac_audio_release,
};
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index 3136c88..57006ae 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -1580,7 +1580,7 @@ static int cs4297a_ioctl_mixdev(struct inode *inode, struct file *file,
static const struct file_operations cs4297a_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = cs4297a_ioctl_mixdev,
+ .bkl_ioctl = cs4297a_ioctl_mixdev,
.open = cs4297a_open_mixdev,
.release = cs4297a_release_mixdev,
};
@@ -2496,7 +2496,7 @@ static const struct file_operations cs4297a_audio_fops = {
.read = cs4297a_read,
.write = cs4297a_write,
.poll = cs4297a_poll,
- .ioctl = cs4297a_ioctl,
+ .bkl_ioctl = cs4297a_ioctl,
.mmap = cs4297a_mmap,
.open = cs4297a_open,
.release = cs4297a_release,
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 20b3b32..300720c 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -3044,7 +3044,7 @@ static const struct file_operations vwsnd_audio_fops = {
.read = vwsnd_audio_read,
.write = vwsnd_audio_write,
.poll = vwsnd_audio_poll,
- .ioctl = vwsnd_audio_ioctl,
+ .bkl_ioctl = vwsnd_audio_ioctl,
.mmap = vwsnd_audio_mmap,
.open = vwsnd_audio_open,
.release = vwsnd_audio_release,
@@ -3231,7 +3231,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
static const struct file_operations vwsnd_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = vwsnd_mixer_ioctl,
+ .bkl_ioctl = vwsnd_mixer_ioctl,
.open = vwsnd_mixer_open,
.release = vwsnd_mixer_release,
};

2010-04-26 20:42:04

by David Miller

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

From: Linus Torvalds <[email protected]>
Date: Mon, 26 Apr 2010 11:08:39 -0700 (PDT)

> NOTE! This has gone through a "allmodconfig" (with staging drivers), but
> only on x86-64. There are quite probably missing architecture conversions
> and/or drivers. But this should be the bulk of them.

"allmodconfig" on sparc64 passes with this patch too, just FYI...

2010-04-26 22:09:47

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Mon, Apr 26, 2010 at 01:42:07PM -0700, David Miller wrote:
> From: Linus Torvalds <[email protected]>
> Date: Mon, 26 Apr 2010 11:08:39 -0700 (PDT)
>
> > NOTE! This has gone through a "allmodconfig" (with staging drivers), but
> > only on x86-64. There are quite probably missing architecture conversions
> > and/or drivers. But this should be the bulk of them.
>
> "allmodconfig" on sparc64 passes with this patch too, just FYI...


Thanks!

I've queued it for the next merge window in

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
bkl/ioctl

2010-04-26 22:24:29

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 4/6] staging: push down BKL into ioctl functions

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++++++----
drivers/staging/dt3155/dt3155_drv.c | 24 ++++++++++++++++++------
drivers/staging/poch/poch.c | 17 +++++++++++++++--
drivers/staging/vme/devices/vme_user.c | 18 +++++++++++++++---
4 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index 54bad65..3291e14 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -16,6 +16,7 @@
***************************************************************************/

#include <linux/version.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>

#include "crystalhd_lnx.h"
@@ -261,12 +262,12 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua,
}

/* API interfaces */
-static int chd_dec_ioctl(struct inode *in, struct file *fd,
- unsigned int cmd, unsigned long ua)
+static long chd_dec_ioctl(struct file *fd, unsigned int cmd, unsigned long ua)
{
struct crystalhd_adp *adp = chd_get_adp();
crystalhd_cmd_proc cproc;
struct crystalhd_user *uc;
+ int ret;

if (!adp || !fd) {
BCMLOG_ERR("Invalid adp\n");
@@ -279,13 +280,17 @@ static int chd_dec_ioctl(struct inode *in, struct file *fd,
return -ENODATA;
}

+ lock_kernel();
cproc = crystalhd_get_cmd_proc(&adp->cmds, cmd, uc);
if (!cproc) {
BCMLOG_ERR("Unhandled command: %d\n", cmd);
+ unlock_kernel();
return -EINVAL;
}

- return chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc);
+ ret = chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc);
+ unlock_kernel();
+ return ret;
}

static int chd_dec_open(struct inode *in, struct file *fd)
@@ -345,7 +350,7 @@ static int chd_dec_close(struct inode *in, struct file *fd)

static const struct file_operations chd_dec_fops = {
.owner = THIS_MODULE,
- .ioctl = chd_dec_ioctl,
+ .unlocked_ioctl = chd_dec_ioctl,
.open = chd_dec_open,
.release = chd_dec_close,
};
diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index e2c44ec..7e6095f 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -63,6 +63,7 @@ extern void printques(int);
#include <linux/types.h>
#include <linux/poll.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>

#include <asm/io.h>
#include <asm/uaccess.h>
@@ -835,6 +836,17 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
return 0;
}

+static long
+dt3155_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = dt3155_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}

/*****************************************************
* file operations supported by DT3155 driver
@@ -842,12 +854,12 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
* register_chrdev
*****************************************************/
static struct file_operations dt3155_fops = {
- read: dt3155_read,
- ioctl: dt3155_ioctl,
- mmap: dt3155_mmap,
- poll: dt3155_poll,
- open: dt3155_open,
- release: dt3155_close
+ .read = dt3155_read,
+ .unlocked_ioctl = dt3155_unlocked_ioctl,
+ .mmap = dt3155_mmap,
+ .poll = dt3155_poll,
+ .open = dt3155_open,
+ .release = dt3155_close
};


diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index f940a34..bf46e29 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -16,6 +16,7 @@
#include <linux/sysfs.h>
#include <linux/poll.h>
#include <linux/idr.h>
+#include <linux/smp_lock.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/ioctl.h>
@@ -911,7 +912,7 @@ static unsigned int poch_poll(struct file *filp, poll_table *pt)
return ret;
}

-static int poch_ioctl(struct inode *inode, struct file *filp,
+static int poch_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct channel_info *channel = filp->private_data;
@@ -1033,11 +1034,23 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
return 0;
}

+static long
+poch_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = poch_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static struct file_operations poch_fops = {
.owner = THIS_MODULE,
.open = poch_open,
.release = poch_release,
- .ioctl = poch_ioctl,
+ .poch_ioctl = poch_unlocked_ioctl,
.poll = poch_poll,
.mmap = poch_mmap
};
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 1ab9a98..bc16fc0 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/syscalls.h>
+#include <linux/smp_lock.h>
#include <linux/types.h>

#include <asm/io.h>
@@ -130,8 +131,7 @@ static int vme_user_release(struct inode *, struct file *);
static ssize_t vme_user_read(struct file *, char *, size_t, loff_t *);
static ssize_t vme_user_write(struct file *, const char *, size_t, loff_t *);
static loff_t vme_user_llseek(struct file *, loff_t, int);
-static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
+static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long);

static int __init vme_user_probe(struct device *, int, int);
static int __exit vme_user_remove(struct device *, int, int);
@@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = {
.read = vme_user_read,
.write = vme_user_write,
.llseek = vme_user_llseek,
- .ioctl = vme_user_ioctl,
+ .unlocked_ioctl = vme_user_unlocked_ioctl,
};


@@ -555,6 +555,18 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
}

+static long
+vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = vme_user_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+

/*
* Unallocate a previously allocated buffer
--
1.7.0.4

2010-04-26 22:24:45

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 2/6] scsi: push down BKL into ioctl functions

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/scsi/3w-9xxx.c | 10 +++++++---
drivers/scsi/3w-sas.c | 7 +++++--
drivers/scsi/3w-xxxx.c | 10 +++++++---
drivers/scsi/aacraid/linit.c | 11 ++++++++---
drivers/scsi/dpt_i2o.c | 20 +++++++++++++++++---
drivers/scsi/gdth.c | 20 +++++++++++++++-----
drivers/scsi/megaraid.c | 20 +++++++++++++++++---
drivers/scsi/megaraid/megaraid_mm.c | 22 +++++++++++++++++-----
drivers/scsi/osst.c | 14 ++++++++++----
drivers/scsi/sg.c | 17 ++++++++++++++---
10 files changed, 117 insertions(+), 34 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index e9788f5..4f74850 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -123,7 +123,7 @@ static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_H
static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
static char *twa_aen_severity_lookup(unsigned char severity_code);
static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id);
-static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
+static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
static int twa_chrdev_open(struct inode *inode, struct file *file);
static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host);
static void twa_free_request_id(TW_Device_Extension *tw_dev,int request_id);
@@ -218,7 +218,7 @@ static struct device_attribute *twa_host_attrs[] = {
/* File operations struct for character device */
static const struct file_operations twa_fops = {
.owner = THIS_MODULE,
- .ioctl = twa_chrdev_ioctl,
+ .unlocked_ioctl = twa_chrdev_ioctl,
.open = twa_chrdev_open,
.release = NULL
};
@@ -635,8 +635,9 @@ out:
} /* End twa_check_srl() */

/* This function handles ioctl for the character device */
-static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
+ struct inode *inode = file->f_path.dentry->d_inode;
long timeout;
unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
dma_addr_t dma_handle;
@@ -655,6 +656,8 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
int retval = TW_IOCTL_ERROR_OS_EFAULT;
void __user *argp = (void __user *)arg;

+ lock_kernel();
+
/* Only let one of these through at a time */
if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
retval = TW_IOCTL_ERROR_OS_EINTR;
@@ -874,6 +877,7 @@ out3:
out2:
mutex_unlock(&tw_dev->ioctl_lock);
out:
+ unlock_kernel();
return retval;
} /* End twa_chrdev_ioctl() */

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 54c5ffb..ab4ad09 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -750,7 +750,7 @@ static void twl_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_comm

/* This function handles ioctl for the character device
This interface is used by smartmontools open source software */
-static int twl_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
long timeout;
unsigned long *cpu_addr, data_buffer_length_adjusted = 0, flags = 0;
@@ -763,6 +763,8 @@ static int twl_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
int retval = -EFAULT;
void __user *argp = (void __user *)arg;

+ lock_kernel();
+
/* Only let one of these through at a time */
if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
retval = -EINTR;
@@ -858,6 +860,7 @@ out3:
out2:
mutex_unlock(&tw_dev->ioctl_lock);
out:
+ unlock_kernel();
return retval;
} /* End twl_chrdev_ioctl() */

@@ -884,7 +887,7 @@ out:
/* File operations struct for character device */
static const struct file_operations twl_fops = {
.owner = THIS_MODULE,
- .ioctl = twl_chrdev_ioctl,
+ .unlocked_ioctl = twl_chrdev_ioctl,
.open = twl_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 5faf903..45a737c 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -880,7 +880,7 @@ static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which)
} /* End tw_allocate_memory() */

/* This function handles ioctl for the character device */
-static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int request_id;
dma_addr_t dma_handle;
@@ -898,9 +898,12 @@ static int tw_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int

dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");

+ lock_kernel();
/* Only let one of these through at a time */
- if (mutex_lock_interruptible(&tw_dev->ioctl_lock))
+ if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
+ unlock_kernel();
return -EINTR;
+ }

/* First copy down the buffer length */
if (copy_from_user(&data_buffer_length, argp, sizeof(unsigned int)))
@@ -1029,6 +1032,7 @@ out2:
dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
out:
mutex_unlock(&tw_dev->ioctl_lock);
+ unlock_kernel();
return retval;
} /* End tw_chrdev_ioctl() */

@@ -1051,7 +1055,7 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
/* File operations struct for character device */
static const struct file_operations tw_fops = {
.owner = THIS_MODULE,
- .ioctl = tw_chrdev_ioctl,
+ .unlocked_ioctl = tw_chrdev_ioctl,
.open = tw_chrdev_open,
.release = NULL
};
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index e9373a2..33898b6 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -705,12 +705,17 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
* Bugs: Needs to handle hot plugging
*/

-static int aac_cfg_ioctl(struct inode *inode, struct file *file,
+static long aac_cfg_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
+ int ret;
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
- return aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
+ lock_kernel();
+ ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
+ unlock_kernel();
+
+ return ret;
}

#ifdef CONFIG_COMPAT
@@ -1029,7 +1034,7 @@ ssize_t aac_get_serial_number(struct device *device, char *buf)

static const struct file_operations aac_cfg_fops = {
.owner = THIS_MODULE,
- .ioctl = aac_cfg_ioctl,
+ .unlocked_ioctl = aac_cfg_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = aac_compat_cfg_ioctl,
#endif
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 0435d04..b0c576f 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -114,12 +114,13 @@ static int hba_count = 0;

static struct class *adpt_sysfs_class;

+static long adpt_unlocked_ioctl(struct file *, unsigned int, unsigned long);
#ifdef CONFIG_COMPAT
static long compat_adpt_ioctl(struct file *, unsigned int, unsigned long);
#endif

static const struct file_operations adpt_fops = {
- .ioctl = adpt_ioctl,
+ .unlocked_ioctl = adpt_unlocked_ioctl,
.open = adpt_open,
.release = adpt_close,
#ifdef CONFIG_COMPAT
@@ -2069,8 +2070,7 @@ static int adpt_system_info(void __user *buffer)
return 0;
}

-static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
- ulong arg)
+static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
{
int minor;
int error = 0;
@@ -2153,6 +2153,20 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
return error;
}

+static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg)
+{
+ struct inode *inode;
+ long ret;
+
+ inode = file->f_dentry->d_inode;
+
+ lock_kernel();
+ ret = adpt_ioctl(inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef CONFIG_COMPAT
static long compat_adpt_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 35a4b30..d3f335d 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -180,8 +180,8 @@ static const char *gdth_ctr_name(gdth_ha_str *ha);

static int gdth_open(struct inode *inode, struct file *filep);
static int gdth_close(struct inode *inode, struct file *filep);
-static int gdth_ioctl(struct inode *inode, struct file *filep,
- unsigned int cmd, unsigned long arg);
+static long gdth_unlocked_ioctl(struct file *filep, unsigned int cmd,
+ unsigned long arg);

static void gdth_flush(gdth_ha_str *ha);
static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *));
@@ -369,7 +369,7 @@ MODULE_LICENSE("GPL");

/* ioctl interface */
static const struct file_operations gdth_fops = {
- .ioctl = gdth_ioctl,
+ .unlocked_ioctl = gdth_unlocked_ioctl,
.open = gdth_open,
.release = gdth_close,
};
@@ -4462,8 +4462,7 @@ free_fail:
return rc;
}

-static int gdth_ioctl(struct inode *inode, struct file *filep,
- unsigned int cmd, unsigned long arg)
+static int gdth_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
gdth_ha_str *ha;
Scsi_Cmnd *scp;
@@ -4611,6 +4610,17 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
return 0;
}

+static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = gdth_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}

/* flush routine */
static void gdth_flush(gdth_ha_str *ha)
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 4bf7edc..c20b621 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -91,12 +91,15 @@ static struct proc_dir_entry *mega_proc_dir_entry;
/* For controller re-ordering */
static struct mega_hbas mega_hbas[MAX_CONTROLLERS];

+static long
+megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
+
/*
* The File Operations structure for the serial/ioctl interface of the driver
*/
static const struct file_operations megadev_fops = {
.owner = THIS_MODULE,
- .ioctl = megadev_ioctl,
+ .unlocked_ioctl = megadev_unlocked_ioctl,
.open = megadev_open,
};

@@ -3302,8 +3305,7 @@ megadev_open (struct inode *inode, struct file *filep)
* controller.
*/
static int
-megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
- unsigned long arg)
+megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
adapter_t *adapter;
nitioctl_t uioc;
@@ -3694,6 +3696,18 @@ freemem_and_return:
return 0;
}

+static long
+megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = megadev_ioctl(filep, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/**
* mega_m_to_n()
* @arg - user address
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 36e0b7d..41f82f7 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -22,7 +22,7 @@

// Entry points for char node driver
static int mraid_mm_open(struct inode *, struct file *);
-static int mraid_mm_ioctl(struct inode *, struct file *, uint, unsigned long);
+static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long);


// routines to convert to and from the old the format
@@ -70,7 +70,7 @@ static wait_queue_head_t wait_q;

static const struct file_operations lsi_fops = {
.open = mraid_mm_open,
- .ioctl = mraid_mm_ioctl,
+ .unlocked_ioctl = mraid_mm_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mraid_mm_compat_ioctl,
#endif
@@ -110,8 +110,7 @@ mraid_mm_open(struct inode *inode, struct file *filep)
* @arg : user ioctl packet
*/
static int
-mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
- unsigned long arg)
+mraid_mm_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
uioc_t *kioc;
char signature[EXT_IOCTL_SIGN_SZ] = {0};
@@ -218,6 +217,19 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
return rval;
}

+static long
+mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd,
+ unsigned long arg)
+{
+ int err;
+
+ /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */
+ lock_kernel();
+ err = mraid_mm_ioctl(filep, cmd, arg);
+ unlock_kernel();
+
+ return err;
+}

/**
* mraid_mm_get_adapter - Returns corresponding adapters for the mimd packet
@@ -1225,7 +1237,7 @@ mraid_mm_compat_ioctl(struct file *filep, unsigned int cmd,
{
int err;

- err = mraid_mm_ioctl(NULL, filep, cmd, arg);
+ err = mraid_mm_ioctl(filep, cmd, arg);

return err;
}
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index b219118..8dbf1c3 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -4932,7 +4932,7 @@ static int os_scsi_tape_close(struct inode * inode, struct file * filp)


/* The ioctl command */
-static int osst_ioctl(struct inode * inode,struct file * file,
+static long osst_ioctl(struct file * file,
unsigned int cmd_in, unsigned long arg)
{
int i, cmd_nr, cmd_type, blk, retval = 0;
@@ -4943,8 +4943,11 @@ static int osst_ioctl(struct inode * inode,struct file * file,
char * name = tape_name(STp);
void __user * p = (void __user *)arg;

- if (mutex_lock_interruptible(&STp->lock))
+ lock_kernel();
+ if (mutex_lock_interruptible(&STp->lock)) {
+ unlock_kernel();
return -ERESTARTSYS;
+ }

#if DEBUG
if (debugging && !STp->in_use) {
@@ -5256,12 +5259,15 @@ static int osst_ioctl(struct inode * inode,struct file * file,

mutex_unlock(&STp->lock);

- return scsi_ioctl(STp->device, cmd_in, p);
+ retval = scsi_ioctl(STp->device, cmd_in, p);
+ unlock_kernel();
+ return retval;

out:
if (SRpnt) osst_release_request(SRpnt);

mutex_unlock(&STp->lock);
+ unlock_kernel();

return retval;
}
@@ -5613,7 +5619,7 @@ static const struct file_operations osst_fops = {
.owner = THIS_MODULE,
.read = osst_read,
.write = osst_write,
- .ioctl = osst_ioctl,
+ .unlocked_ioctl = osst_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = osst_compat_ioctl,
#endif
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index dee1c96..ef752b2 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -758,8 +758,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
}

static int
-sg_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd_in, unsigned long arg)
+sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
{
void __user *p = (void __user *)arg;
int __user *ip = p;
@@ -1078,6 +1077,18 @@ sg_ioctl(struct inode *inode, struct file *filp,
}
}

+static long
+sg_unlocked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = sg_ioctl(filp, cmd_in, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef CONFIG_COMPAT
static long sg_compat_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
{
@@ -1322,7 +1333,7 @@ static const struct file_operations sg_fops = {
.read = sg_read,
.write = sg_write,
.poll = sg_poll,
- .ioctl = sg_ioctl,
+ .unlocked_ioctl = sg_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = sg_compat_ioctl,
#endif
--
1.7.0.4

2010-04-26 22:24:52

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 0/6] Push down BKL into device drivers

This is half the work of getting rid of the BKL in
the ioctl file operation, the rest in arch/ and fs/
still needs to be done, maybe two more hours of
work (for someone else than me ;-)).

Pushdown is straightforward. In many cases, it's
rather obvious that the BKL is not needed at all,
but let's not mix the removal with the pushdown.

Arnd Bergmann (6):
dvb: push down BKL into ioctl functions
scsi: push down BKL into ioctl functions
isdn: push down BKL into ioctl functions
staging: push down BKL into ioctl functions
v4l: always use unlocked_ioctl
drivers: push down BKL into various drivers

drivers/block/pktcdvd.c | 13 ++++++--
drivers/char/apm-emulation.c | 8 +++--
drivers/char/applicom.c | 13 +++++---
drivers/char/ds1620.c | 16 ++++++++-
drivers/char/dtlk.c | 15 +++++----
drivers/char/generic_nvram.c | 17 ++++++++--
drivers/char/genrtc.c | 16 ++++++++-
drivers/char/hpet.c | 14 +++++---
drivers/char/i8k.c | 21 ++++++++++--
drivers/char/ipmi/ipmi_devintf.c | 26 +++++++++++++---
drivers/char/ipmi/ipmi_watchdog.c | 17 +++++++++-
drivers/char/nvram.c | 10 ++++--
drivers/char/nwflash.c | 7 +++-
drivers/char/raw.c | 42 ++++++++++++++-----------
drivers/hwmon/fschmd.c | 9 +++--
drivers/hwmon/w83793.c | 10 ++++--
drivers/input/misc/hp_sdc_rtc.c | 34 ++++++++++++++------
drivers/isdn/capi/capi.c | 17 ++++++++--
drivers/isdn/divert/divert_procfs.c | 19 ++++++++++--
drivers/isdn/i4l/isdn_common.c | 18 +++++++++--
drivers/isdn/mISDN/timerdev.c | 10 ++++--
drivers/macintosh/nvram.c | 2 +-
drivers/macintosh/via-pmu.c | 17 ++++++++--
drivers/media/dvb/dvb-core/dmxdev.c | 31 +++++++++++++-----
drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 17 +++++++---
drivers/media/dvb/dvb-core/dvb_frontend.c | 30 +++++++++---------
drivers/media/dvb/dvb-core/dvb_net.c | 15 +++++++--
drivers/media/dvb/dvb-core/dvbdev.c | 17 +++++++----
drivers/media/dvb/dvb-core/dvbdev.h | 11 ++----
drivers/media/dvb/firewire/firedtv-ci.c | 5 +--
drivers/media/dvb/ttpci/av7110.c | 4 +-
drivers/media/dvb/ttpci/av7110_av.c | 8 ++--
drivers/media/dvb/ttpci/av7110_ca.c | 5 +--
drivers/media/video/v4l2-dev.c | 17 ++++++++--
drivers/mtd/mtdchar.c | 19 ++++++++---
drivers/pcmcia/pcmcia_ioctl.c | 17 ++++++++--
drivers/rtc/rtc-m41t80.c | 16 ++++++++-
drivers/sbus/char/openprom.c | 44 +++++++++++++++-----------
drivers/scsi/3w-9xxx.c | 10 ++++--
drivers/scsi/3w-sas.c | 7 +++-
drivers/scsi/3w-xxxx.c | 10 ++++--
drivers/scsi/aacraid/linit.c | 11 +++++--
drivers/scsi/dpt_i2o.c | 20 ++++++++++--
drivers/scsi/gdth.c | 20 +++++++++---
drivers/scsi/megaraid.c | 20 ++++++++++--
drivers/scsi/megaraid/megaraid_mm.c | 22 ++++++++++---
drivers/scsi/osst.c | 14 ++++++--
drivers/scsi/sg.c | 17 ++++++++--
drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++--
drivers/staging/dt3155/dt3155_drv.c | 24 +++++++++++----
drivers/staging/poch/poch.c | 17 +++++++++-
drivers/staging/vme/devices/vme_user.c | 18 +++++++++--
drivers/usb/mon/mon_bin.c | 23 ++++++++++----
drivers/usb/mon/mon_stat.c | 3 +-
54 files changed, 631 insertions(+), 245 deletions(-)

2010-04-26 22:24:54

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 1/6] dvb: push down BKL into ioctl functions

This requires changing all users of dvb_usercopy to
omit the inode argument.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/media/dvb/dvb-core/dmxdev.c | 31 +++++++++++++++++++-------
drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 17 ++++++++++----
drivers/media/dvb/dvb-core/dvb_frontend.c | 30 +++++++++++++-------------
drivers/media/dvb/dvb-core/dvb_net.c | 15 +++++++++---
drivers/media/dvb/dvb-core/dvbdev.c | 17 +++++++++-----
drivers/media/dvb/dvb-core/dvbdev.h | 11 +++------
drivers/media/dvb/firewire/firedtv-ci.c | 5 +--
drivers/media/dvb/ttpci/av7110.c | 4 +-
drivers/media/dvb/ttpci/av7110_av.c | 8 +++---
drivers/media/dvb/ttpci/av7110_ca.c | 5 +--
10 files changed, 85 insertions(+), 58 deletions(-)

diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 9ddc579..425862f 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
+#include <linux/smp_lock.h>
#include <linux/poll.h>
#include <linux/ioctl.h>
#include <linux/wait.h>
@@ -963,7 +964,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count,
return ret;
}

-static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_demux_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dmxdev_filter *dmxdevfilter = file->private_data;
@@ -1084,10 +1085,16 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
return ret;
}

-static int dvb_demux_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
@@ -1139,7 +1146,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_demux_fops = {
.owner = THIS_MODULE,
.read = dvb_demux_read,
- .ioctl = dvb_demux_ioctl,
+ .unlocked_ioctl = dvb_demux_ioctl,
.open = dvb_demux_open,
.release = dvb_demux_release,
.poll = dvb_demux_poll,
@@ -1152,7 +1159,7 @@ static struct dvb_device dvbdev_demux = {
.fops = &dvb_demux_fops
};

-static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_dvr_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1176,10 +1183,16 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
return ret;
}

-static int dvb_dvr_ioctl(struct inode *inode, struct file *file,
+static long dvb_dvr_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
@@ -1208,7 +1221,7 @@ static const struct file_operations dvb_dvr_fops = {
.owner = THIS_MODULE,
.read = dvb_dvr_read,
.write = dvb_dvr_write,
- .ioctl = dvb_dvr_ioctl,
+ .unlocked_ioctl = dvb_dvr_ioctl,
.open = dvb_dvr_open,
.release = dvb_dvr_release,
.poll = dvb_dvr_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index cb22da5..ef259a0 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -36,6 +36,7 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
+#include <linux/smp_lock.h>
#include <linux/kthread.h>

#include "dvb_ca_en50221.h"
@@ -1181,7 +1182,7 @@ static int dvb_ca_en50221_thread(void *data)
*
* @return 0 on success, <0 on error.
*/
-static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_ca_en50221_io_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1255,10 +1256,16 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
*
* @return 0 on success, <0 on error.
*/
-static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long dvb_ca_en50221_io_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}


@@ -1611,7 +1618,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_en50221_io_read,
.write = dvb_ca_en50221_io_write,
- .ioctl = dvb_ca_en50221_io_ioctl,
+ .unlocked_ioctl = dvb_ca_en50221_io_ioctl,
.open = dvb_ca_en50221_io_open,
.release = dvb_ca_en50221_io_release,
.poll = dvb_ca_en50221_io_poll,
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 55ea260..5450d1f 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -36,6 +36,7 @@
#include <linux/list.h>
#include <linux/freezer.h>
#include <linux/jiffies.h>
+#include <linux/smp_lock.h>
#include <linux/kthread.h>
#include <asm/processor.h>

@@ -1188,14 +1189,14 @@ static void dtv_property_cache_submit(struct dvb_frontend *fe)
}
}

-static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_legacy(struct file *file,
unsigned int cmd, void *parg);
-static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_properties(struct file *file,
unsigned int cmd, void *parg);

static int dtv_property_process_get(struct dvb_frontend *fe,
struct dtv_property *tvp,
- struct inode *inode, struct file *file)
+ struct file *file)
{
int r = 0;

@@ -1328,7 +1329,6 @@ static int dtv_property_process_get(struct dvb_frontend *fe,

static int dtv_property_process_set(struct dvb_frontend *fe,
struct dtv_property *tvp,
- struct inode *inode,
struct file *file)
{
int r = 0;
@@ -1359,7 +1359,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
dprintk("%s() Finalised property cache\n", __func__);
dtv_property_cache_submit(fe);

- r |= dvb_frontend_ioctl_legacy(inode, file, FE_SET_FRONTEND,
+ r |= dvb_frontend_ioctl_legacy(file, FE_SET_FRONTEND,
&fepriv->parameters);
break;
case DTV_FREQUENCY:
@@ -1391,12 +1391,12 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
break;
case DTV_VOLTAGE:
fe->dtv_property_cache.voltage = tvp->u.data;
- r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_VOLTAGE,
+ r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE,
(void *)fe->dtv_property_cache.voltage);
break;
case DTV_TONE:
fe->dtv_property_cache.sectone = tvp->u.data;
- r = dvb_frontend_ioctl_legacy(inode, file, FE_SET_TONE,
+ r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE,
(void *)fe->dtv_property_cache.sectone);
break;
case DTV_CODE_RATE_HP:
@@ -1480,7 +1480,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
return r;
}

-static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1502,17 +1502,17 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
return -ERESTARTSYS;

if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY))
- err = dvb_frontend_ioctl_properties(inode, file, cmd, parg);
+ err = dvb_frontend_ioctl_properties(file, cmd, parg);
else {
fe->dtv_property_cache.state = DTV_UNDEFINED;
- err = dvb_frontend_ioctl_legacy(inode, file, cmd, parg);
+ err = dvb_frontend_ioctl_legacy(file, cmd, parg);
}

up(&fepriv->sem);
return err;
}

-static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_properties(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1548,7 +1548,7 @@ static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
}

for (i = 0; i < tvps->num; i++) {
- (tvp + i)->result = dtv_property_process_set(fe, tvp + i, inode, file);
+ (tvp + i)->result = dtv_property_process_set(fe, tvp + i, file);
err |= (tvp + i)->result;
}

@@ -1580,7 +1580,7 @@ static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
}

for (i = 0; i < tvps->num; i++) {
- (tvp + i)->result = dtv_property_process_get(fe, tvp + i, inode, file);
+ (tvp + i)->result = dtv_property_process_get(fe, tvp + i, file);
err |= (tvp + i)->result;
}

@@ -1597,7 +1597,7 @@ out:
return err;
}

-static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
+static int dvb_frontend_ioctl_legacy(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -2022,7 +2022,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)

static const struct file_operations dvb_frontend_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.poll = dvb_frontend_poll,
.open = dvb_frontend_open,
.release = dvb_frontend_release
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 441c064..a96eee3 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -59,6 +59,7 @@
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/dvb/net.h>
+#include <linux/smp_lock.h>
#include <linux/uio.h>
#include <asm/uaccess.h>
#include <linux/crc32.h>
@@ -1333,7 +1334,7 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)
return 0;
}

-static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
+static int dvb_net_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1435,10 +1436,16 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
return 0;
}

-static int dvb_net_ioctl(struct inode *inode, struct file *file,
+static long dvb_net_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl);
+ int ret;
+
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
+ unlock_kernel();
+
+ return ret;
}

static int dvb_net_close(struct inode *inode, struct file *file)
@@ -1459,7 +1466,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)

static const struct file_operations dvb_net_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_net_ioctl,
+ .unlocked_ioctl = dvb_net_ioctl,
.open = dvb_generic_open,
.release = dvb_net_close,
};
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 94159b9..b915c39 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -154,10 +154,11 @@ int dvb_generic_release(struct inode *inode, struct file *file)
EXPORT_SYMBOL(dvb_generic_release);


-int dvb_generic_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+long dvb_generic_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
{
struct dvb_device *dvbdev = file->private_data;
+ int ret;

if (!dvbdev)
return -ENODEV;
@@ -165,7 +166,11 @@ int dvb_generic_ioctl(struct inode *inode, struct file *file,
if (!dvbdev->kernel_ioctl)
return -EINVAL;

- return dvb_usercopy (inode, file, cmd, arg, dvbdev->kernel_ioctl);
+ lock_kernel();
+ ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
+ unlock_kernel();
+
+ return ret;
}
EXPORT_SYMBOL(dvb_generic_ioctl);

@@ -377,9 +382,9 @@ EXPORT_SYMBOL(dvb_unregister_adapter);
define this as video_usercopy(). this will introduce a dependecy
to the v4l "videodev.o" module, which is unnecessary for some
cards (ie. the budget dvb-cards don't need the v4l module...) */
-int dvb_usercopy(struct inode *inode, struct file *file,
+int dvb_usercopy(struct file *file,
unsigned int cmd, unsigned long arg,
- int (*func)(struct inode *inode, struct file *file,
+ int (*func)(struct file *file,
unsigned int cmd, void *arg))
{
char sbuf[128];
@@ -416,7 +421,7 @@ int dvb_usercopy(struct inode *inode, struct file *file,
}

/* call driver */
- if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
+ if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
err = -EINVAL;

if (err < 0)
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index f7b499d..fcc6ae9 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -116,8 +116,7 @@ struct dvb_device {

wait_queue_head_t wait_queue;
/* don't really need those !? -- FIXME: use video_usercopy */
- int (*kernel_ioctl)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg);
+ int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);

void *priv;
};
@@ -138,17 +137,15 @@ extern void dvb_unregister_device (struct dvb_device *dvbdev);

extern int dvb_generic_open (struct inode *inode, struct file *file);
extern int dvb_generic_release (struct inode *inode, struct file *file);
-extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
+extern long dvb_generic_ioctl (struct file *file,
unsigned int cmd, unsigned long arg);

/* we don't mess with video_usercopy() any more,
we simply define out own dvb_usercopy(), which will hopefully become
generic_usercopy() someday... */

-extern int dvb_usercopy(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg,
- int (*func)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg));
+extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
+ int (*func)(struct file *file, unsigned int cmd, void *arg));

/** generic DVB attach function. */
#ifdef CONFIG_MEDIA_ATTACH
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index 853e04b..d3c2cf6 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -175,8 +175,7 @@ static int fdtv_ca_send_msg(struct firedtv *fdtv, void *arg)
return err;
}

-static int fdtv_ca_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg)
+static int fdtv_ca_ioctl(struct file *file, unsigned int cmd, void *arg)
{
struct dvb_device *dvbdev = file->private_data;
struct firedtv *fdtv = dvbdev->priv;
@@ -217,7 +216,7 @@ static unsigned int fdtv_ca_io_poll(struct file *file, poll_table *wait)

static const struct file_operations fdtv_ca_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
.poll = fdtv_ca_io_poll,
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 3891559..a6be529 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -708,7 +708,7 @@ static void gpioirq(unsigned long cookie)


#ifdef CONFIG_DVB_AV7110_OSD
-static int dvb_osd_ioctl(struct inode *inode, struct file *file,
+static int dvb_osd_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -727,7 +727,7 @@ static int dvb_osd_ioctl(struct inode *inode, struct file *file,

static const struct file_operations dvb_osd_fops = {
.owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
.release = dvb_generic_release,
};
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 5388481..13efba9 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1089,7 +1089,7 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len
}


-static int dvb_video_ioctl(struct inode *inode, struct file *file,
+static int dvb_video_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1297,7 +1297,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
return ret;
}

-static int dvb_audio_ioctl(struct inode *inode, struct file *file,
+static int dvb_audio_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
@@ -1517,7 +1517,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
static const struct file_operations dvb_video_fops = {
.owner = THIS_MODULE,
.write = dvb_video_write,
- .ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_video_open,
.release = dvb_video_release,
.poll = dvb_video_poll,
@@ -1535,7 +1535,7 @@ static struct dvb_device dvbdev_video = {
static const struct file_operations dvb_audio_fops = {
.owner = THIS_MODULE,
.write = dvb_audio_write,
- .ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_audio_open,
.release = dvb_audio_release,
.poll = dvb_audio_poll,
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index ac7779c..4eba35a 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -248,8 +248,7 @@ static unsigned int dvb_ca_poll (struct file *file, poll_table *wait)
return mask;
}

-static int dvb_ca_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
+static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
struct av7110 *av7110 = dvbdev->priv;
@@ -350,7 +349,7 @@ static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_read,
.write = dvb_ca_write,
- .ioctl = dvb_generic_ioctl,
+ .unlocked_ioctl = dvb_generic_ioctl,
.open = dvb_ca_open,
.release = dvb_generic_release,
.poll = dvb_ca_poll,
--
1.7.0.4

2010-04-26 22:24:43

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 3/6] isdn: push down BKL into ioctl functions

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/isdn/capi/capi.c | 17 ++++++++++++++---
drivers/isdn/divert/divert_procfs.c | 19 ++++++++++++++++---
drivers/isdn/i4l/isdn_common.c | 18 +++++++++++++++---
drivers/isdn/mISDN/timerdev.c | 10 ++++++----
4 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index ee58375..0cabe31 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -787,8 +787,7 @@ capi_poll(struct file *file, poll_table * wait)
}

static int
-capi_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+capi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct capidev *cdev = file->private_data;
capi_ioctl_struct data;
@@ -981,6 +980,18 @@ register_out:
}
}

+static long
+capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = capi_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static int capi_open(struct inode *inode, struct file *file)
{
struct capidev *cdev;
@@ -1026,7 +1037,7 @@ static const struct file_operations capi_fops =
.read = capi_read,
.write = capi_write,
.poll = capi_poll,
- .ioctl = capi_ioctl,
+ .unlocked_ioctl = capi_unlocked_ioctl,
.open = capi_open,
.release = capi_release,
};
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 9f49d90..8084557 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -11,6 +11,7 @@

#include <linux/module.h>
#include <linux/poll.h>
+#include <linux/smp_lock.h>
#include <linux/slab.h>
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
@@ -178,8 +179,7 @@ isdn_divert_close(struct inode *ino, struct file *filep)
/* IOCTL */
/*********/
static int
-isdn_divert_ioctl(struct inode *inode, struct file *file,
- uint cmd, ulong arg)
+isdn_divert_ioctl(struct file *file, uint cmd, ulong arg)
{
divert_ioctl dioctl;
int i;
@@ -258,6 +258,19 @@ isdn_divert_ioctl(struct inode *inode, struct file *file,
return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0;
} /* isdn_divert_ioctl */

+static long
+isdn_divert_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = isdn_divert_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
+
static const struct file_operations isdn_fops =
{
.owner = THIS_MODULE,
@@ -265,7 +278,7 @@ static const struct file_operations isdn_fops =
.read = isdn_divert_read,
.write = isdn_divert_write,
.poll = isdn_divert_poll,
- .ioctl = isdn_divert_ioctl,
+ .unlocked_ioctl = isdn_divert_unlocked_ioctl,
.open = isdn_divert_open,
.release = isdn_divert_close,
};
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 70044ee..a44cdb4 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1272,9 +1272,9 @@ isdn_poll(struct file *file, poll_table * wait)


static int
-isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+isdn_ioctl(struct file *file, uint cmd, ulong arg)
{
- uint minor = iminor(inode);
+ uint minor = iminor(file->f_path.dentry->d_inode);
isdn_ctrl c;
int drvidx;
int chidx;
@@ -1722,6 +1722,18 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
#undef cfg
}

+static long
+isdn_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = isdn_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/*
* Open the device code.
*/
@@ -1838,7 +1850,7 @@ static const struct file_operations isdn_fops =
.read = isdn_read,
.write = isdn_write,
.poll = isdn_poll,
- .ioctl = isdn_ioctl,
+ .unlocked_ioctl = isdn_unlocked_ioctl,
.open = isdn_open,
.release = isdn_close,
};
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 8785004..c3243c9 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -24,6 +24,7 @@
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mISDNif.h>
+#include <linux/smp_lock.h>
#include "core.h"

static u_int *debug;
@@ -215,9 +216,8 @@ unlock:
return ret;
}

-static int
-mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
- unsigned long arg)
+static long
+mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
struct mISDNtimerdev *dev = filep->private_data;
int id, tout, ret = 0;
@@ -226,6 +226,7 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
if (*debug & DEBUG_TIMER)
printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__,
filep, cmd, arg);
+ lock_kernel();
switch (cmd) {
case IMADDTIMER:
if (get_user(tout, (int __user *)arg)) {
@@ -257,13 +258,14 @@ mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
default:
ret = -EINVAL;
}
+ unlock_kernel();
return ret;
}

static const struct file_operations mISDN_fops = {
.read = mISDN_read,
.poll = mISDN_poll,
- .ioctl = mISDN_ioctl,
+ .unlocked_ioctl = mISDN_ioctl,
.open = mISDN_open,
.release = mISDN_close,
};
--
1.7.0.4

2010-04-26 22:25:12

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 5/6] v4l: always use unlocked_ioctl

v4l drivers may still use a locked ioctl method,
but we now always export an unlocked_ioctl and
lock ourselves, so that the ->ioctl file operation
can get removed.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/media/video/v4l2-dev.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7090699..3606694 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -22,6 +22,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
+#include <linux/smp_lock.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/slab.h>
@@ -215,16 +216,21 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
return vdev->fops->poll(filp, poll);
}

-static int v4l2_ioctl(struct inode *inode, struct file *filp,
+static long v4l2_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct video_device *vdev = video_devdata(filp);
+ int ret;

if (!vdev->fops->ioctl)
return -ENOTTY;
/* Allow ioctl to continue even if the device was unregistered.
Things like dequeueing buffers might still be useful. */
- return vdev->fops->ioctl(filp, cmd, arg);
+ lock_kernel();
+ ret = vdev->fops->ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
}

static long v4l2_unlocked_ioctl(struct file *filp,
@@ -323,6 +329,11 @@ static const struct file_operations v4l2_unlocked_fops = {
.llseek = no_llseek,
};

+/*
+ * Note: this should not be needed, just check
+ * both pointers in v4l2_ioctl, or kill
+ * fops->ioctl. -arnd
+ */
static const struct file_operations v4l2_fops = {
.owner = THIS_MODULE,
.read = v4l2_read,
@@ -330,7 +341,7 @@ static const struct file_operations v4l2_fops = {
.open = v4l2_open,
.get_unmapped_area = v4l2_get_unmapped_area,
.mmap = v4l2_mmap,
- .ioctl = v4l2_ioctl,
+ .unlocked_ioctl = v4l2_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = v4l2_compat_ioctl32,
#endif
--
1.7.0.4

2010-04-26 22:25:25

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 6/6] drivers: push down BKL into various drivers

These are the last remaining device drivers using
the ->ioctl file operation in the drivers directory.

Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/block/pktcdvd.c | 13 ++++++++--
drivers/char/apm-emulation.c | 8 ++++--
drivers/char/applicom.c | 13 ++++++----
drivers/char/ds1620.c | 16 +++++++++++-
drivers/char/dtlk.c | 15 ++++++------
drivers/char/generic_nvram.c | 17 +++++++++++--
drivers/char/genrtc.c | 16 +++++++++++-
drivers/char/hpet.c | 14 +++++++----
drivers/char/i8k.c | 21 ++++++++++++++---
drivers/char/ipmi/ipmi_devintf.c | 26 +++++++++++++++++----
drivers/char/ipmi/ipmi_watchdog.c | 17 ++++++++++++-
drivers/char/nvram.c | 10 ++++++--
drivers/char/nwflash.c | 7 ++++-
drivers/char/raw.c | 42 ++++++++++++++++++++---------------
drivers/hwmon/fschmd.c | 9 ++++---
drivers/hwmon/w83793.c | 10 +++++---
drivers/input/misc/hp_sdc_rtc.c | 34 ++++++++++++++++++++--------
drivers/macintosh/nvram.c | 2 +-
drivers/macintosh/via-pmu.c | 17 +++++++++++--
drivers/mtd/mtdchar.c | 19 +++++++++++----
drivers/pcmcia/pcmcia_ioctl.c | 17 +++++++++++--
drivers/rtc/rtc-m41t80.c | 16 +++++++++++-
drivers/sbus/char/openprom.c | 44 +++++++++++++++++++++----------------
drivers/usb/mon/mon_bin.c | 23 ++++++++++++++-----
drivers/usb/mon/mon_stat.c | 3 +-
25 files changed, 307 insertions(+), 122 deletions(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index ddf1942..84a5658 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -55,6 +55,7 @@
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
#include <linux/freezer.h>
#include <linux/mutex.h>
#include <linux/slab.h>
@@ -2984,7 +2985,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
mutex_unlock(&ctl_mutex);
}

-static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
struct pkt_ctrl_command ctrl_cmd;
@@ -3001,16 +3002,22 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
case PKT_CTRL_CMD_SETUP:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ lock_kernel();
ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev);
+ unlock_kernel();
ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev);
break;
case PKT_CTRL_CMD_TEARDOWN:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ lock_kernel();
ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev));
+ unlock_kernel();
break;
case PKT_CTRL_CMD_STATUS:
+ lock_kernel();
pkt_get_status(&ctrl_cmd);
+ unlock_kernel();
break;
default:
return -ENOTTY;
@@ -3023,8 +3030,8 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm


static const struct file_operations pkt_ctl_fops = {
- .ioctl = pkt_ctl_ioctl,
- .owner = THIS_MODULE,
+ .unlocked_ioctl = pkt_ctl_ioctl,
+ .owner = THIS_MODULE,
};

static struct miscdevice pkt_misc = {
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 4f568cb..033e150 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -265,8 +265,8 @@ static unsigned int apm_poll(struct file *fp, poll_table * wait)
* Only when everyone who has opened /dev/apm_bios with write permission
* has acknowledge does the actual suspend happen.
*/
-static int
-apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
+static long
+apm_ioctl(struct file *filp, u_int cmd, u_long arg)
{
struct apm_user *as = filp->private_data;
int err = -EINVAL;
@@ -274,6 +274,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
if (!as->suser || !as->writer)
return -EPERM;

+ lock_kernel();
switch (cmd) {
case APM_IOC_SUSPEND:
mutex_lock(&state_lock);
@@ -334,6 +335,7 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
mutex_unlock(&state_lock);
break;
}
+ unlock_kernel();

return err;
}
@@ -397,7 +399,7 @@ static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = apm_read,
.poll = apm_poll,
- .ioctl = apm_ioctl,
+ .unlocked_ioctl = apm_ioctl,
.open = apm_open,
.release = apm_release,
};
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a7424bf..63313a3 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -26,6 +26,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/errno.h>
+#include <linux/smp_lock.h>
#include <linux/miscdevice.h>
#include <linux/pci.h>
#include <linux/wait.h>
@@ -106,8 +107,7 @@ static unsigned int DeviceErrorCount; /* number of device error */

static ssize_t ac_read (struct file *, char __user *, size_t, loff_t *);
static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *);
-static int ac_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
+static long ac_ioctl(struct file *, unsigned int, unsigned long);
static irqreturn_t ac_interrupt(int, void *);

static const struct file_operations ac_fops = {
@@ -115,7 +115,7 @@ static const struct file_operations ac_fops = {
.llseek = no_llseek,
.read = ac_read,
.write = ac_write,
- .ioctl = ac_ioctl,
+ .unlocked_ioctl = ac_ioctl,
};

static struct miscdevice ac_miscdev = {
@@ -689,7 +689,7 @@ static irqreturn_t ac_interrupt(int vec, void *dev_instance)



-static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

{ /* @ ADG ou ATO selon le cas */
int i;
@@ -711,7 +711,8 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
kfree(adgl);
return -EFAULT;
}
-
+
+ lock_kernel();
IndexCard = adgl->num_card-1;

if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
@@ -721,6 +722,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
warncount--;
}
kfree(adgl);
+ unlock_kernel();
return -EINVAL;
}

@@ -838,6 +840,7 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
}
Dummy = readb(apbs[IndexCard].RamIO + VERS);
kfree(adgl);
+ unlock_kernel();
return 0;
}

diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index 61f0146..dbee868 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -232,7 +232,7 @@ ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
}

static int
-ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+ds1620_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct therm therm;
union {
@@ -316,6 +316,18 @@ ds1620_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
return 0;
}

+static long
+ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = ds1620_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef THERM_USE_PROC
static int
proc_therm_ds1620_read(char *buf, char **start, off_t offset,
@@ -344,7 +356,7 @@ static const struct file_operations ds1620_fops = {
.owner = THIS_MODULE,
.open = ds1620_open,
.read = ds1620_read,
- .ioctl = ds1620_ioctl,
+ .unlocked_ioctl = ds1620_unlocked_ioctl,
};

static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 045c930..e3859d4 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -93,8 +93,8 @@ static ssize_t dtlk_write(struct file *, const char __user *,
static unsigned int dtlk_poll(struct file *, poll_table *);
static int dtlk_open(struct inode *, struct file *);
static int dtlk_release(struct inode *, struct file *);
-static int dtlk_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
+static long dtlk_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg);

static const struct file_operations dtlk_fops =
{
@@ -102,7 +102,7 @@ static const struct file_operations dtlk_fops =
.read = dtlk_read,
.write = dtlk_write,
.poll = dtlk_poll,
- .ioctl = dtlk_ioctl,
+ .unlocked_ioctl = dtlk_ioctl,
.open = dtlk_open,
.release = dtlk_release,
};
@@ -263,10 +263,9 @@ static void dtlk_timer_tick(unsigned long data)
wake_up_interruptible(&dtlk_process_list);
}

-static int dtlk_ioctl(struct inode *inode,
- struct file *file,
- unsigned int cmd,
- unsigned long arg)
+static long dtlk_ioctl(struct file *file,
+ unsigned int cmd,
+ unsigned long arg)
{
char __user *argp = (char __user *)arg;
struct dtlk_settings *sp;
@@ -276,7 +275,9 @@ static int dtlk_ioctl(struct inode *inode,
switch (cmd) {

case DTLK_INTERROGATE:
+ lock_kernel();
sp = dtlk_interrogate();
+ unlock_kernel();
if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
return -EINVAL;
return 0;
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index fda4181..82b5a88 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -19,6 +19,7 @@
#include <linux/miscdevice.h>
#include <linux/fcntl.h>
#include <linux/init.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/nvram.h>
#ifdef CONFIG_PPC_PMAC
@@ -84,8 +85,7 @@ static ssize_t write_nvram(struct file *file, const char __user *buf,
return p - buf;
}

-static int nvram_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static int nvram_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
switch(cmd) {
#ifdef CONFIG_PPC_PMAC
@@ -116,12 +116,23 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
return 0;
}

+static long nvram_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = nvram_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
const struct file_operations nvram_fops = {
.owner = THIS_MODULE,
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .ioctl = nvram_ioctl,
+ .unlocked_ioctl = nvram_unlocked_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 31e7c91..b6c2cc1 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -262,7 +262,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
#endif
}

-static int gen_rtc_ioctl(struct inode *inode, struct file *file,
+static int gen_rtc_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
struct rtc_time wtime;
@@ -332,6 +332,18 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
}

+static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = gen_rtc_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/*
* We enforce only one user at a time here with the open/close.
* Also clear the previous interrupt data on an open, and clean
@@ -482,7 +494,7 @@ static const struct file_operations gen_rtc_fops = {
.read = gen_rtc_read,
.poll = gen_rtc_poll,
#endif
- .ioctl = gen_rtc_ioctl,
+ .unlocked_ioctl = gen_rtc_unlocked_ioctl,
.open = gen_rtc_open,
.release = gen_rtc_release,
};
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 9ded667..a0a1829 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -431,14 +431,18 @@ static int hpet_release(struct inode *inode, struct file *file)

static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);

-static int
-hpet_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg)
+static long hpet_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
{
struct hpet_dev *devp;
+ int ret;

devp = file->private_data;
- return hpet_ioctl_common(devp, cmd, arg, 0);
+ lock_kernel();
+ ret = hpet_ioctl_common(devp, cmd, arg, 0);
+ unlock_kernel();
+
+ return ret;
}

static int hpet_ioctl_ieon(struct hpet_dev *devp)
@@ -654,7 +658,7 @@ static const struct file_operations hpet_fops = {
.llseek = no_llseek,
.read = hpet_read,
.poll = hpet_poll,
- .ioctl = hpet_ioctl,
+ .unlocked_ioctl = hpet_ioctl,
.open = hpet_open,
.release = hpet_release,
.fasync = hpet_fasync,
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index fc8cf7a..3dc67ae 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -21,6 +21,7 @@
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/smp_lock.h>
#include <linux/dmi.h>
#include <linux/capability.h>
#include <asm/uaccess.h>
@@ -82,8 +83,8 @@ module_param(fan_mult, int, 0);
MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with");

static int i8k_open_fs(struct inode *inode, struct file *file);
-static int i8k_ioctl(struct inode *, struct file *, unsigned int,
- unsigned long);
+static long i8k_unlocked_ioctl(struct file *, unsigned int,
+ unsigned long);

static const struct file_operations i8k_fops = {
.owner = THIS_MODULE,
@@ -91,7 +92,7 @@ static const struct file_operations i8k_fops = {
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
- .ioctl = i8k_ioctl,
+ .unlocked_ioctl = i8k_unlocked_ioctl,
};

struct smm_regs {
@@ -307,7 +308,7 @@ static int i8k_get_dell_signature(int req_fn)
return regs.eax == 1145651527 && regs.edx == 1145392204 ? 0 : -1;
}

-static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
+static int i8k_ioctl(struct file *fp, unsigned int cmd,
unsigned long arg)
{
int val = 0;
@@ -395,6 +396,18 @@ static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
return 0;
}

+static long
+i8k_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = i8k_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/*
* Print the information for /proc/i8k.
*/
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 65545de..d8ec92a 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -228,8 +228,7 @@ static int handle_send_req(ipmi_user_t user,
return rv;
}

-static int ipmi_ioctl(struct inode *inode,
- struct file *file,
+static int ipmi_ioctl(struct file *file,
unsigned int cmd,
unsigned long data)
{
@@ -630,6 +629,23 @@ static int ipmi_ioctl(struct inode *inode,
return rv;
}

+/*
+ * Note: it doesn't make sense to take the BKL here but
+ * not in compat_ipmi_ioctl. -arnd
+ */
+static long ipmi_unlocked_ioctl(struct file *file,
+ unsigned int cmd,
+ unsigned long data)
+{
+ int ret;
+
+ lock_kernel();
+ ret = ipmi_ioctl(file, cmd, data);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef CONFIG_COMPAT

/*
@@ -802,7 +818,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
if (copy_to_user(precv64, &recv64, sizeof(recv64)))
return -EFAULT;

- rc = ipmi_ioctl(filep->f_path.dentry->d_inode, filep,
+ rc = ipmi_ioctl(filep,
((cmd == COMPAT_IPMICTL_RECEIVE_MSG)
? IPMICTL_RECEIVE_MSG
: IPMICTL_RECEIVE_MSG_TRUNC),
@@ -819,14 +835,14 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
return rc;
}
default:
- return ipmi_ioctl(filep->f_path.dentry->d_inode, filep, cmd, arg);
+ return ipmi_ioctl(filep, cmd, arg);
}
}
#endif

static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
- .ioctl = ipmi_ioctl,
+ .unlocked_ioctl = ipmi_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl,
#endif
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index a4d57e3..82bcdb2 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -659,7 +659,7 @@ static struct watchdog_info ident = {
.identity = "IPMI"
};

-static int ipmi_ioctl(struct inode *inode, struct file *file,
+static int ipmi_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
@@ -730,6 +730,19 @@ static int ipmi_ioctl(struct inode *inode, struct file *file,
}
}

+static long ipmi_unlocked_ioctl(struct file *file,
+ unsigned int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = ipmi_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static ssize_t ipmi_write(struct file *file,
const char __user *buf,
size_t len,
@@ -880,7 +893,7 @@ static const struct file_operations ipmi_wdog_fops = {
.read = ipmi_read,
.poll = ipmi_poll,
.write = ipmi_write,
- .ioctl = ipmi_ioctl,
+ .unlocked_ioctl = ipmi_unlocked_ioctl,
.open = ipmi_open,
.release = ipmi_close,
.fasync = ipmi_fasync,
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 47e8f7b..66d2917 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -296,8 +296,8 @@ checksum_err:
return -EIO;
}

-static int nvram_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long nvram_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
{
int i;

@@ -308,6 +308,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN))
return -EACCES;

+ lock_kernel();
spin_lock_irq(&rtc_lock);

for (i = 0; i < NVRAM_BYTES; ++i)
@@ -315,6 +316,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
__nvram_set_checksum();

spin_unlock_irq(&rtc_lock);
+ unlock_kernel();
return 0;

case NVRAM_SETCKS:
@@ -323,9 +325,11 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN))
return -EACCES;

+ lock_kernel();
spin_lock_irq(&rtc_lock);
__nvram_set_checksum();
spin_unlock_irq(&rtc_lock);
+ unlock_kernel();
return 0;

default:
@@ -422,7 +426,7 @@ static const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = nvram_read,
.write = nvram_write,
- .ioctl = nvram_ioctl,
+ .unlocked_ioctl = nvram_ioctl,
.open = nvram_open,
.release = nvram_release,
};
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index f808109..043a1c7 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -94,8 +94,9 @@ static int get_flash_id(void)
return c2;
}

-static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cmd, unsigned long arg)
+static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
+ lock_kernel();
switch (cmd) {
case CMD_WRITE_DISABLE:
gbWriteBase64Enable = 0;
@@ -113,8 +114,10 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm
default:
gbWriteBase64Enable = 0;
gbWriteEnable = 0;
+ unlock_kernel();
return -EINVAL;
}
+ unlock_kernel();
return 0;
}

@@ -631,7 +634,7 @@ static const struct file_operations flash_fops =
.llseek = flash_llseek,
.read = flash_read,
.write = flash_write,
- .ioctl = flash_ioctl,
+ .unlocked_ioctl = flash_ioctl,
};

static struct miscdevice flash_miscdev =
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 8756ab0..b38942f 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -121,13 +121,17 @@ static int raw_release(struct inode *inode, struct file *filp)
/*
* Forward ioctls to the underlying block device.
*/
-static int
-raw_ioctl(struct inode *inode, struct file *filp,
- unsigned int command, unsigned long arg)
+static long
+raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
{
struct block_device *bdev = filp->private_data;
+ int ret;
+
+ lock_kernel();
+ ret = blkdev_ioctl(bdev, 0, command, arg);
+ unlock_kernel();

- return blkdev_ioctl(bdev, 0, command, arg);
+ return ret;
}

static void bind_device(struct raw_config_request *rq)
@@ -141,13 +145,14 @@ static void bind_device(struct raw_config_request *rq)
* Deal with ioctls against the raw-device control interface, to bind
* and unbind other raw devices.
*/
-static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
- unsigned int command, unsigned long arg)
+static long raw_ctl_ioctl(struct file *filp, unsigned int command,
+ unsigned long arg)
{
struct raw_config_request rq;
struct raw_device_data *rawdev;
int err = 0;

+ lock_kernel();
switch (command) {
case RAW_SETBIND:
case RAW_GETBIND:
@@ -240,25 +245,26 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
break;
}
out:
+ unlock_kernel();
return err;
}

static const struct file_operations raw_fops = {
- .read = do_sync_read,
- .aio_read = generic_file_aio_read,
- .write = do_sync_write,
- .aio_write = blkdev_aio_write,
- .fsync = blkdev_fsync,
- .open = raw_open,
- .release= raw_release,
- .ioctl = raw_ioctl,
- .owner = THIS_MODULE,
+ .read = do_sync_read,
+ .aio_read = generic_file_aio_read,
+ .write = do_sync_write,
+ .aio_write = blkdev_aio_write,
+ .fsync = blkdev_fsync,
+ .open = raw_open,
+ .release = raw_release,
+ .unlocked_ioctl = raw_ioctl,
+ .owner = THIS_MODULE,
};

static const struct file_operations raw_ctl_fops = {
- .ioctl = raw_ctl_ioctl,
- .open = raw_open,
- .owner = THIS_MODULE,
+ .unlocked_ioctl = raw_ctl_ioctl,
+ .open = raw_open,
+ .owner = THIS_MODULE,
};

static struct cdev raw_cdev;
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index 0627f7a..b7ca2a9 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -38,6 +38,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
+#include <linux/smp_lock.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
@@ -847,8 +848,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
return count;
}

-static int watchdog_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
@@ -858,6 +858,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
int i, ret = 0;
struct fschmd_data *data = filp->private_data;

+ lock_kernel();
switch (cmd) {
case WDIOC_GETSUPPORT:
ident.firmware_version = data->revision;
@@ -914,7 +915,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
default:
ret = -ENOTTY;
}
-
+ unlock_kernel();
return ret;
}

@@ -924,7 +925,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_release,
.write = watchdog_write,
- .ioctl = watchdog_ioctl,
+ .unlocked_ioctl = watchdog_ioctl,
};


diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 612807d..697202e 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -35,6 +35,7 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
+#include <linux/smp_lock.h>
#include <linux/hwmon-vid.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
@@ -1319,8 +1320,8 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
return count;
}

-static int watchdog_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static long watchdog_ioctl(struct file *filp, unsigned int cmd,
+ unsigned long arg)
{
static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING |
@@ -1332,6 +1333,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
int val, ret = 0;
struct w83793_data *data = filp->private_data;

+ lock_kernel();
switch (cmd) {
case WDIOC_GETSUPPORT:
if (!nowayout)
@@ -1385,7 +1387,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
default:
ret = -ENOTTY;
}
-
+ unlock_kernel();
return ret;
}

@@ -1395,7 +1397,7 @@ static const struct file_operations watchdog_fops = {
.open = watchdog_open,
.release = watchdog_close,
.write = watchdog_write,
- .ioctl = watchdog_ioctl,
+ .unlocked_ioctl = watchdog_ioctl,
};

/*
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ad730e1..e00a1cc 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -43,6 +43,7 @@
#include <linux/proc_fs.h>
#include <linux/poll.h>
#include <linux/rtc.h>
+#include <linux/smp_lock.h>
#include <linux/semaphore.h>

MODULE_AUTHOR("Brian S. Julin <[email protected]>");
@@ -64,8 +65,8 @@ static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos);

-static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
+static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg);

static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);

@@ -512,7 +513,7 @@ static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
return len;
}

-static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
+static int hp_sdc_rtc_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
#if 1
@@ -659,14 +660,27 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
#endif
}

+static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = hp_sdc_rtc_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
+
static const struct file_operations hp_sdc_rtc_fops = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .read = hp_sdc_rtc_read,
- .poll = hp_sdc_rtc_poll,
- .ioctl = hp_sdc_rtc_ioctl,
- .open = hp_sdc_rtc_open,
- .fasync = hp_sdc_rtc_fasync,
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .read = hp_sdc_rtc_read,
+ .poll = hp_sdc_rtc_poll,
+ .unlocked_ioctl = hp_sdc_rtc_ioctl,
+ .open = hp_sdc_rtc_open,
+ .fasync = hp_sdc_rtc_fasync,
};

static struct miscdevice hp_sdc_rtc_dev = {
diff --git a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c
index c876349..a271c82 100644
--- a/drivers/macintosh/nvram.c
+++ b/drivers/macintosh/nvram.c
@@ -100,7 +100,7 @@ const struct file_operations nvram_fops = {
.llseek = nvram_llseek,
.read = read_nvram,
.write = write_nvram,
- .ioctl = nvram_ioctl,
+ .unlocked_ioctl = nvram_ioctl,
};

static struct miscdevice nvram_dev = {
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 4276484..3d4fc0f 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2273,8 +2273,7 @@ static int register_pmu_pm_ops(void)
device_initcall(register_pmu_pm_ops);
#endif

-static int
-pmu_ioctl(struct inode * inode, struct file *filp,
+static int pmu_ioctl(struct file *filp,
u_int cmd, u_long arg)
{
__u32 __user *argp = (__u32 __user *)arg;
@@ -2337,11 +2336,23 @@ pmu_ioctl(struct inode * inode, struct file *filp,
return error;
}

+static long pmu_unlocked_ioctl(struct file *filp,
+ u_int cmd, u_long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = pmu_ioctl(filp, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
static const struct file_operations pmu_device_fops = {
.read = pmu_read,
.write = pmu_write,
.poll = pmu_fpoll,
- .ioctl = pmu_ioctl,
+ .unlocked_ioctl = pmu_unlocked_ioctl,
.open = pmu_open,
.release = pmu_release,
};
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 5b081cb..6749c2f 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -450,8 +450,7 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
return ret;
}

-static int mtd_ioctl(struct inode *inode, struct file *file,
- u_int cmd, u_long arg)
+static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
{
struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd;
@@ -822,6 +821,17 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
return ret;
} /* memory_ioctl */

+static long mtd_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = mtd_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
#ifdef CONFIG_COMPAT

struct mtd_oob_buf32 {
@@ -836,7 +846,6 @@ struct mtd_oob_buf32 {
static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
- struct inode *inode = file->f_path.dentry->d_inode;
struct mtd_file_info *mfi = file->private_data;
struct mtd_info *mtd = mfi->mtd;
void __user *argp = compat_ptr(arg);
@@ -874,7 +883,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
break;
}
default:
- ret = mtd_ioctl(inode, file, cmd, (unsigned long)argp);
+ ret = mtd_ioctl(file, cmd, (unsigned long)argp);
}

unlock_kernel();
@@ -942,7 +951,7 @@ static const struct file_operations mtd_fops = {
.llseek = mtd_lseek,
.read = mtd_read,
.write = mtd_write,
- .ioctl = mtd_ioctl,
+ .unlocked_ioctl = mtd_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mtd_compat_ioctl,
#endif
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 104e73d..a3b1b5b 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -821,8 +821,7 @@ static u_int ds_poll(struct file *file, poll_table *wait)

/*====================================================================*/

-static int ds_ioctl(struct inode *inode, struct file *file,
- u_int cmd, u_long arg)
+static int ds_ioctl(struct file *file, u_int cmd, u_long arg)
{
struct pcmcia_socket *s;
void __user *uarg = (char __user *)arg;
@@ -1031,13 +1030,25 @@ free_out:
return err;
} /* ds_ioctl */

+static long ds_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = ds_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
+
/*====================================================================*/

static const struct file_operations ds_fops = {
.owner = THIS_MODULE,
.open = ds_open,
.release = ds_release,
- .ioctl = ds_ioctl,
+ .unlocked_ioctl = ds_unlocked_ioctl,
.read = ds_read,
.write = ds_write,
.poll = ds_poll,
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 60fe266..038095d 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -623,7 +623,7 @@ static ssize_t wdt_read(struct file *file, char __user *buf,
* according to their available features. We only actually usefully support
* querying capabilities and current status.
*/
-static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+static int wdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int new_margin, rv;
@@ -676,6 +676,18 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
return -ENOTTY;
}

+static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = wdt_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
/**
* wdt_open:
* @inode: inode of device
@@ -736,7 +748,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
static const struct file_operations wdt_fops = {
.owner = THIS_MODULE,
.read = wdt_read,
- .ioctl = wdt_ioctl,
+ .unlocked_ioctl = wdt_unlocked_ioctl,
.write = wdt_write,
.open = wdt_open,
.release = wdt_release,
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index fc2f676..d53e62a 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -298,9 +298,9 @@ static int opromgetbootargs(void __user *argp, struct openpromio *op, int bufsiz
/*
* SunOS and Solaris /dev/openprom ioctl calls.
*/
-static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
- unsigned int cmd, unsigned long arg,
- struct device_node *dp)
+static long openprom_sunos_ioctl(struct file * file,
+ unsigned int cmd, unsigned long arg,
+ struct device_node *dp)
{
DATA *data = file->private_data;
struct openpromio *opp = NULL;
@@ -316,6 +316,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
if (bufsize < 0)
return bufsize;

+ lock_kernel();
+
switch (cmd) {
case OPROMGETOPT:
case OPROMGETPROP:
@@ -365,6 +367,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
}

kfree(opp);
+ unlock_kernel();
+
return error;
}

@@ -547,13 +551,14 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
return 0;
}

-static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
+static int openprom_bsd_ioctl(struct file * file,
unsigned int cmd, unsigned long arg)
{
DATA *data = (DATA *) file->private_data;
void __user *argp = (void __user *)arg;
int err;

+ lock_kernel();
switch (cmd) {
case OPIOCGET:
err = opiocget(argp, data);
@@ -570,10 +575,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
case OPIOCGETOPTNODE:
BUILD_BUG_ON(sizeof(phandle) != sizeof(int));

+ err = 0;
if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
- return -EFAULT;
-
- return 0;
+ err = -EFAULT;
+ break;

case OPIOCGETNEXT:
case OPIOCGETCHILD:
@@ -581,9 +586,10 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
break;

default:
- return -EINVAL;
-
+ err = -EINVAL;
+ break;
};
+ unlock_kernel();

return err;
}
@@ -592,8 +598,8 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
/*
* Handoff control to the correct ioctl handler.
*/
-static int openprom_ioctl(struct inode * inode, struct file * file,
- unsigned int cmd, unsigned long arg)
+static long openprom_ioctl(struct file * file,
+ unsigned int cmd, unsigned long arg)
{
DATA *data = (DATA *) file->private_data;

@@ -602,14 +608,14 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMNXTOPT:
if ((file->f_mode & FMODE_READ) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg,
+ return openprom_sunos_ioctl(file, cmd, arg,
options_node);

case OPROMSETOPT:
case OPROMSETOPT2:
if ((file->f_mode & FMODE_WRITE) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg,
+ return openprom_sunos_ioctl(file, cmd, arg,
options_node);

case OPROMNEXT:
@@ -618,7 +624,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMNXTPROP:
if ((file->f_mode & FMODE_READ) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg,
+ return openprom_sunos_ioctl(file, cmd, arg,
data->current_node);

case OPROMU2P:
@@ -630,7 +636,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPROMPATH2NODE:
if ((file->f_mode & FMODE_READ) == 0)
return -EPERM;
- return openprom_sunos_ioctl(inode, file, cmd, arg, NULL);
+ return openprom_sunos_ioctl(file, cmd, arg, NULL);

case OPIOCGET:
case OPIOCNEXTPROP:
@@ -639,12 +645,12 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
case OPIOCGETCHILD:
if ((file->f_mode & FMODE_READ) == 0)
return -EBADF;
- return openprom_bsd_ioctl(inode,file,cmd,arg);
+ return openprom_bsd_ioctl(file,cmd,arg);

case OPIOCSET:
if ((file->f_mode & FMODE_WRITE) == 0)
return -EBADF;
- return openprom_bsd_ioctl(inode,file,cmd,arg);
+ return openprom_bsd_ioctl(file,cmd,arg);

default:
return -EINVAL;
@@ -676,7 +682,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
case OPROMSETCUR:
case OPROMPCI2NODE:
case OPROMPATH2NODE:
- rval = openprom_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ rval = openprom_ioctl(file, cmd, arg);
break;
}

@@ -709,7 +715,7 @@ static int openprom_release(struct inode * inode, struct file * file)
static const struct file_operations openprom_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .ioctl = openprom_ioctl,
+ .unlocked_ioctl = openprom_ioctl,
.compat_ioctl = openprom_compat_ioctl,
.open = openprom_open,
.release = openprom_release,
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index ddf7f9a..5594772 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -954,8 +954,7 @@ static int mon_bin_queued(struct mon_reader_bin *rp)

/*
*/
-static int mon_bin_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static int mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct mon_reader_bin *rp = file->private_data;
// struct mon_bus* mbus = rp->r.m_bus;
@@ -1095,6 +1094,19 @@ static int mon_bin_ioctl(struct inode *inode, struct file *file,
return ret;
}

+static long mon_bin_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret;
+
+ lock_kernel();
+ ret = mon_bin_ioctl(file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+
+
#ifdef CONFIG_COMPAT
static long mon_bin_compat_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
@@ -1148,14 +1160,13 @@ static long mon_bin_compat_ioctl(struct file *file,
return 0;

case MON_IOCG_STATS:
- return mon_bin_ioctl(NULL, file, cmd,
- (unsigned long) compat_ptr(arg));
+ return mon_bin_ioctl(file, cmd, (unsigned long) compat_ptr(arg));

case MON_IOCQ_URB_LEN:
case MON_IOCQ_RING_SIZE:
case MON_IOCT_RING_SIZE:
case MON_IOCH_MFLUSH:
- return mon_bin_ioctl(NULL, file, cmd, arg);
+ return mon_bin_ioctl(file, cmd, arg);

default:
;
@@ -1239,7 +1250,7 @@ static const struct file_operations mon_fops_binary = {
.read = mon_bin_read,
/* .write = mon_text_write, */
.poll = mon_bin_poll,
- .ioctl = mon_bin_ioctl,
+ .unlocked_ioctl = mon_bin_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = mon_bin_compat_ioctl,
#endif
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 1becdc3..8ec94f1 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -11,6 +11,7 @@
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/fs.h>
+#include <linux/smp_lock.h>
#include <asm/uaccess.h>

#include "usb_mon.h"
@@ -63,6 +64,6 @@ const struct file_operations mon_fops_stat = {
.read = mon_stat_read,
/* .write = mon_stat_write, */
/* .poll = mon_stat_poll, */
- /* .ioctl = mon_stat_ioctl, */
+ /* .unlocked_ioctl = mon_stat_ioctl, */
.release = mon_stat_release,
};
--
1.7.0.4

2010-04-26 22:35:16

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal



On Tue, 27 Apr 2010, Frederic Weisbecker wrote:
>
> I've queued it for the next merge window in
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> bkl/ioctl

Btw, I hope you took the second version, that had the two additional fixes
from Arnd (and my expansion of his fix to au1550_ac97.c).

Looking at the arch code, I doubt there are any big architecture-specific
things. But there could easily be some other drivers like au1550_ac97.c
that only get enabled on certain architectures and missed the grepping for
some reason.

That said, because of Arnd's fix, I did end up grepping for
'file_operations' and old-style gcc initializers (ie "ioctl: xyz" rather
than the proper ".ioctl = xyz"), and the grep came up empty.

But it's possible that there's something hiding: with all of serial,
bluetooth, block drivers, sound, socket proto's and v4l2 each having their
own 'ioctl' pointers, it's not entirely trivial to grep for it all and be
sure..

So there might be one or two cases still hiding, but it looks unlikely.
And I'm almost certain that it definitely isn't more than just one or two.

Linus

2010-04-26 23:04:43

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Mon, Apr 26, 2010 at 03:32:51PM -0700, Linus Torvalds wrote:
>
>
> On Tue, 27 Apr 2010, Frederic Weisbecker wrote:
> >
> > I've queued it for the next merge window in
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
> > bkl/ioctl
>
> Btw, I hope you took the second version, that had the two additional fixes
> from Arnd (and my expansion of his fix to au1550_ac97.c).


Yeah.



> Looking at the arch code, I doubt there are any big architecture-specific
> things. But there could easily be some other drivers like au1550_ac97.c
> that only get enabled on certain architectures and missed the grepping for
> some reason.
>
> That said, because of Arnd's fix, I did end up grepping for
> 'file_operations' and old-style gcc initializers (ie "ioctl: xyz" rather
> than the proper ".ioctl = xyz"), and the grep came up empty.
>
> But it's possible that there's something hiding: with all of serial,
> bluetooth, block drivers, sound, socket proto's and v4l2 each having their
> own 'ioctl' pointers, it's not entirely trivial to grep for it all and be
> sure..
>
> So there might be one or two cases still hiding, but it looks unlikely.
> And I'm almost certain that it definitely isn't more than just one or two.


Ok, thanks.

2010-04-27 09:14:52

by John Kacur

[permalink] [raw]
Subject: Re: [PATCH 0/6] Push down BKL into device drivers



On Tue, 27 Apr 2010, Arnd Bergmann wrote:

> This is half the work of getting rid of the BKL in
> the ioctl file operation, the rest in arch/ and fs/
> still needs to be done, maybe two more hours of
> work (for someone else than me ;-)).
>
> Pushdown is straightforward. In many cases, it's
> rather obvious that the BKL is not needed at all,
> but let's not mix the removal with the pushdown.

Hi Arnd. These pushdowns conflicted with Linus's renaming.
In addition I found a few errors due to the change to
unlocked_ioctl.

I will resubmit fixes to these problems in a new mail.

Thanks

>
> Arnd Bergmann (6):
> dvb: push down BKL into ioctl functions
> scsi: push down BKL into ioctl functions
> isdn: push down BKL into ioctl functions
> staging: push down BKL into ioctl functions
> v4l: always use unlocked_ioctl
> drivers: push down BKL into various drivers
>
> drivers/block/pktcdvd.c | 13 ++++++--
> drivers/char/apm-emulation.c | 8 +++--
> drivers/char/applicom.c | 13 +++++---
> drivers/char/ds1620.c | 16 ++++++++-
> drivers/char/dtlk.c | 15 +++++----
> drivers/char/generic_nvram.c | 17 ++++++++--
> drivers/char/genrtc.c | 16 ++++++++-
> drivers/char/hpet.c | 14 +++++---
> drivers/char/i8k.c | 21 ++++++++++--
> drivers/char/ipmi/ipmi_devintf.c | 26 +++++++++++++---
> drivers/char/ipmi/ipmi_watchdog.c | 17 +++++++++-
> drivers/char/nvram.c | 10 ++++--
> drivers/char/nwflash.c | 7 +++-
> drivers/char/raw.c | 42 ++++++++++++++-----------
> drivers/hwmon/fschmd.c | 9 +++--
> drivers/hwmon/w83793.c | 10 ++++--
> drivers/input/misc/hp_sdc_rtc.c | 34 ++++++++++++++------
> drivers/isdn/capi/capi.c | 17 ++++++++--
> drivers/isdn/divert/divert_procfs.c | 19 ++++++++++--
> drivers/isdn/i4l/isdn_common.c | 18 +++++++++--
> drivers/isdn/mISDN/timerdev.c | 10 ++++--
> drivers/macintosh/nvram.c | 2 +-
> drivers/macintosh/via-pmu.c | 17 ++++++++--
> drivers/media/dvb/dvb-core/dmxdev.c | 31 +++++++++++++-----
> drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 17 +++++++---
> drivers/media/dvb/dvb-core/dvb_frontend.c | 30 +++++++++---------
> drivers/media/dvb/dvb-core/dvb_net.c | 15 +++++++--
> drivers/media/dvb/dvb-core/dvbdev.c | 17 +++++++----
> drivers/media/dvb/dvb-core/dvbdev.h | 11 ++----
> drivers/media/dvb/firewire/firedtv-ci.c | 5 +--
> drivers/media/dvb/ttpci/av7110.c | 4 +-
> drivers/media/dvb/ttpci/av7110_av.c | 8 ++--
> drivers/media/dvb/ttpci/av7110_ca.c | 5 +--
> drivers/media/video/v4l2-dev.c | 17 ++++++++--
> drivers/mtd/mtdchar.c | 19 ++++++++---
> drivers/pcmcia/pcmcia_ioctl.c | 17 ++++++++--
> drivers/rtc/rtc-m41t80.c | 16 ++++++++-
> drivers/sbus/char/openprom.c | 44 +++++++++++++++-----------
> drivers/scsi/3w-9xxx.c | 10 ++++--
> drivers/scsi/3w-sas.c | 7 +++-
> drivers/scsi/3w-xxxx.c | 10 ++++--
> drivers/scsi/aacraid/linit.c | 11 +++++--
> drivers/scsi/dpt_i2o.c | 20 ++++++++++--
> drivers/scsi/gdth.c | 20 +++++++++---
> drivers/scsi/megaraid.c | 20 ++++++++++--
> drivers/scsi/megaraid/megaraid_mm.c | 22 ++++++++++---
> drivers/scsi/osst.c | 14 ++++++--
> drivers/scsi/sg.c | 17 ++++++++--
> drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++--
> drivers/staging/dt3155/dt3155_drv.c | 24 +++++++++++----
> drivers/staging/poch/poch.c | 17 +++++++++-
> drivers/staging/vme/devices/vme_user.c | 18 +++++++++--
> drivers/usb/mon/mon_bin.c | 23 ++++++++++----
> drivers/usb/mon/mon_stat.c | 3 +-
> 54 files changed, 631 insertions(+), 245 deletions(-)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2010-04-27 09:25:57

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal


* Arnd Bergmann <[email protected]> wrote:

> On Monday 26 April 2010, Ingo Molnar wrote:
> > This could be done all automated for a hundred old drivers if need to be.
> > There would be no bkl_ioctl's left.
>
> I don't think it can be fully automated. [...]

Corner cases are not a problem as long as the risk of them going unnoticed is
lower than the risk of a manual conversion introducing bugs.

> [...] For the majority of the modules, your approach would work fine, but
> there are still the well-known pitfalls in corner cases:
>
> - recursive uses in functions outside of ioctl (possibly none left
> after the TTY layer is done, but who knows)

Not a problem even if there's any such usage left: lockdep will sort those out
very quickly.

> - lock-order problems with other mutexes (see DRM)

This too will be mapped out very quickly via lockdep.

> - code that depends on autorelease to allow one ioctl while another
> is sleeping. (a small number of drivers)

This is a real issue, and in fact it's an unknown: there may be an unknown
number of random sleep points within BKL codepaths that is being relied on in
creative ways.

Note that by introducing a mutex we (in most cases) make the locking
_stricter_, so the biggest risk from that is a lockup - which will be
debuggable via lockdep.

Ingo

2010-04-27 18:15:13

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 4/6] staging: push down BKL into ioctl functions

Hi Greg,


On Tue, Apr 27, 2010 at 12:24:03AM +0200, Arnd Bergmann wrote:
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++++++----
> drivers/staging/dt3155/dt3155_drv.c | 24 ++++++++++++++++++------
> drivers/staging/poch/poch.c | 17 +++++++++++++++--
> drivers/staging/vme/devices/vme_user.c | 18 +++++++++++++++---
> 4 files changed, 57 insertions(+), 15 deletions(-)


If you are fine with this patch, I think it would be better if
you get it in your tree.

Thanks.




>
> diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
> index 54bad65..3291e14 100644
> --- a/drivers/staging/crystalhd/crystalhd_lnx.c
> +++ b/drivers/staging/crystalhd/crystalhd_lnx.c
> @@ -16,6 +16,7 @@
> ***************************************************************************/
>
> #include <linux/version.h>
> +#include <linux/smp_lock.h>
> #include <linux/slab.h>
>
> #include "crystalhd_lnx.h"
> @@ -261,12 +262,12 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua,
> }
>
> /* API interfaces */
> -static int chd_dec_ioctl(struct inode *in, struct file *fd,
> - unsigned int cmd, unsigned long ua)
> +static long chd_dec_ioctl(struct file *fd, unsigned int cmd, unsigned long ua)
> {
> struct crystalhd_adp *adp = chd_get_adp();
> crystalhd_cmd_proc cproc;
> struct crystalhd_user *uc;
> + int ret;
>
> if (!adp || !fd) {
> BCMLOG_ERR("Invalid adp\n");
> @@ -279,13 +280,17 @@ static int chd_dec_ioctl(struct inode *in, struct file *fd,
> return -ENODATA;
> }
>
> + lock_kernel();
> cproc = crystalhd_get_cmd_proc(&adp->cmds, cmd, uc);
> if (!cproc) {
> BCMLOG_ERR("Unhandled command: %d\n", cmd);
> + unlock_kernel();
> return -EINVAL;
> }
>
> - return chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc);
> + ret = chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc);
> + unlock_kernel();
> + return ret;
> }
>
> static int chd_dec_open(struct inode *in, struct file *fd)
> @@ -345,7 +350,7 @@ static int chd_dec_close(struct inode *in, struct file *fd)
>
> static const struct file_operations chd_dec_fops = {
> .owner = THIS_MODULE,
> - .ioctl = chd_dec_ioctl,
> + .unlocked_ioctl = chd_dec_ioctl,
> .open = chd_dec_open,
> .release = chd_dec_close,
> };
> diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
> index e2c44ec..7e6095f 100644
> --- a/drivers/staging/dt3155/dt3155_drv.c
> +++ b/drivers/staging/dt3155/dt3155_drv.c
> @@ -63,6 +63,7 @@ extern void printques(int);
> #include <linux/types.h>
> #include <linux/poll.h>
> #include <linux/sched.h>
> +#include <linux/smp_lock.h>
>
> #include <asm/io.h>
> #include <asm/uaccess.h>
> @@ -835,6 +836,17 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
> return 0;
> }
>
> +static long
> +dt3155_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> +{
> + int ret;
> +
> + lock_kernel();
> + ret = dt3155_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
> + unlock_kernel();
> +
> + return ret;
> +}
>
> /*****************************************************
> * file operations supported by DT3155 driver
> @@ -842,12 +854,12 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait)
> * register_chrdev
> *****************************************************/
> static struct file_operations dt3155_fops = {
> - read: dt3155_read,
> - ioctl: dt3155_ioctl,
> - mmap: dt3155_mmap,
> - poll: dt3155_poll,
> - open: dt3155_open,
> - release: dt3155_close
> + .read = dt3155_read,
> + .unlocked_ioctl = dt3155_unlocked_ioctl,
> + .mmap = dt3155_mmap,
> + .poll = dt3155_poll,
> + .open = dt3155_open,
> + .release = dt3155_close
> };
>
>
> diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
> index f940a34..bf46e29 100644
> --- a/drivers/staging/poch/poch.c
> +++ b/drivers/staging/poch/poch.c
> @@ -16,6 +16,7 @@
> #include <linux/sysfs.h>
> #include <linux/poll.h>
> #include <linux/idr.h>
> +#include <linux/smp_lock.h>
> #include <linux/interrupt.h>
> #include <linux/init.h>
> #include <linux/ioctl.h>
> @@ -911,7 +912,7 @@ static unsigned int poch_poll(struct file *filp, poll_table *pt)
> return ret;
> }
>
> -static int poch_ioctl(struct inode *inode, struct file *filp,
> +static int poch_ioctl(struct file *filp,
> unsigned int cmd, unsigned long arg)
> {
> struct channel_info *channel = filp->private_data;
> @@ -1033,11 +1034,23 @@ static int poch_ioctl(struct inode *inode, struct file *filp,
> return 0;
> }
>
> +static long
> +poch_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> +{
> + int ret;
> +
> + lock_kernel();
> + ret = poch_ioctl(file, cmd, arg);
> + unlock_kernel();
> +
> + return ret;
> +}
> +
> static struct file_operations poch_fops = {
> .owner = THIS_MODULE,
> .open = poch_open,
> .release = poch_release,
> - .ioctl = poch_ioctl,
> + .poch_ioctl = poch_unlocked_ioctl,
> .poll = poch_poll,
> .mmap = poch_mmap
> };
> diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
> index 1ab9a98..bc16fc0 100644
> --- a/drivers/staging/vme/devices/vme_user.c
> +++ b/drivers/staging/vme/devices/vme_user.c
> @@ -31,6 +31,7 @@
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> #include <linux/syscalls.h>
> +#include <linux/smp_lock.h>
> #include <linux/types.h>
>
> #include <asm/io.h>
> @@ -130,8 +131,7 @@ static int vme_user_release(struct inode *, struct file *);
> static ssize_t vme_user_read(struct file *, char *, size_t, loff_t *);
> static ssize_t vme_user_write(struct file *, const char *, size_t, loff_t *);
> static loff_t vme_user_llseek(struct file *, loff_t, int);
> -static int vme_user_ioctl(struct inode *, struct file *, unsigned int,
> - unsigned long);
> +static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long);
>
> static int __init vme_user_probe(struct device *, int, int);
> static int __exit vme_user_remove(struct device *, int, int);
> @@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = {
> .read = vme_user_read,
> .write = vme_user_write,
> .llseek = vme_user_llseek,
> - .ioctl = vme_user_ioctl,
> + .unlocked_ioctl = vme_user_unlocked_ioctl,
> };
>
>
> @@ -555,6 +555,18 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
> return -EINVAL;
> }
>
> +static long
> +vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> +{
> + int ret;
> +
> + lock_kernel();
> + ret = vme_user_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
> + unlock_kernel();
> +
> + return ret;
> +}
> +
>
> /*
> * Unallocate a previously allocated buffer
> --
> 1.7.0.4
>

2010-04-27 18:43:48

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 4/6] staging: push down BKL into ioctl functions

On Tue, Apr 27, 2010 at 08:15:07PM +0200, Frederic Weisbecker wrote:
> Hi Greg,
>
>
> On Tue, Apr 27, 2010 at 12:24:03AM +0200, Arnd Bergmann wrote:
> > Signed-off-by: Arnd Bergmann <[email protected]>
> > ---
> > drivers/staging/crystalhd/crystalhd_lnx.c | 13 +++++++++----
> > drivers/staging/dt3155/dt3155_drv.c | 24 ++++++++++++++++++------
> > drivers/staging/poch/poch.c | 17 +++++++++++++++--
> > drivers/staging/vme/devices/vme_user.c | 18 +++++++++++++++---
> > 4 files changed, 57 insertions(+), 15 deletions(-)
>
>
> If you are fine with this patch, I think it would be better if
> you get it in your tree.

Ok, I'll queue it up (note, the poch driver is now gone in the staging
tree.)

thanks,

greg k-h

2010-04-28 13:21:19

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Tue, Apr 27, 2010 at 11:25:30AM +0200, Ingo Molnar wrote:
>
> * Arnd Bergmann <[email protected]> wrote:
>
> > On Monday 26 April 2010, Ingo Molnar wrote:
> > > This could be done all automated for a hundred old drivers if need to be.
> > > There would be no bkl_ioctl's left.
> >
> > I don't think it can be fully automated. [...]
>
> Corner cases are not a problem as long as the risk of them going unnoticed is
> lower than the risk of a manual conversion introducing bugs.
>
> > [...] For the majority of the modules, your approach would work fine, but
> > there are still the well-known pitfalls in corner cases:
> >
> > - recursive uses in functions outside of ioctl (possibly none left
> > after the TTY layer is done, but who knows)
>
> Not a problem even if there's any such usage left: lockdep will sort those out
> very quickly.
>
> > - lock-order problems with other mutexes (see DRM)
>
> This too will be mapped out very quickly via lockdep.


And the hung task detector too which is the last resort to detect
uncovered resource dependencies (was really useful for reiserfs).

But the problem is among those people who may use such ancient drivers,
I guess few of them will have those debug config enabled.

And because there are almost no testers of these drivers, nobody/few will ever
notice the problem.


> > - code that depends on autorelease to allow one ioctl while another
> > is sleeping. (a small number of drivers)
>
> This is a real issue, and in fact it's an unknown: there may be an unknown
> number of random sleep points within BKL codepaths that is being relied on in
> creative ways.
>
> Note that by introducing a mutex we (in most cases) make the locking
> _stricter_, so the biggest risk from that is a lockup - which will be
> debuggable via lockdep.


So, as explained above, lockdep won't even help here.

I mean, for callsites that are obvious, say when it is clear that
the bkl is leaf lock or doesn't introduce uncovered resource dependencies due
to non-release on sleep, we should do such conversion. And I guess most
drivers that use the bkl follow this scheme.

But for the others (rares I think), the operation looks unsafe to me.
If we don't have the hardware to test the driver, then lockdep and hung
task detectors are going to be useless.

That said, once we reach that point with 4 users of bkl remaining, may
be that will be time to buy such hardware for a symbolic $1 in obscure
places and do the tests. Or just git-rm if we are too lazy.

2010-04-28 13:37:23

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal


* Frederic Weisbecker <[email protected]> wrote:

> [...]
>
> That said, once we reach that point with 4 users of bkl remaining, may be
> that will be time to buy such hardware for a symbolic $1 in obscure places
> and do the tests. Or just git-rm if we are too lazy.

Precisely. Note that the actual value of BKL-covered code shrinks every time
we push the BKL out of commonly used code.

So even if there's still usage sites around, there will be a point where it
makes sense to just desupport it or do a final, crude conversion. If there are
no active users who are willing to help us debug potential bugs then there's
frankly no value in us being just as careful with those drivers as we are with
other, more commonly used code.

For the rest, lockdep & softlockup detector will be plenty enough to debug any
bugs that may slip through - just like you did it with ReiserFS.

Ingo

2010-04-28 14:05:45

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [GIT PULL v2] Preparation for BKL'ed ioctl removal

On Tuesday 27 April 2010, Ingo Molnar wrote:
> * Arnd Bergmann <[email protected]> wrote:
>
> > On Monday 26 April 2010, Ingo Molnar wrote:
> > > This could be done all automated for a hundred old drivers if need to be.
> > > There would be no bkl_ioctl's left.
> >
> > I don't think it can be fully automated. [...]
>
> Corner cases are not a problem as long as the risk of them going unnoticed is
> lower than the risk of a manual conversion introducing bugs.

I actually support your idea of automatic conversion of modules in the
way you lined out, but would not want to apply it to the entire kernel
at once, but only to modules that were manually inspected to be safe for
doing this.

This minimizes both the risk from corner cases and the risk from manual
conversion.

Arnd