mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Al Viro <viro@ZenIV.linux.org.uk>, Jan Blunck <jblunck@suse.de>,
	Ingo Molnar <mingo@elte.hu>, John Kacur <jkacur@redhat.com>
Subject: [GIT PULL v2] Preparation for BKL'ed ioctl removal
Date: Thu, 22 Apr 2010 02:48:02 +0200	[thread overview]
Message-ID: <1271897282-11207-1-git-send-regression-fweisbec@gmail.com> (raw)
In-Reply-To: <1271390201-20431-1-git-send-regression-fweisbec@gmail.com>

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 <arnd@arndb.de>
Date:   Thu Apr 1 14:42:38 2010 +0200

    vfs: Introduce CONFIG_BKL and deprecated_ioctl
    
    This is a preparation for the removal of the big kernel lock that
    introduces new interfaces for device drivers still using it.
    
    We can start marking those device drivers as 'depends on CONFIG_BKL'
    now, and make that symbol optional later, when the point has come
    at which we are able to build a kernel without the BKL.
    
    Similarly, device drivers that currently make use of the implicit
    BKL locking around the ioctl function can now get annotated by
    changing
    
    	.ioctl = foo_ioctl,
    
    to
    
    	.locked_ioctl = foo_ioctl,
    	.unlocked_ioctl = deprecated_ioctl,
    
    As soon as no driver remains using the old ioctl callback, it can
    get removed.
    
    [fweisbec: move config bkl from Kconfig.debug to Kconfig.locks,
    rename default_ioctl to deprecated_ioctl]
    
    v2: Remove default_llseek() declaration from smp_lock.h, we
    don't need to prepare it to be modularized right now.
    
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 6c75110..e6d6a75 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -58,6 +58,28 @@ static long vfs_ioctl(struct file *filp, unsigned int cmd,
 	return error;
 }
 
+#ifdef CONFIG_BKL
+/*
+ * deprecated_ioctl - call locked_ioctl with BKL held
+ *
+ * Setting only the ioctl operation but not unlocked_ioctl will become
+ * invalid in the future, all drivers that are not converted to unlocked_ioctl
+ * should set .unlocked_ioctl = deprecated_ioctl now.
+ */
+long deprecated_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+	int error = -ENOTTY;
+	if (filp->f_op->locked_ioctl) {
+		lock_kernel();
+		error = filp->f_op->locked_ioctl(filp->f_path.dentry->d_inode,
+						 filp, cmd, arg);
+		unlock_kernel();
+	}
+	return error;
+}
+EXPORT_SYMBOL_GPL(default_ioctl);
+#endif
+
 static int ioctl_fibmap(struct file *filp, int __user *p)
 {
 	struct address_space *mapping = filp->f_mapping;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 39d57bc..6b65b26 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1492,6 +1492,9 @@ struct file_operations {
 	int (*readdir) (struct file *, void *, filldir_t);
 	unsigned int (*poll) (struct file *, struct poll_table_struct *);
 	int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+#ifdef CONFIG_BKL
+	int (*locked_ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
+#endif
 	long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
 	long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
 	int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index 2ea1dd1..3ed34da 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -62,4 +62,7 @@ static inline void cycle_kernel_lock(void)
 #define kernel_locked()				1
 
 #endif /* CONFIG_LOCK_KERNEL */
+
+long deprecated_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
 #endif /* __LINUX_SMPLOCK_H */
diff --git a/kernel/Kconfig.locks b/kernel/Kconfig.locks
index 88c92fb..9a80413 100644
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -200,3 +200,13 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE
 
 config MUTEX_SPIN_ON_OWNER
 	def_bool SMP && !DEBUG_MUTEXES && !HAVE_DEFAULT_NO_SPIN_MUTEXES
+
+config BKL
+	def_bool y
+	help
+	  This is the traditional lock that is used in old code instead
+	  of proper locking. All drivers that use the BKL should depend
+	  on this symbol.
+	  This configuration option will become user-selectable in the
+	  future, as soon as it is possible to build a kernel without
+	  it.

  reply	other threads:[~2010-04-22  0:47 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16  3:56 [GIT PULL] " Frederic Weisbecker
2010-04-22  0:48 ` Frederic Weisbecker [this message]
2010-04-24 15:25   ` [GIT PULL v2] " Frederic Weisbecker
2010-04-24 18:36     ` Linus Torvalds
2010-04-24 18:47       ` Linus Torvalds
2010-04-24 19:54         ` Arnd Bergmann
2010-04-24 20:01           ` Linus Torvalds
2010-04-24 20:40             ` Arnd Bergmann
2010-04-24 22:15               ` Linus Torvalds
2010-04-25 17:39                 ` Frederic Weisbecker
2010-04-25 17:49                   ` Linus Torvalds
2010-04-25 18:05                     ` Frederic Weisbecker
2010-04-26  8:30                     ` Arnd Bergmann
2010-04-26 18:08                       ` Linus Torvalds
2010-04-26 19:12                         ` Arnd Bergmann
2010-04-26 20:36                           ` Linus Torvalds
2010-04-26 22:23                           ` [PATCH 0/6] Push down BKL into device drivers Arnd Bergmann
2010-04-27  9:14                             ` John Kacur
2010-04-26 22:24                           ` [PATCH 1/6] dvb: push down BKL into ioctl functions Arnd Bergmann
2010-04-26 22:24                           ` [PATCH 2/6] scsi: " Arnd Bergmann
2010-04-26 22:24                           ` [PATCH 3/6] isdn: " Arnd Bergmann
2010-04-26 22:24                           ` [PATCH 4/6] staging: " Arnd Bergmann
2010-04-27 18:15                             ` Frederic Weisbecker
2010-04-27 18:33                               ` Greg KH
2010-04-26 22:24                           ` [PATCH 5/6] v4l: always use unlocked_ioctl Arnd Bergmann
2010-04-26 22:24                           ` [PATCH 6/6] drivers: push down BKL into various drivers Arnd Bergmann
2010-04-26 20:42                         ` [GIT PULL v2] Preparation for BKL'ed ioctl removal David Miller
2010-04-26 22:09                           ` Frederic Weisbecker
2010-04-26 22:32                             ` Linus Torvalds
2010-04-26 23:04                               ` Frederic Weisbecker
2010-04-26  7:25                   ` Ingo Molnar
2010-04-26 11:29                     ` Arnd Bergmann
2010-04-27  9:25                       ` Ingo Molnar
2010-04-28 13:21                         ` Frederic Weisbecker
2010-04-28 13:37                           ` Ingo Molnar
2010-04-28 14:05                         ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1271897282-11207-1-git-send-regression-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=arnd@arndb.de \
    --cc=jblunck@suse.de \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome