Skip to contentSkip to conversation

Preparation for BKL'ed ioctl removal

GIT PULL In review Frederic Weisbecker 7 participants 36 messages Apr 16, 2010 – Apr 28, 2010

Subsystems (39)
lore
Share & tools
lore
#0 lore raw

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]

fs/ioctl.c +22 -0
index 6c75110..e6d6a75 100644
@@ -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;
include/linux/fs.h +3 -0
index 39d57bc..6b65b26 100644
@@ -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 *);
include/linux/smp_lock.h +4 -0
index 2ea1dd1..c8693e1 100644
@@ -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 */
kernel/Kconfig.locks +10 -0
index 88c92fb..9a80413 100644
@@ -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.
#1 lore raw

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.

fs/ioctl.c +22 -0
index 6c75110..e6d6a75 100644
@@ -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;
include/linux/fs.h +3 -0
index 39d57bc..6b65b26 100644
@@ -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 *);
include/linux/smp_lock.h +3 -0
index 2ea1dd1..3ed34da 100644
@@ -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 */
kernel/Kconfig.locks +10 -0
index 88c92fb..9a80413 100644
@@ -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.
#2 lore raw
Quoted 7 lines · Frederic Weisbecker

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

Quoted 7 lines

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.

#3 lore raw
Quoted 3 lines · Frederic Weisbecker

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

#4 lore raw
Quoted 5 lines · Linus Torvalds

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

maintainer
#5 lore raw
Quoted 12 lines · On Saturday 24 April 2010 20:47:17 Linus Torvalds wrote:
Quoted 5 lines · Linus Torvalds

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.

Quoted 6 lines

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

#6 lore raw
Quoted 4 lines · Arnd Bergmann

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

maintainer
#7 lore raw
Quoted 9 lines · On Saturday 24 April 2010 22:01:18 Linus Torvalds wrote:
Quoted 4 lines · Arnd Bergmann

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.

Quoted 11 lines

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.

Quoted 2 lines

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

#8 lore raw
Quoted 2 lines · Arnd Bergmann

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

#9 lore raw
Quoted 25 lines · Linus Torvalds
Quoted 2 lines · Arnd Bergmann

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.

Quoted 3 lines

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.

Quoted 3 lines

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?

#10 lore raw
Quoted 8 lines · Frederic Weisbecker

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

(quoted diff) +2 -1
-	.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

#11 lore raw
Quoted 50 lines · Linus Torvalds
Quoted 8 lines · Frederic Weisbecker

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

(quoted diff) +2 -1
-	.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.

Quoted 7 lines

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!

#30 lore raw
In reply to Frederic Weisbecker
Quoted 10 lines · Frederic Weisbecker
Quoted 3 lines

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.

Quoted 2 lines

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

maintainer
#12 lore raw
In reply to Linus Torvalds
Quoted 16 lines · 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) {
Quoted 8 lines
                        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

maintainer
#31 lore raw
In reply to Ingo Molnar
Quoted 2 lines · Ingo Molnar

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

Quoted 3 lines

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

#13 lore raw
In reply to Arnd Bergmann
Quoted 4 lines · Arnd Bergmann

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

---
 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(-)
arch/cris/arch-v10/drivers/ds1302.c +1 -1
index 77630df..a921861 100644
@@ -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. */
arch/cris/arch-v10/drivers/gpio.c +1 -1
index 4b0f65f..54db6cb 100644
@@ -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,
arch/cris/arch-v10/drivers/i2c.c +1 -1
index a8737a8..2e7eb8a 100644
@@ -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,
 };
arch/cris/arch-v10/drivers/pcf8563.c +1 -1
index 1e90c1a..1a1f0f3 100644
@@ -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
arch/cris/arch-v10/drivers/sync_serial.c +1 -1
index 109dcd8..04e7339 100644
@@ -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
 };
arch/cris/arch-v32/drivers/cryptocop.c +1 -1
index b70fb34..9022dae 100644
@@ -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
 };
 
 
arch/cris/arch-v32/drivers/i2c.c +1 -1
index 5068263..6cfe2cf 100644
@@ -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,
 };
arch/cris/arch-v32/drivers/mach-a3/gpio.c +1 -1
index 97357cf..0031713 100644
@@ -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,
arch/cris/arch-v32/drivers/mach-fs/gpio.c +1 -1
index d89ab80..72ffbfa 100644
@@ -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,
arch/cris/arch-v32/drivers/pcf8563.c +1 -1
index f447850..223081a 100644
@@ -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
arch/cris/arch-v32/drivers/sync_serial.c +1 -1
index 4889f19..8ce4f32 100644
@@ -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
 };
