summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2017-03-06 09:20:20 -0800
committerTony Hutter <[email protected]>2017-06-09 14:05:15 -0700
commit2094a93e87a8b8a21c217245ef733c509c9898cf (patch)
tree7df29da4e47e30b0e9b562db23a6f9f7c46fed10
parent03336d011ca821511888fca2b4989a4e8d8d741d (diff)
Fix loop device becomes read-only
Commit 933ec99 removes read and write from f_op because the vfs layer will select iter_write or aio_write automatically. However, for Linux <= 4.0, loop_set_fd will actually check f_op->write and set read-only if not exists. This patch add them back and use the generic do_sync_{read,write} for aio_{read,write} and new_sync_{read,write} for {read,write}_iter. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Chunwei Chen <[email protected]> Closes #5776 Closes #5855
-rw-r--r--config/kernel-vfs-rw-iterate.m422
-rw-r--r--module/zfs/zpl_file.c6
2 files changed, 27 insertions, 1 deletions
diff --git a/config/kernel-vfs-rw-iterate.m4 b/config/kernel-vfs-rw-iterate.m4
index af44beb7b..9f8fe6559 100644
--- a/config/kernel-vfs-rw-iterate.m4
+++ b/config/kernel-vfs-rw-iterate.m4
@@ -1,5 +1,5 @@
dnl #
-dnl # Linux 4.1.x API
+dnl # Linux 3.16 API
dnl #
AC_DEFUN([ZFS_AC_KERNEL_VFS_RW_ITERATE],
[AC_MSG_CHECKING([whether fops->read/write_iter() are available])
@@ -21,6 +21,26 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_RW_ITERATE],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_VFS_RW_ITERATE, 1,
[fops->read/write_iter() are available])
+
+ ZFS_AC_KERNEL_NEW_SYNC_READ
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
+dnl # Linux 4.1 API
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_NEW_SYNC_READ],
+ [AC_MSG_CHECKING([whether new_sync_read() is available])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ new_sync_read(NULL, NULL, 0, NULL);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_NEW_SYNC_READ, 1,
+ [new_sync_read() is available])
],[
AC_MSG_RESULT(no)
])
diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
index 19e8a6278..8781d8ca9 100644
--- a/module/zfs/zpl_file.c
+++ b/module/zfs/zpl_file.c
@@ -857,9 +857,15 @@ const struct file_operations zpl_file_operations = {
.release = zpl_release,
.llseek = zpl_llseek,
#ifdef HAVE_VFS_RW_ITERATE
+#ifdef HAVE_NEW_SYNC_READ
+ .read = new_sync_read,
+ .write = new_sync_write,
+#endif
.read_iter = zpl_iter_read,
.write_iter = zpl_iter_write,
#else
+ .read = do_sync_read,
+ .write = do_sync_write,
.aio_read = zpl_aio_read,
.aio_write = zpl_aio_write,
#endif