]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - fs/gfs2/file.c
Merge tag 'gfs2-for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux...
[thirdparty/linux.git] / fs / gfs2 / file.c
index 62cc5bd12d091f04048d0b5db03d1b1d2a22a7f5..9d58295ccf7a49e6f1a8f1f9bfda15b300b133e8 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/compat.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
@@ -354,6 +355,31 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        return -ENOTTY;
 }
 
+#ifdef CONFIG_COMPAT
+static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       switch(cmd) {
+       /* These are just misnamed, they actually get/put from/to user an int */
+       case FS_IOC32_GETFLAGS:
+               cmd = FS_IOC_GETFLAGS;
+               break;
+       case FS_IOC32_SETFLAGS:
+               cmd = FS_IOC_SETFLAGS;
+               break;
+       /* Keep this list in sync with gfs2_ioctl */
+       case FITRIM:
+       case FS_IOC_GETFSLABEL:
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+
+       return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
+}
+#else
+#define gfs2_compat_ioctl NULL
+#endif
+
 /**
  * gfs2_size_hint - Give a hint to the size of a write request
  * @filep: The struct file
@@ -745,7 +771,8 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to)
        if (ret)
                goto out_uninit;
 
-       ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL);
+       ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL,
+                          is_sync_kiocb(iocb));
 
        gfs2_glock_dq(&gh);
 out_uninit:
@@ -780,7 +807,8 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from)
        if (offset + len > i_size_read(&ip->i_inode))
                goto out;
 
-       ret = iomap_dio_rw(iocb, from, &gfs2_iomap_ops, NULL);
+       ret = iomap_dio_rw(iocb, from, &gfs2_iomap_ops, NULL,
+                          is_sync_kiocb(iocb));
 
 out:
        gfs2_glock_dq(&gh);
@@ -1307,6 +1335,7 @@ const struct file_operations gfs2_file_fops = {
        .write_iter     = gfs2_file_write_iter,
        .iopoll         = iomap_dio_iopoll,
        .unlocked_ioctl = gfs2_ioctl,
+       .compat_ioctl   = gfs2_compat_ioctl,
        .mmap           = gfs2_mmap,
        .open           = gfs2_open,
        .release        = gfs2_release,
@@ -1322,6 +1351,7 @@ const struct file_operations gfs2_file_fops = {
 const struct file_operations gfs2_dir_fops = {
        .iterate_shared = gfs2_readdir,
        .unlocked_ioctl = gfs2_ioctl,
+       .compat_ioctl   = gfs2_compat_ioctl,
        .open           = gfs2_open,
        .release        = gfs2_release,
        .fsync          = gfs2_fsync,
@@ -1338,6 +1368,7 @@ const struct file_operations gfs2_file_fops_nolock = {
        .write_iter     = gfs2_file_write_iter,
        .iopoll         = iomap_dio_iopoll,
        .unlocked_ioctl = gfs2_ioctl,
+       .compat_ioctl   = gfs2_compat_ioctl,
        .mmap           = gfs2_mmap,
        .open           = gfs2_open,
        .release        = gfs2_release,
@@ -1351,6 +1382,7 @@ const struct file_operations gfs2_file_fops_nolock = {
 const struct file_operations gfs2_dir_fops_nolock = {
        .iterate_shared = gfs2_readdir,
        .unlocked_ioctl = gfs2_ioctl,
+       .compat_ioctl   = gfs2_compat_ioctl,
        .open           = gfs2_open,
        .release        = gfs2_release,
        .fsync          = gfs2_fsync,