arch/ia64/kernel/perfmon.c +1 -1
index ab985f7..0c4326c 100644
@@ -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,
arch/ia64/sn/kernel/sn2/sn_hwperf.c +1 -1
index 55ac3c4..ffc65e1 100644
@@ -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 = {
arch/m68k/bvme6000/rtc.c +1 -1
index b46ea17..fb939c6 100644
@@ -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,
 };
arch/m68k/mvme16x/rtc.c +1 -1
index 8da9c25..9cebd9f 100644
@@ -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,
 };
arch/um/drivers/harddog_kern.c +1 -1
index d332503..6cb24a1 100644
@@ -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,
 };
arch/um/drivers/hostaudio_kern.c +2 -2
index 368219c..cbc7366 100644
@@ -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,
 };
arch/um/drivers/mmapper_kern.c +1 -1
index d22f9e5..50f7976 100644
@@ -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,
drivers/block/pktcdvd.c +1 -1
index ddf1942..d0bb5c7 100644
@@ -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,
 };
 
drivers/char/apm-emulation.c +1 -1
index 4f568cb..a7d3df3 100644
@@ -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,
 };
drivers/char/applicom.c +1 -1
index a7424bf..8a845bd 100644
@@ -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 = {
drivers/char/ds1620.c +1 -1
index 61f0146..de8f7ba 100644
@@ -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 = {
drivers/char/dtlk.c +1 -1
index 045c930..da15fb9 100644
@@ -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,
 };
drivers/char/generic_nvram.c +1 -1
index fda4181..0947ad9 100644
@@ -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 = {
drivers/char/genrtc.c +1 -1
index 31e7c91..414ca68 100644
@@ -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,
 };
drivers/char/hpet.c +1 -1
index 9ded667..09c33d1 100644
@@ -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,
drivers/char/i8k.c +1 -1
index fc8cf7a..2a211d5 100644
@@ -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 {
drivers/char/ipmi/ipmi_devintf.c +1 -1
index 65545de..57b2990 100644
@@ -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
drivers/char/ipmi/ipmi_watchdog.c +1 -1
index a4d57e3..e8d478e 100644
@@ -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,
drivers/char/nvram.c +1 -1
index 47e8f7b..2688c4e 100644
@@ -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,
 };
drivers/char/nwflash.c +1 -1
index f808109..636b9f8 100644
@@ -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 =
drivers/char/raw.c +2 -2
index 8756ab0..e0ece78 100644
@@ -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,
 };
drivers/hwmon/fschmd.c +1 -1
index 0627f7a..fa60ff2 100644
@@ -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,
 };
 
 
