Merge branch 'master' into for-linus
[firefly-linux-kernel-4.4.55.git] / net / sunrpc / cache.c
index a3f340c8b79a83dccc52b413f517a21ccb91b751..58de76c8540c65dac38999ea4c9a5c2af5303f92 100644 (file)
 #include <linux/workqueue.h>
 #include <linux/mutex.h>
 #include <linux/pagemap.h>
+#include <linux/smp_lock.h>
 #include <asm/ioctls.h>
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/cache.h>
 #include <linux/sunrpc/stats.h>
 #include <linux/sunrpc/rpc_pipe_fs.h>
+#include <linux/smp_lock.h>
 
 #define         RPCDBG_FACILITY RPCDBG_CACHE
 
@@ -1344,12 +1346,18 @@ static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
        return cache_poll(filp, wait, cd);
 }
 
-static int cache_ioctl_procfs(struct inode *inode, struct file *filp,
-                             unsigned int cmd, unsigned long arg)
+static long cache_ioctl_procfs(struct file *filp,
+                              unsigned int cmd, unsigned long arg)
 {
+       long ret;
+       struct inode *inode = filp->f_path.dentry->d_inode;
        struct cache_detail *cd = PDE(inode)->data;
 
-       return cache_ioctl(inode, filp, cmd, arg, cd);
+       lock_kernel();
+       ret = cache_ioctl(inode, filp, cmd, arg, cd);
+       unlock_kernel();
+
+       return ret;
 }
 
 static int cache_open_procfs(struct inode *inode, struct file *filp)
@@ -1372,7 +1380,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 */
+       .unlocked_ioctl = cache_ioctl_procfs, /* for FIONREAD */
        .open           = cache_open_procfs,
        .release        = cache_release_procfs,
 };
@@ -1538,12 +1546,18 @@ static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait)
        return cache_poll(filp, wait, cd);
 }
 
-static int cache_ioctl_pipefs(struct inode *inode, struct file *filp,
+static long cache_ioctl_pipefs(struct file *filp,
                              unsigned int cmd, unsigned long arg)
 {
+       struct inode *inode = filp->f_dentry->d_inode;
        struct cache_detail *cd = RPC_I(inode)->private;
+       long ret;
+
+       lock_kernel();
+       ret = cache_ioctl(inode, filp, cmd, arg, cd);
+       unlock_kernel();
 
-       return cache_ioctl(inode, filp, cmd, arg, cd);
+       return ret;
 }
 
 static int cache_open_pipefs(struct inode *inode, struct file *filp)
@@ -1566,7 +1580,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 */
+       .unlocked_ioctl = cache_ioctl_pipefs, /* for FIONREAD */
        .open           = cache_open_pipefs,
        .release        = cache_release_pipefs,
 };