ncpfs: BKL ioctl pushdown
authorJohn Kacur <jkacur@redhat.com>
Wed, 5 May 2010 13:15:37 +0000 (15:15 +0200)
committerFrederic Weisbecker <fweisbec@gmail.com>
Mon, 17 May 2010 03:27:42 +0000 (05:27 +0200)
Convert ncp_ioctl to an unlocked_ioctl and push down the bkl into it.

Signed-off-by: John Kacur <jkacur@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Petr Vandrovec <vandrove@vc.cvut.cz>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
fs/ncpfs/dir.c
fs/ncpfs/file.c
fs/ncpfs/ioctl.c
include/linux/ncp_fs.h

index 7edfcd4d5e524b5ad1ace0f64a11f508437ef5c9..92dde6f8d893b51a254e258dfd8942039a95ada6 100644 (file)
@@ -51,7 +51,7 @@ const struct file_operations ncp_dir_operations =
 {
        .read           = generic_read_dir,
        .readdir        = ncp_readdir,
-       .ioctl          = ncp_ioctl,
+       .unlocked_ioctl = ncp_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = ncp_compat_ioctl,
 #endif
index 1daabb90e0a54bba1a3c65146fb7098b3fdb8218..b93870892892126ec4926fe59f396989f636745a 100644 (file)
@@ -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,
+       .unlocked_ioctl = ncp_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = ncp_compat_ioctl,
 #endif
index 60a5e2864ea8b9b97e41de53875480959e17400f..023c03d020707a88e5930b8d92d89ce2c5845d20 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
+#include <linux/smp_lock.h>
 
 #include <linux/ncp_fs.h>
 
@@ -261,9 +262,9 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
 }
 #endif /* CONFIG_NCPFS_NLS */
 
-static int __ncp_ioctl(struct inode *inode, struct file *filp,
-             unsigned int cmd, unsigned long arg)
+static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+       struct inode *inode = filp->f_dentry->d_inode;
        struct ncp_server *server = NCP_SERVER(inode);
        int result;
        struct ncp_ioctl_request request;
@@ -841,11 +842,11 @@ static int ncp_ioctl_need_write(unsigned int cmd)
        }
 }
 
-int ncp_ioctl(struct inode *inode, struct file *filp,
-             unsigned int cmd, unsigned long arg)
+long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
-       int ret;
+       long ret;
 
+       lock_kernel();
        if (ncp_ioctl_need_write(cmd)) {
                /*
                 * inside the ioctl(), any failures which
@@ -853,24 +854,28 @@ int ncp_ioctl(struct inode *inode, struct file *filp,
                 * -EACCESS, so it seems consistent to keep
                 *  that here.
                 */
-               if (mnt_want_write(filp->f_path.mnt))
-                       return -EACCES;
+               if (mnt_want_write(filp->f_path.mnt)) {
+                       ret = -EACCES;
+                       goto out;
+               }
        }
-       ret = __ncp_ioctl(inode, filp, cmd, arg);
+       ret = __ncp_ioctl(filp, cmd, arg);
        if (ncp_ioctl_need_write(cmd))
                mnt_drop_write(filp->f_path.mnt);
+
+out:
+       unlock_kernel();
        return ret;
 }
 
 #ifdef CONFIG_COMPAT
 long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = file->f_path.dentry->d_inode;
-       int ret;
+       long ret;
 
        lock_kernel();
        arg = (unsigned long) compat_ptr(arg);
-       ret = ncp_ioctl(inode, file, cmd, arg);
+       ret = ncp_ioctl(file, cmd, arg);
        unlock_kernel();
        return ret;
 }
index 30b06c89394482f86955dfa69f8a9f912e98388d..4522aed00906c81f885eae6ed5c0ecd9f399bde8 100644 (file)
@@ -210,7 +210,7 @@ int ncp_date_dos2unix(__le16 time, __le16 date);
 void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date);
 
 /* linux/fs/ncpfs/ioctl.c */
-int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
+long ncp_ioctl(struct file *, unsigned int, unsigned long);
 long ncp_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /* linux/fs/ncpfs/sock.c */