drivers/hwmon/w83793.c +1 -1
index 612807d..6f63623 100644
@@ -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,
 };
 
 /*
drivers/input/misc/hp_sdc_rtc.c +1 -1
index ad730e1..0fdfd20 100644
@@ -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,
 };
drivers/isdn/capi/capi.c +1 -1
index ee58375..6bc9766 100644
@@ -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,
 };
drivers/isdn/divert/divert_procfs.c +1 -1
index 9f49d90..ae0244f 100644
@@ -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,                                      
 };
drivers/isdn/i4l/isdn_common.c +1 -1
index 70044ee..08ba72d 100644
@@ -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,
 };
drivers/isdn/mISDN/timerdev.c +1 -1
index 8785004..fc7d777 100644
@@ -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,
 };
drivers/macintosh/nvram.c +1 -1
index c876349..6a3115f 100644
@@ -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 = {
drivers/macintosh/via-pmu.c +1 -1
index 4276484..1cac03c 100644
@@ -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,
 };
drivers/media/dvb/dvb-core/dmxdev.c +2 -2
index 9ddc579..a6c4f2f 100644
@@ -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,
drivers/media/dvb/dvb-core/dvb_ca_en50221.c +1 -1
index cb22da5..4609c7e 100644
@@ -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,
drivers/media/dvb/dvb-core/dvb_frontend.c +1 -1
index 55ea260..5ebf731 100644
@@ -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
drivers/media/dvb/dvb-core/dvb_net.c +1 -1
index 441c064..7ae8ef1 100644
@@ -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,
 };
drivers/media/dvb/firewire/firedtv-ci.c +1 -1
index 853e04b..9378618 100644
@@ -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,
drivers/media/dvb/ttpci/av7110.c +1 -1
index 3891559..0e606af 100644
@@ -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,
 };
drivers/media/dvb/ttpci/av7110_av.c +2 -2
index 5388481..62d3b1f 100644
@@ -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,
drivers/media/dvb/ttpci/av7110_ca.c +1 -1
index ac7779c..94e0668 100644
@@ -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,
drivers/media/video/v4l2-compat-ioctl32.c +3 -3
index f77f84b..befb4ea 100644
@@ -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) {
drivers/media/video/v4l2-dev.c +1 -1
index 7090699..c48143a 100644
@@ -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
drivers/mtd/mtdchar.c +1 -1
index 5b081cb..57b48c4 100644
@@ -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
drivers/pcmcia/pcmcia_ioctl.c +1 -1
index 104e73d..ca84016 100644
@@ -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,
drivers/rtc/rtc-m41t80.c +1 -1
index 60fe266..e662d61 100644
@@ -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,
drivers/sbus/char/openprom.c +1 -1
index fc2f676..1fdc1a9 100644
@@ -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,
drivers/scsi/3w-9xxx.c +1 -1
index e9788f5..32da0ef 100644
@@ -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
 };
drivers/scsi/3w-sas.c +1 -1
index 54c5ffb..3cac9e4 100644
@@ -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
 };
drivers/scsi/3w-xxxx.c +1 -1
index 5faf903..2713dd5 100644
@@ -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
 };
drivers/scsi/aacraid/linit.c +1 -1
index e9373a2..c2b037d 100644
@@ -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
drivers/scsi/dpt_i2o.c +1 -1
index 0435d04..6ec5682 100644
@@ -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
drivers/scsi/gdth.c +1 -1
index 35a4b30..69c1629 100644
@@ -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,
 };
drivers/scsi/megaraid.c +1 -1
index 4bf7edc..49a3501 100644
@@ -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,
 };
 
drivers/scsi/megaraid/megaraid_mm.c +1 -1
index 36e0b7d..9bd7787 100644
@@ -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
drivers/scsi/osst.c +1 -1
index b219118..a1a78bb 100644
@@ -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
drivers/scsi/sg.c +1 -1
index dee1c96..93d043e 100644
@@ -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
drivers/staging/crystalhd/crystalhd_lnx.c +1 -1
index 54bad65..3d6b773 100644
@@ -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,
 };
drivers/staging/dt3155/dt3155_drv.c +2 -2
index e2c44ec..09fb197 100644
@@ -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
 };
drivers/staging/poch/poch.c +1 -1
index f940a34..edc8c58 100644
@@ -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
 };
drivers/staging/vme/devices/vme_user.c +1 -1
index 1ab9a98..7ba7149 100644
@@ -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,
 };
 
 
drivers/usb/mon/mon_bin.c +1 -1
index ddf7f9a..9ce7c74 100644
@@ -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
drivers/usb/mon/mon_stat.c +1 -1
index 1becdc3..091e7fb 100644
@@ -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,
 };
fs/autofs/root.c +1 -1
index 8713c7c..b838f68 100644
@@ -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 = {
fs/autofs4/root.c +1 -1
index 109a6c6..e764eb1 100644
@@ -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 = {
fs/bad_inode.c +1 -1
index a05287a..3fd4ada 100644
@@ -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,
fs/coda/pioctl.c +1 -1
index 773f2ce..72184f0 100644
@@ -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 */
fs/coda/psdev.c +1 -1
index be4392c..70a98a8 100644
@@ -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,
 };
fs/compat_ioctl.c +1 -1
index c32a1b6..3561d04 100644
@@ -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;
 	}
fs/ecryptfs/file.c +5 -4
index e7440a6..a5fa728 100644
@@ -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;
fs/fat/dir.c +1 -1
index 530b4ca..f5473d4 100644
@@ -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
fs/fat/file.c +1 -1
index e8c159d..1ddabe7 100644
@@ -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,
 };
fs/hfsplus/dir.c +1 -1
index 5f40236..d30ab33 100644
@@ -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,
 };
fs/hfsplus/inode.c +1 -1
index 1bcf597..c0a5c46 100644
@@ -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)
fs/ioctl.c +2 -2
index 7faefb4..921f727 100644
@@ -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();
 	}
fs/logfs/dir.c +1 -1
index 2396a85..02e7719 100644
@@ -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,
 };
fs/logfs/file.c +1 -1
index 370f367..4618614 100644
@@ -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,
fs/ncpfs/dir.c +1 -1
index 7edfcd4..ba898f9 100644
@@ -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
fs/ncpfs/file.c +1 -1
index 1daabb9..1138914 100644
@@ -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
fs/ntfs/dir.c +1 -1
index fe44d3f..8cf00ab 100644
@@ -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. */
 };
fs/ntfs/file.c +1 -1
index 8804f09..50a7f6d 100644
@@ -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. */
fs/proc/inode.c +4 -4
index d35b232..8e8f813 100644
@@ -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();
 	}
 
fs/smbfs/dir.c +1 -1
index 3e4803b..a2eac18 100644
@@ -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,
 };
 
fs/smbfs/file.c +1 -1
index dbf6548..dbdb834 100644
@@ -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,
fs/udf/dir.c +1 -1
index f0f2a43..d4f8f0c 100644
@@ -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,
 };
fs/udf/file.c +1 -1
index 4b6a46c..443066b 100644
@@ -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,
include/linux/fs.h +1 -1
index 44f35ae..1a82f78 100644
@@ -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 *);
net/sunrpc/cache.c +2 -2
index 39bddba..278deab 100644
@@ -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,
 };
net/sunrpc/rpc_pipe.c +1 -1
index 20e30c6..b6dd719 100644
@@ -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,
 };
sound/oss/dmasound/dmasound_core.c +2 -2
index 3f3c3f7..3c43220 100644
@@ -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,
 };
sound/oss/msnd_pinnacle.c +1 -1
index a1e3f96..0070ddc 100644
@@ -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,
 };
sound/oss/sh_dac_audio.c +1 -1
index 4153752..c21d1da 100644
@@ -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,
 };
sound/oss/swarm_cs4297a.c +2 -2
index 3136c88..57006ae 100644
@@ -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,
sound/oss/vwsnd.c +2 -2
index 20b3b32..300720c 100644
@@ -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,
 };
maintainer
#14 lore raw
Quoted 1 line · 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.

Quoted 3 lines

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.

Quoted 1 line

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.

Documentation/filesystems/vfs.txt +1 -1
index 3de2f32..4890683 100644
@@ -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 *);
sound/oss/au1550_ac97.c +5 -5
index c1070e3..7295781 100644
@@ -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
#15 lore raw
Quoted 6 lines · Arnd Bergmann

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

Quoted 5 lines
Quoted 1 line

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 ]

---
 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(-)
Documentation/filesystems/vfs.txt +1 -1
index 3de2f32..4890683 100644
@@ -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 *);
arch/cris/arch-v10/drivers/ds1302.c +1 -1
index 77630df..a921861 100644
@@ -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. */
arch/cris/arch-v10/drivers/gpio.c +1 -1
index 4b0f65f..54db6cb 100644
@@ -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,
arch/cris/arch-v10/drivers/i2c.c +1 -1
index a8737a8..2e7eb8a 100644
@@ -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,
 };
arch/cris/arch-v10/drivers/pcf8563.c +1 -1
index 1e90c1a..1a1f0f3 100644
@@ -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
arch/cris/arch-v10/drivers/sync_serial.c +1 -1
index 109dcd8..04e7339 100644
@@ -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
 };
arch/cris/arch-v32/drivers/cryptocop.c +1 -1
index b70fb34..9022dae 100644
@@ -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
 };
 
 
arch/cris/arch-v32/drivers/i2c.c +1 -1
index 5068263..6cfe2cf 100644
@@ -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,
 };
arch/cris/arch-v32/drivers/mach-a3/gpio.c +1 -1
index 97357cf..0031713 100644
@@ -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,
arch/cris/arch-v32/drivers/mach-fs/gpio.c +1 -1
index d89ab80..72ffbfa 100644
@@ -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,
arch/cris/arch-v32/drivers/pcf8563.c +1 -1
index f447850..223081a 100644
@@ -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
arch/cris/arch-v32/drivers/sync_serial.c +1 -1
index 4889f19..8ce4f32 100644
@@ -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
 };
arch/ia64/kernel/perfmon.c +1 -1
index ab985f7..0c4326c 100644
@@ -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,
arch/ia64/sn/kernel/sn2/sn_hwperf.c +1 -1
index 55ac3c4..ffc65e1 100644
@@ -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 = {
arch/m68k/bvme6000/rtc.c +1 -1
index b46ea17..fb939c6 100644
@@ -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,
 };
arch/m68k/mvme16x/rtc.c +1 -1
index 8da9c25..9cebd9f 100644
@@ -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,
 };
arch/um/drivers/harddog_kern.c +1 -1
index d332503..6cb24a1 100644
@@ -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,
 };
arch/um/drivers/hostaudio_kern.c +2 -2
index 368219c..cbc7366 100644
@@ -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,
 };
arch/um/drivers/mmapper_kern.c +1 -1
index d22f9e5..50f7976 100644
@@ -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,
drivers/block/pktcdvd.c +1 -1
index ddf1942..d0bb5c7 100644
@@ -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,
 };
 
drivers/char/apm-emulation.c +1 -1
index 4f568cb..a7d3df3 100644
@@ -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,
 };
drivers/char/applicom.c +1 -1
index a7424bf..8a845bd 100644
@@ -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 = {
drivers/char/ds1620.c +1 -1
index 61f0146..de8f7ba 100644
@@ -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 = {
drivers/char/dtlk.c +1 -1
index 045c930..da15fb9 100644
@@ -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,
 };
drivers/char/generic_nvram.c +1 -1
index fda4181..0947ad9 100644
@@ -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 = {
drivers/char/genrtc.c +1 -1
index 31e7c91..414ca68 100644
@@ -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,
 };
drivers/char/hpet.c +1 -1
index 9ded667..09c33d1 100644
@@ -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,
drivers/char/i8k.c +1 -1
index fc8cf7a..2a211d5 100644
@@ -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 {
drivers/char/ipmi/ipmi_devintf.c +1 -1
index 65545de..57b2990 100644
@@ -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
drivers/char/ipmi/ipmi_watchdog.c +1 -1
index a4d57e3..e8d478e 100644
@@ -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,
drivers/char/nvram.c +1 -1
index 47e8f7b..2688c4e 100644
@@ -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,
 };
drivers/char/nwflash.c +1 -1
index f808109..636b9f8 100644
@@ -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 =
drivers/char/raw.c +2 -2
index 8756ab0..e0ece78 100644
@@ -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,
 };
drivers/hwmon/fschmd.c +1 -1
index 0627f7a..fa60ff2 100644
@@ -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,
 };
 
 
drivers/hwmon/w83793.c +1 -1
index 612807d..6f63623 100644
@@ -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,
 };
 
 /*
drivers/input/misc/hp_sdc_rtc.c +1 -1
index ad730e1..0fdfd20 100644
@@ -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,
 };
drivers/isdn/capi/capi.c +1 -1
index ee58375..6bc9766 100644
@@ -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,
 };
drivers/isdn/divert/divert_procfs.c +1 -1
index 9f49d90..ae0244f 100644
@@ -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,                                      
 };
drivers/isdn/i4l/isdn_common.c +1 -1
index 70044ee..08ba72d 100644
@@ -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,
 };
drivers/isdn/mISDN/timerdev.c +1 -1
index 8785004..fc7d777 100644
@@ -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,
 };
drivers/macintosh/nvram.c +1 -1
index c876349..6a3115f 100644
@@ -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 = {
drivers/macintosh/via-pmu.c +1 -1
index 4276484..1cac03c 100644
@@ -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,
 };
drivers/media/dvb/dvb-core/dmxdev.c +2 -2
index 9ddc579..a6c4f2f 100644
@@ -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,
drivers/media/dvb/dvb-core/dvb_ca_en50221.c +1 -1
index cb22da5..4609c7e 100644
@@ -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,
drivers/media/dvb/dvb-core/dvb_frontend.c +1 -1
index 55ea260..5ebf731 100644
@@ -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
drivers/media/dvb/dvb-core/dvb_net.c +1 -1
index 441c064..7ae8ef1 100644
@@ -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,
 };
drivers/media/dvb/firewire/firedtv-ci.c +1 -1
index 853e04b..9378618 100644
@@ -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,
drivers/media/dvb/ttpci/av7110.c +1 -1
index 3891559..0e606af 100644
@@ -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,
 };
drivers/media/dvb/ttpci/av7110_av.c +2 -2
index 5388481..62d3b1f 100644
@@ -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,
drivers/media/dvb/ttpci/av7110_ca.c +1 -1
index ac7779c..94e0668 100644
@@ -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,
drivers/media/video/v4l2-compat-ioctl32.c +3 -3
index f77f84b..befb4ea 100644
@@ -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) {
drivers/media/video/v4l2-dev.c +1 -1
index 7090699..c48143a 100644
@@ -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
drivers/mtd/mtdchar.c +1 -1
index 5b081cb..57b48c4 100644
@@ -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
drivers/pcmcia/pcmcia_ioctl.c +1 -1
index 104e73d..ca84016 100644
@@ -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,
drivers/rtc/rtc-m41t80.c +1 -1
index 60fe266..e662d61 100644
@@ -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,
drivers/sbus/char/openprom.c +1 -1
index fc2f676..1fdc1a9 100644
@@ -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,
drivers/scsi/3w-9xxx.c +1 -1
index e9788f5..32da0ef 100644
@@ -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
 };
drivers/scsi/3w-sas.c +1 -1
index 54c5ffb..3cac9e4 100644
@@ -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
 };
drivers/scsi/3w-xxxx.c +1 -1
index 5faf903..2713dd5 100644
@@ -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
 };
drivers/scsi/aacraid/linit.c +1 -1
index e9373a2..c2b037d 100644
@@ -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
drivers/scsi/dpt_i2o.c +1 -1
index 0435d04..6ec5682 100644
@@ -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
drivers/scsi/gdth.c +1 -1
index 35a4b30..69c1629 100644
@@ -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,
 };
drivers/scsi/megaraid.c +1 -1
index 4bf7edc..49a3501 100644
@@ -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,
 };
 
drivers/scsi/megaraid/megaraid_mm.c +1 -1
index 36e0b7d..9bd7787 100644
@@ -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
drivers/scsi/osst.c +1 -1
index b219118..a1a78bb 100644
@@ -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
drivers/scsi/sg.c +1 -1
index dee1c96..93d043e 100644
@@ -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
drivers/staging/crystalhd/crystalhd_lnx.c +1 -1
index 54bad65..3d6b773 100644
@@ -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,
 };
drivers/staging/dt3155/dt3155_drv.c +2 -2
index e2c44ec..09fb197 100644
@@ -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
 };
drivers/staging/poch/poch.c +1 -1
index f940a34..edc8c58 100644
@@ -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
 };
drivers/staging/vme/devices/vme_user.c +1 -1
index 1ab9a98..7ba7149 100644
@@ -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,
 };
 
 
drivers/usb/mon/mon_bin.c +1 -1
index ddf7f9a..9ce7c74 100644
@@ -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
drivers/usb/mon/mon_stat.c +1 -1
index 1becdc3..091e7fb 100644
@@ -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,
 };
fs/autofs/root.c +1 -1
index 8713c7c..b838f68 100644
@@ -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 = {
fs/autofs4/root.c +1 -1
index 109a6c6..e764eb1 100644
@@ -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 = {
fs/bad_inode.c +1 -1
index a05287a..3fd4ada 100644
@@ -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,
fs/coda/pioctl.c +1 -1
index 773f2ce..72184f0 100644
@@ -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 */
fs/coda/psdev.c +1 -1
index be4392c..70a98a8 100644
@@ -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,
 };
fs/compat_ioctl.c +1 -1
index c32a1b6..3561d04 100644
@@ -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;
 	}
fs/ecryptfs/file.c +5 -4
index e7440a6..a5fa728 100644
@@ -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;
fs/fat/dir.c +1 -1
index 530b4ca..f5473d4 100644
@@ -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
fs/fat/file.c +1 -1
index e8c159d..1ddabe7 100644
@@ -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,
 };
fs/hfsplus/dir.c +1 -1
index 5f40236..d30ab33 100644
@@ -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,
 };
fs/hfsplus/inode.c +1 -1
index 1bcf597..c0a5c46 100644
@@ -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)
fs/ioctl.c +2 -2
index 7faefb4..921f727 100644
@@ -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();
 	}
fs/logfs/dir.c +1 -1
index 2396a85..02e7719 100644
@@ -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,
 };
fs/logfs/file.c +1 -1
index 370f367..4618614 100644
@@ -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,
fs/ncpfs/dir.c +1 -1
index 7edfcd4..ba898f9 100644
@@ -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
fs/ncpfs/file.c +1 -1
index 1daabb9..1138914 100644
@@ -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
fs/ntfs/dir.c +1 -1
index fe44d3f..8cf00ab 100644
@@ -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. */
 };
fs/ntfs/file.c +1 -1
index 8804f09..50a7f6d 100644
@@ -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. */
fs/proc/inode.c +4 -4
index d35b232..8e8f813 100644
@@ -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();
 	}
 
fs/smbfs/dir.c +1 -1
index 3e4803b..a2eac18 100644
@@ -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,
 };
 
fs/smbfs/file.c +1 -1
index dbf6548..dbdb834 100644
@@ -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,
fs/udf/dir.c +1 -1
index f0f2a43..d4f8f0c 100644
@@ -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,
 };
fs/udf/file.c +1 -1
index 4b6a46c..443066b 100644
@@ -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,
include/linux/fs.h +1 -1
index 44f35ae..1a82f78 100644
@@ -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 *);
net/sunrpc/cache.c +2 -2
index 39bddba..278deab 100644
@@ -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,
 };
net/sunrpc/rpc_pipe.c +1 -1
index 20e30c6..b6dd719 100644
@@ -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,
 };
sound/oss/au1550_ac97.c +14 -14
index c1070e3..2280ef7 100644
@@ -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]");
sound/oss/dmasound/dmasound_core.c +2 -2
index 3f3c3f7..3c43220 100644
@@ -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,
 };
sound/oss/msnd_pinnacle.c +1 -1
index a1e3f96..0070ddc 100644
@@ -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,
 };
sound/oss/sh_dac_audio.c +1 -1
index 4153752..c21d1da 100644
@@ -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,
 };
sound/oss/swarm_cs4297a.c +2 -2
index 3136c88..57006ae 100644
@@ -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,
sound/oss/vwsnd.c +2 -2
index 20b3b32..300720c 100644
@@ -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,
 };
maintainer
#26 lore raw
In reply to Linus Torvalds

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

Quoted 3 lines

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

#27 lore raw
Quoted 8 lines · David Miller

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

Quoted 3 lines

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

maintainer
#21 lore raw

PATCH 4/6 staging: push down BKL into ioctl functions

In reply to Arnd Bergmann
---
 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(-)
drivers/staging/crystalhd/crystalhd_lnx.c +9 -4
index 54bad65..3291e14 100644
@@ -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,
 };
drivers/staging/dt3155/dt3155_drv.c +18 -6
index e2c44ec..7e6095f 100644
@@ -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
 };
 
 
drivers/staging/poch/poch.c +15 -2
index f940a34..bf46e29 100644
@@ -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
 };
drivers/staging/vme/devices/vme_user.c +15 -3
index 1ab9a98..bc16fc0 100644
@@ -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
Signature · 1 line
1.7.0.4
maintainer
#18 lore raw

PATCH 3/6 isdn: push down BKL into ioctl functions

In reply to Arnd Bergmann
---
 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(-)
drivers/isdn/capi/capi.c +14 -3
index ee58375..0cabe31 100644
@@ -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,
 };
drivers/isdn/divert/divert_procfs.c +16 -3
index 9f49d90..8084557 100644
@@ -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,                                      
 };
drivers/isdn/i4l/isdn_common.c +15 -3
index 70044ee..a44cdb4 100644
@@ -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,
 };
drivers/isdn/mISDN/timerdev.c +6 -4
index 8785004..c3243c9 100644
@@ -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,
 };
Signature · 1 line
1.7.0.4
maintainer
#17 lore raw

PATCH 2/6 scsi: push down BKL into ioctl functions

In reply to Arnd Bergmann
---
 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(-)
drivers/scsi/3w-9xxx.c +7 -3
index e9788f5..4f74850 100644
@@ -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() */
 
drivers/scsi/3w-sas.c +5 -2
index 54c5ffb..ab4ad09 100644
@@ -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
 };
drivers/scsi/3w-xxxx.c +7 -3
index 5faf903..45a737c 100644
@@ -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
 };
drivers/scsi/aacraid/linit.c +8 -3
index e9373a2..33898b6 100644
@@ -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
drivers/scsi/dpt_i2o.c +17 -3
index 0435d04..b0c576f 100644
@@ -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)
drivers/scsi/gdth.c +15 -5
index 35a4b30..d3f335d 100644
@@ -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)
drivers/scsi/megaraid.c +17 -3
index 4bf7edc..c20b621 100644
@@ -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
drivers/scsi/megaraid/megaraid_mm.c +17 -5
index 36e0b7d..41f82f7 100644
@@ -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;
 }
drivers/scsi/osst.c +10 -4
index b219118..8dbf1c3 100644
@@ -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
drivers/scsi/sg.c +14 -3
index dee1c96..ef752b2 100644
@@ -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
Signature · 1 line
1.7.0.4
maintainer
#19 lore raw

cover Push down BKL into device drivers

In reply to Arnd Bergmann

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(-)
maintainer
#16 lore raw

PATCH 1/6 dvb: push down BKL into ioctl functions

In reply to Arnd Bergmann

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

---
 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(-)
drivers/media/dvb/dvb-core/dmxdev.c +22 -9
index 9ddc579..425862f 100644
@@ -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,
drivers/media/dvb/dvb-core/dvb_ca_en50221.c +12 -5
index cb22da5..ef259a0 100644
@@ -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,
drivers/media/dvb/dvb-core/dvb_frontend.c +15 -15
index 55ea260..5450d1f 100644
@@ -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
drivers/media/dvb/dvb-core/dvb_net.c +11 -4
index 441c064..a96eee3 100644
@@ -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,
 };
drivers/media/dvb/dvb-core/dvbdev.c +11 -6
index 94159b9..b915c39 100644
@@ -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)
drivers/media/dvb/dvb-core/dvbdev.h +4 -7
index f7b499d..fcc6ae9 100644
@@ -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
drivers/media/dvb/firewire/firedtv-ci.c +2 -3
index 853e04b..d3c2cf6 100644
@@ -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,
drivers/media/dvb/ttpci/av7110.c +2 -2
index 3891559..a6be529 100644
@@ -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,
 };
drivers/media/dvb/ttpci/av7110_av.c +4 -4
index 5388481..13efba9 100644
@@ -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,
drivers/media/dvb/ttpci/av7110_ca.c +2 -3
index ac7779c..4eba35a 100644
@@ -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,
Signature · 1 line
1.7.0.4
maintainer
#24 lore raw

PATCH 5/6 v4l: always use unlocked_ioctl

In reply to Arnd Bergmann

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.

---
 drivers/media/video/v4l2-dev.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
drivers/media/video/v4l2-dev.c +14 -3
index 7090699..3606694 100644
@@ -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
Signature · 1 line
1.7.0.4
maintainer
#25 lore raw

PATCH 6/6 drivers: push down BKL into various drivers

In reply to Arnd Bergmann

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

---
 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(-)
drivers/block/pktcdvd.c +10 -3
index ddf1942..84a5658 100644
@@ -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 = {
drivers/char/apm-emulation.c +5 -3
index 4f568cb..033e150 100644
@@ -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,
 };
drivers/char/applicom.c +8 -5
index a7424bf..63313a3 100644
@@ -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;
 }
 
drivers/char/ds1620.c +14 -2
index 61f0146..dbee868 100644
@@ -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 = {
drivers/char/dtlk.c +8 -7
index 045c930..e3859d4 100644
@@ -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;
drivers/char/generic_nvram.c +14 -3
index fda4181..82b5a88 100644
@@ -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 = {
drivers/char/genrtc.c +14 -2
index 31e7c91..b6c2cc1 100644
@@ -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,
 };
drivers/char/hpet.c +9 -5
index 9ded667..a0a1829 100644
@@ -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,
drivers/char/i8k.c +17 -4
index fc8cf7a..3dc67ae 100644
@@ -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.
  */
drivers/char/ipmi/ipmi_devintf.c +21 -5
index 65545de..d8ec92a 100644
@@ -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
drivers/char/ipmi/ipmi_watchdog.c +15 -2
index a4d57e3..82bcdb2 100644
@@ -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,
drivers/char/nvram.c +7 -3
index 47e8f7b..66d2917 100644
@@ -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,
 };
drivers/char/nwflash.c +5 -2
index f808109..043a1c7 100644
@@ -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 =
drivers/char/raw.c +24 -18

75 lines not on this page · raw message

drivers/hwmon/fschmd.c +5 -4
index 0627f7a..b7ca2a9 100644
@@ -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,
 };
 
 
drivers/hwmon/w83793.c +6 -4
index 612807d..697202e 100644
@@ -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,
 };
 
 /*
drivers/input/misc/hp_sdc_rtc.c +24 -10
index ad730e1..e00a1cc 100644
@@ -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 = {
drivers/macintosh/nvram.c +1 -1
index c876349..a271c82 100644
@@ -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 = {
drivers/macintosh/via-pmu.c +14 -3
index 4276484..3d4fc0f 100644
@@ -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,
 };
drivers/mtd/mtdchar.c +14 -5
index 5b081cb..6749c2f 100644
@@ -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
drivers/pcmcia/pcmcia_ioctl.c +14 -3
index 104e73d..a3b1b5b 100644
@@ -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,
drivers/rtc/rtc-m41t80.c +14 -2
index 60fe266..038095d 100644
@@ -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,
drivers/sbus/char/openprom.c +25 -19

140 lines not on this page · raw message

drivers/usb/mon/mon_bin.c +17 -6
index ddf7f9a..5594772 100644
@@ -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
drivers/usb/mon/mon_stat.c +2 -1
index 1becdc3..8ec94f1 100644
@@ -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,
 };
Signature · 1 line
1.7.0.4
#28 lore raw
In reply to Frederic Weisbecker
Quoted 5 lines · Frederic Weisbecker

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

#29 lore raw
Quoted 11 lines · Linus Torvalds
Quoted 5 lines · Frederic Weisbecker

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.

Quoted 9 lines

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.

Quoted 7 lines

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.

#20 lore raw

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

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

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

Quoted 71 lines

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/

#32 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann
Quoted 2 lines · Ingo Molnar

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.

Quoted 5 lines

[...] 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.

Quoted 1 line

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

This too will be mapped out very quickly via lockdep.

Quoted 2 lines

- 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

#22 lore raw

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

In reply to Arnd Bergmann

Hi Greg,

Quoted 7 lines · Arnd Bergmann
---
 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.

Quoted 204 lines
drivers/staging/crystalhd/crystalhd_lnx.c +9 -4
index 54bad65..3291e14 100644
@@ -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,
 };
drivers/staging/dt3155/dt3155_drv.c +18 -6
index e2c44ec..7e6095f 100644
@@ -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
 };
 
 
drivers/staging/poch/poch.c +15 -2
index f940a34..bf46e29 100644
@@ -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
 };
drivers/staging/vme/devices/vme_user.c +15 -3
index 1ab9a98..bc16fc0 100644
@@ -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
Signature · 1 line
1.7.0.4
#23 lore raw

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

Quoted 13 lines · Frederic Weisbecker

Hi Greg,

Quoted 7 lines · Arnd Bergmann
---
 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(-)
Quoted 2 lines

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

#33 lore raw
In reply to Ingo Molnar
Quoted 18 lines · Ingo Molnar
Quoted 5 lines · Arnd Bergmann
Quoted 2 lines · Ingo Molnar

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.

Quoted 5 lines

[...] 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)

Quoted 6 lines

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

Quoted 1 line

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

Quoted 10 lines
Quoted 2 lines

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

#34 lore raw
Quoted 5 lines · Frederic Weisbecker

[...]

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

maintainer
#35 lore raw
In reply to Ingo Molnar
Quoted 10 lines · Ingo Molnar
Quoted 5 lines · Arnd Bergmann
Quoted 2 lines · Ingo Molnar

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