[PATCH][SRU][XENIAL] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.6-0ubuntu16

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH][SRU][XENIAL] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.6-0ubuntu16

Colin King
From: Colin Ian King <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1656259

Sync with zfs to enable zfs to respect RSIZE_LIMIT limits, using:

 - backport of zfs upstream commit 933ec999511f3d29de005bfa8966ae007b161c0f
   ("Retire .write/.read file operations")
 - backport of zfs upstream commit 4b908d32200b6e5c7b5115322b6c8d25e770daa0
   ("Linux 4.8 compat: posix_acl_valid()") to facilitate changes in
   posix_acl_valid.

---
 zfs/META                            |   2 +-
 zfs/config/kernel-acl.m4            |  24 ++++
 zfs/config/kernel-vfs-rw-iterate.m4 |  21 +++
 zfs/config/kernel.m4                |   2 +
 zfs/configure                       | 274 ++++++++++++++++++++++++++++++++++++
 zfs/include/linux/vfs_compat.h      |  12 ++
 zfs/module/zfs/zpl_file.c           |  75 +++++-----
 zfs/module/zfs/zpl_xattr.c          |   4 +-
 zfs/zfs_config.h.in                 |   6 +
 9 files changed, 384 insertions(+), 36 deletions(-)

diff --git a/zfs/META b/zfs/META
index 94784ee..4a3c456 100644
--- a/zfs/META
+++ b/zfs/META
@@ -2,7 +2,7 @@ Meta:         1
 Name:         zfs
 Branch:       1.0
 Version:      0.6.5.6
-Release:      0ubuntu15
+Release:      0ubuntu16
 Release-Tags: relext
 License:      CDDL
 Author:       OpenZFS on Linux
diff --git a/zfs/config/kernel-acl.m4 b/zfs/config/kernel-acl.m4
index 1cb28b2..85f4cfb 100644
--- a/zfs/config/kernel-acl.m4
+++ b/zfs/config/kernel-acl.m4
@@ -118,6 +118,30 @@ AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T], [
 ])
 
 dnl #
+dnl # 4.8 API change,
+dnl # The function posix_acl_valid now must be passed a namespace.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS], [
+ AC_MSG_CHECKING([whether posix_acl_valid() wants user namespace])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ #include <linux/posix_acl.h>
+ ],[
+ struct user_namespace *user_ns = NULL;
+ const struct posix_acl *acl = NULL;
+ int error;
+
+ error = posix_acl_valid(user_ns, acl);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_POSIX_ACL_VALID_WITH_NS, 1,
+    [posix_acl_valid() wants user namespace])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
+
+dnl #
 dnl # 2.6.27 API change,
 dnl # Check if inode_operations contains the function permission
 dnl # and expects the nameidata structure to have been removed.
diff --git a/zfs/config/kernel-vfs-rw-iterate.m4 b/zfs/config/kernel-vfs-rw-iterate.m4
index f8dc422..af44beb 100644
--- a/zfs/config/kernel-vfs-rw-iterate.m4
+++ b/zfs/config/kernel-vfs-rw-iterate.m4
@@ -25,3 +25,24 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_RW_ITERATE],
  AC_MSG_RESULT(no)
  ])
 ])
+
+dnl #
+dnl # Linux 4.1.x API
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS],
+ [AC_MSG_CHECKING([whether generic_write_checks() takes kiocb])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+
+ ],[
+ struct kiocb *iocb = NULL;
+ struct iov_iter *iov = NULL;
+ generic_write_checks(iocb, iov);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_GENERIC_WRITE_CHECKS_KIOCB, 1,
+ [generic_write_checks() takes kiocb])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/zfs/config/kernel.m4 b/zfs/config/kernel.m4
index bac7d4d..0eddc2f 100644
--- a/zfs/config/kernel.m4
+++ b/zfs/config/kernel.m4
@@ -41,6 +41,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
  ZFS_AC_KERNEL_POSIX_ACL_CHMOD
  ZFS_AC_KERNEL_POSIX_ACL_CACHING
  ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
+ ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS
  ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION
  ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA
  ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL
@@ -88,6 +89,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
  ZFS_AC_KERNEL_LSEEK_EXECUTE
  ZFS_AC_KERNEL_VFS_ITERATE
  ZFS_AC_KERNEL_VFS_RW_ITERATE
+ ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS
  ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
  ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
  ZFS_AC_KERNEL_MAKE_REQUEST_FN
diff --git a/zfs/configure b/zfs/configure
index ebbae10..c4e04b5 100755
--- a/zfs/configure
+++ b/zfs/configure
@@ -17823,6 +17823,76 @@ fi
 
 
 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether posix_acl_valid() wants user namespace" >&5
+$as_echo_n "checking whether posix_acl_valid() wants user namespace... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+ #include <linux/fs.h>
+ #include <linux/posix_acl.h>
+
+int
+main (void)
+{
+
+ struct user_namespace *user_ns = NULL;
+ const struct posix_acl *acl = NULL;
+ int error;
+
+ error = posix_acl_valid(user_ns, acl);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+
+cat - <<_ACEOF >conftest.h
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ if { ac_try='cp conftest.c conftest.h build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_POSIX_ACL_VALID_WITH_NS 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+ rm -Rf build
+
+
+
+
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether iops->permission() exists" >&5
 $as_echo_n "checking whether iops->permission() exists... " >&6; }
 
@@ -22338,6 +22408,73 @@ fi
 
 
 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether generic_write_checks() takes kiocb" >&5
+$as_echo_n "checking whether generic_write_checks() takes kiocb... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+ #include <linux/fs.h>
+
+
+int
+main (void)
+{
+
+ struct kiocb *iocb = NULL;
+ struct iov_iter *iov = NULL;
+ generic_write_checks(iocb, iov);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+
+cat - <<_ACEOF >conftest.h
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ if { ac_try='cp conftest.c conftest.h build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GENERIC_WRITE_CHECKS_KIOCB 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+ rm -Rf build
+
+
+
 
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether kmap_atomic wants 1 args" >&5
 $as_echo_n "checking whether kmap_atomic wants 1 args... " >&6; }
@@ -27080,6 +27217,76 @@ fi
 
 
 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether posix_acl_valid() wants user namespace" >&5
+$as_echo_n "checking whether posix_acl_valid() wants user namespace... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+ #include <linux/fs.h>
+ #include <linux/posix_acl.h>
+
+int
+main (void)
+{
+
+ struct user_namespace *user_ns = NULL;
+ const struct posix_acl *acl = NULL;
+ int error;
+
+ error = posix_acl_valid(user_ns, acl);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+
+cat - <<_ACEOF >conftest.h
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ if { ac_try='cp conftest.c conftest.h build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_POSIX_ACL_VALID_WITH_NS 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+ rm -Rf build
+
+
+
+
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether iops->permission() exists" >&5
 $as_echo_n "checking whether iops->permission() exists... " >&6; }
 
@@ -31595,6 +31802,73 @@ fi
 
 
 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether generic_write_checks() takes kiocb" >&5
+$as_echo_n "checking whether generic_write_checks() takes kiocb... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+ #include <linux/fs.h>
+
+
+int
+main (void)
+{
+
+ struct kiocb *iocb = NULL;
+ struct iov_iter *iov = NULL;
+ generic_write_checks(iocb, iov);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+
+cat - <<_ACEOF >conftest.h
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ if { ac_try='cp conftest.c conftest.h build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GENERIC_WRITE_CHECKS_KIOCB 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+ rm -Rf build
+
+
+
 
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether kmap_atomic wants 1 args" >&5
 $as_echo_n "checking whether kmap_atomic wants 1 args... " >&6; }
diff --git a/zfs/include/linux/vfs_compat.h b/zfs/include/linux/vfs_compat.h
index bcec114..8037055 100644
--- a/zfs/include/linux/vfs_compat.h
+++ b/zfs/include/linux/vfs_compat.h
@@ -320,6 +320,18 @@ typedef umode_t zpl_equivmode_t;
 #else
 typedef mode_t zpl_equivmode_t;
 #endif /* HAVE_POSIX_ACL_EQUIV_MODE_UMODE_T */
+
+/*
+ * 4.8 API change,
+ * posix_acl_valid() now must be passed a namespace, the namespace from
+ * from super block associated with the given inode is used for this purpose.
+ */
+#ifdef HAVE_POSIX_ACL_VALID_WITH_NS
+#define zpl_posix_acl_valid(ip, acl)  posix_acl_valid(ip->i_sb->s_user_ns, acl)
+#else
+#define zpl_posix_acl_valid(ip, acl)  posix_acl_valid(acl)
+#endif
+
 #endif /* CONFIG_FS_POSIX_ACL */
 
 #ifndef HAVE_CURRENT_UMASK
diff --git a/zfs/module/zfs/zpl_file.c b/zfs/module/zfs/zpl_file.c
index 5c430c7..466322f 100644
--- a/zfs/module/zfs/zpl_file.c
+++ b/zfs/module/zfs/zpl_file.c
@@ -251,20 +251,6 @@ zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t *ppos,
 }
 
 static ssize_t
-zpl_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
-{
- cred_t *cr = CRED();
- ssize_t read;
-
- crhold(cr);
- read = zpl_read_common(filp->f_mapping->host, buf, len, ppos,
-    UIO_USERSPACE, filp->f_flags, cr);
- crfree(cr);
-
- return (read);
-}
-
-static ssize_t
 zpl_iter_read_common(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, size_t count, uio_seg_t seg, size_t skip)
 {
@@ -301,7 +287,7 @@ static ssize_t
 zpl_aio_read(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, loff_t pos)
 {
- return (zpl_iter_read_common(kiocb, iovp, nr_segs, kiocb->ki_nbytes,
+ return (zpl_iter_read_common(kiocb, iovp, nr_segs, count,
     UIO_USERSPACE, 0));
 }
 #endif /* HAVE_VFS_RW_ITERATE */
@@ -353,20 +339,6 @@ zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t *ppos,
 }
 
 static ssize_t
-zpl_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
-{
- cred_t *cr = CRED();
- ssize_t wrote;
-
- crhold(cr);
- wrote = zpl_write_common(filp->f_mapping->host, buf, len, ppos,
-    UIO_USERSPACE, filp->f_flags, cr);
- crfree(cr);
-
- return (wrote);
-}
-
-static ssize_t
 zpl_iter_write_common(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, size_t count, uio_seg_t seg, size_t skip)
 {
@@ -386,16 +358,40 @@ zpl_iter_write_common(struct kiocb *kiocb, const struct iovec *iovp,
 static ssize_t
 zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from)
 {
+ size_t count;
  ssize_t ret;
  uio_seg_t seg = UIO_USERSPACE;
+
+#ifndef HAVE_GENERIC_WRITE_CHECKS_KIOCB
+ struct file *file = kiocb->ki_filp;
+ struct address_space *mapping = file->f_mapping;
+ struct inode *ip = mapping->host;
+ int isblk = S_ISBLK(ip->i_mode);
+
+ count = iov_iter_count(from);
+ ret = generic_write_checks(file, &kiocb->ki_pos, &count, isblk);
+#else
+ /*
+ * XXX - ideally this check should be in the same lock region with
+ * write operations, so that there's no TOCTTOU race when doing
+ * append and someone else grow the file.
+ */
+ ret = generic_write_checks(kiocb, from);
+ count = ret;
+#endif
+ if (ret <= 0)
+ return (ret);
+
  if (from->type & ITER_KVEC)
  seg = UIO_SYSSPACE;
  if (from->type & ITER_BVEC)
  seg = UIO_BVEC;
+
  ret = zpl_iter_write_common(kiocb, from->iov, from->nr_segs,
-    iov_iter_count(from), seg, from->iov_offset);
+ count, seg, from->iov_offset);
  if (ret > 0)
  iov_iter_advance(from, ret);
+
  return (ret);
 }
 #else
@@ -403,7 +399,22 @@ static ssize_t
 zpl_aio_write(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, loff_t pos)
 {
- return (zpl_iter_write_common(kiocb, iovp, nr_segs, kiocb->ki_nbytes,
+ struct file *file = kiocb->ki_filp;
+ struct address_space *mapping = file->f_mapping;
+ struct inode *ip = mapping->host;
+ int isblk = S_ISBLK(ip->i_mode);
+ size_t count;
+ ssize_t ret;
+
+ ret = generic_segment_checks(iovp, &nr_segs, &count, VERIFY_READ);
+ if (ret)
+ return (ret);
+
+ ret = generic_write_checks(file, &pos, &count, isblk);
+ if (ret)
+ return (ret);
+
+ return (zpl_iter_write_common(kiocb, iovp, nr_segs, count,
     UIO_USERSPACE, 0));
 }
 #endif /* HAVE_VFS_RW_ITERATE */
@@ -827,8 +838,6 @@ const struct file_operations zpl_file_operations = {
  .open = zpl_open,
  .release = zpl_release,
  .llseek = zpl_llseek,
- .read = zpl_read,
- .write = zpl_write,
 #ifdef HAVE_VFS_RW_ITERATE
  .read_iter = zpl_iter_read,
  .write_iter = zpl_iter_write,
diff --git a/zfs/module/zfs/zpl_xattr.c b/zfs/module/zfs/zpl_xattr.c
index d811da7..b70cdf7 100644
--- a/zfs/module/zfs/zpl_xattr.c
+++ b/zfs/module/zfs/zpl_xattr.c
@@ -1281,7 +1281,7 @@ __zpl_xattr_acl_set_access(struct inode *ip, const char *name,
  if (IS_ERR(acl))
  return (PTR_ERR(acl));
  else if (acl) {
- error = posix_acl_valid(ip->i_sb->s_user_ns, acl);
+ error = zpl_posix_acl_valid(ip, acl);
  if (error) {
  zpl_posix_acl_release(acl);
  return (error);
@@ -1320,7 +1320,7 @@ __zpl_xattr_acl_set_default(struct inode *ip, const char *name,
  if (IS_ERR(acl))
  return (PTR_ERR(acl));
  else if (acl) {
- error = posix_acl_valid(ip->i_sb->s_user_ns, acl);
+ error = zpl_posix_acl_valid(ip, acl);
  if (error) {
  zpl_posix_acl_release(acl);
  return (error);
diff --git a/zfs/zfs_config.h.in b/zfs/zfs_config.h.in
index 86c5668..1f5de55 100644
--- a/zfs/zfs_config.h.in
+++ b/zfs/zfs_config.h.in
@@ -174,6 +174,9 @@
 /* generic_start_io_acct()/generic_end_io_acct() avaliable */
 #undef HAVE_GENERIC_IO_ACCT
 
+/* generic_write_checks() takes kiocb */
+#undef HAVE_GENERIC_WRITE_CHECKS_KIOCB
+
 /* iops->get_acl() exists */
 #undef HAVE_GET_ACL
 
@@ -279,6 +282,9 @@
 /* posix_acl_release() is GPL-only */
 #undef HAVE_POSIX_ACL_RELEASE_GPL_ONLY
 
+/* posix_acl_valid() wants user namespace */
+#undef HAVE_POSIX_ACL_VALID_WITH_NS
+
 /* iops->put_link() cookie */
 #undef HAVE_PUT_LINK_COOKIE
 
--
2.9.3


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH][SRU][YAKKETY] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.8-0ubuntu4.2

Colin King
From: Colin Ian King <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1656259

Sync with zfs to enable zfs to respect RSIZE_LIMIT limits, using:

 - backport of zfs upstream commit 933ec999511f3d29de005bfa8966ae007b161c0f
   ("Retire .write/.read file operations")

Signed-off-by: Colin Ian King <[hidden email]>
---
 zfs/META                            |   2 +-
 zfs/config/kernel-vfs-rw-iterate.m4 |  21 ++++++
 zfs/config/kernel.m4                |   1 +
 zfs/configure                       | 134 ++++++++++++++++++++++++++++++++++++
 zfs/module/zfs/zpl_file.c           |  75 +++++++++++---------
 zfs/zfs_config.h.in                 |   3 +
 6 files changed, 202 insertions(+), 34 deletions(-)

diff --git a/zfs/META b/zfs/META
index 53c6200..a086086 100644
--- a/zfs/META
+++ b/zfs/META
@@ -2,7 +2,7 @@ Meta:         1
 Name:         zfs
 Branch:       1.0
 Version:      0.6.5.8
-Release:      0ubuntu4.1
+Release:      0ubuntu4.2
 Release-Tags: relext
 License:      CDDL
 Author:       OpenZFS on Linux
diff --git a/zfs/config/kernel-vfs-rw-iterate.m4 b/zfs/config/kernel-vfs-rw-iterate.m4
index f8dc422..af44beb 100644
--- a/zfs/config/kernel-vfs-rw-iterate.m4
+++ b/zfs/config/kernel-vfs-rw-iterate.m4
@@ -25,3 +25,24 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_RW_ITERATE],
  AC_MSG_RESULT(no)
  ])
 ])
+
+dnl #
+dnl # Linux 4.1.x API
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS],
+ [AC_MSG_CHECKING([whether generic_write_checks() takes kiocb])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+
+ ],[
+ struct kiocb *iocb = NULL;
+ struct iov_iter *iov = NULL;
+ generic_write_checks(iocb, iov);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_GENERIC_WRITE_CHECKS_KIOCB, 1,
+ [generic_write_checks() takes kiocb])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/zfs/config/kernel.m4 b/zfs/config/kernel.m4
index 53720ee..9207bfb 100644
--- a/zfs/config/kernel.m4
+++ b/zfs/config/kernel.m4
@@ -94,6 +94,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
  ZFS_AC_KERNEL_LSEEK_EXECUTE
  ZFS_AC_KERNEL_VFS_ITERATE
  ZFS_AC_KERNEL_VFS_RW_ITERATE
+ ZFS_AC_KERNEL_GENERIC_WRITE_CHECKS
  ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
  ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
  ZFS_AC_KERNEL_MAKE_REQUEST_FN
diff --git a/zfs/configure b/zfs/configure
index 8e8f0d3..9a64425 100755
--- a/zfs/configure
+++ b/zfs/configure
@@ -23082,6 +23082,73 @@ fi
 
 
 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether generic_write_checks() takes kiocb" >&5
+$as_echo_n "checking whether generic_write_checks() takes kiocb... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+ #include <linux/fs.h>
+
+
+int
+main (void)
+{
+
+ struct kiocb *iocb = NULL;
+ struct iov_iter *iov = NULL;
+ generic_write_checks(iocb, iov);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+
+cat - <<_ACEOF >conftest.h
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ if { ac_try='cp conftest.c conftest.h build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GENERIC_WRITE_CHECKS_KIOCB 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+ rm -Rf build
+
+
+
 
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether kmap_atomic wants 1 args" >&5
 $as_echo_n "checking whether kmap_atomic wants 1 args... " >&6; }
@@ -33083,6 +33150,73 @@ fi
 
 
 
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether generic_write_checks() takes kiocb" >&5
+$as_echo_n "checking whether generic_write_checks() takes kiocb... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+ #include <linux/fs.h>
+
+
+int
+main (void)
+{
+
+ struct kiocb *iocb = NULL;
+ struct iov_iter *iov = NULL;
+ generic_write_checks(iocb, iov);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+
+cat - <<_ACEOF >conftest.h
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+ echo "obj-m := conftest.o" >build/Makefile
+ modpost_flag=''
+ test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+ if { ac_try='cp conftest.c conftest.h build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GENERIC_WRITE_CHECKS_KIOCB 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+ rm -Rf build
+
+
+
 
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether kmap_atomic wants 1 args" >&5
 $as_echo_n "checking whether kmap_atomic wants 1 args... " >&6; }
diff --git a/zfs/module/zfs/zpl_file.c b/zfs/module/zfs/zpl_file.c
index a629b59..9701820 100644
--- a/zfs/module/zfs/zpl_file.c
+++ b/zfs/module/zfs/zpl_file.c
@@ -251,20 +251,6 @@ zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t *ppos,
 }
 
 static ssize_t
-zpl_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
-{
- cred_t *cr = CRED();
- ssize_t read;
-
- crhold(cr);
- read = zpl_read_common(filp->f_mapping->host, buf, len, ppos,
-    UIO_USERSPACE, filp->f_flags, cr);
- crfree(cr);
-
- return (read);
-}
-
-static ssize_t
 zpl_iter_read_common(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, size_t count, uio_seg_t seg, size_t skip)
 {
@@ -301,7 +287,7 @@ static ssize_t
 zpl_aio_read(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, loff_t pos)
 {
- return (zpl_iter_read_common(kiocb, iovp, nr_segs, kiocb->ki_nbytes,
+ return (zpl_iter_read_common(kiocb, iovp, nr_segs, count,
     UIO_USERSPACE, 0));
 }
 #endif /* HAVE_VFS_RW_ITERATE */
@@ -353,20 +339,6 @@ zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t *ppos,
 }
 
 static ssize_t
-zpl_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
-{
- cred_t *cr = CRED();
- ssize_t wrote;
-
- crhold(cr);
- wrote = zpl_write_common(filp->f_mapping->host, buf, len, ppos,
-    UIO_USERSPACE, filp->f_flags, cr);
- crfree(cr);
-
- return (wrote);
-}
-
-static ssize_t
 zpl_iter_write_common(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, size_t count, uio_seg_t seg, size_t skip)
 {
@@ -386,16 +358,40 @@ zpl_iter_write_common(struct kiocb *kiocb, const struct iovec *iovp,
 static ssize_t
 zpl_iter_write(struct kiocb *kiocb, struct iov_iter *from)
 {
+ size_t count;
  ssize_t ret;
  uio_seg_t seg = UIO_USERSPACE;
+
+#ifndef HAVE_GENERIC_WRITE_CHECKS_KIOCB
+ struct file *file = kiocb->ki_filp;
+ struct address_space *mapping = file->f_mapping;
+ struct inode *ip = mapping->host;
+ int isblk = S_ISBLK(ip->i_mode);
+
+ count = iov_iter_count(from);
+ ret = generic_write_checks(file, &kiocb->ki_pos, &count, isblk);
+#else
+ /*
+ * XXX - ideally this check should be in the same lock region with
+ * write operations, so that there's no TOCTTOU race when doing
+ * append and someone else grow the file.
+ */
+ ret = generic_write_checks(kiocb, from);
+ count = ret;
+#endif
+ if (ret <= 0)
+ return (ret);
+
  if (from->type & ITER_KVEC)
  seg = UIO_SYSSPACE;
  if (from->type & ITER_BVEC)
  seg = UIO_BVEC;
+
  ret = zpl_iter_write_common(kiocb, from->iov, from->nr_segs,
-    iov_iter_count(from), seg, from->iov_offset);
+ count, seg, from->iov_offset);
  if (ret > 0)
  iov_iter_advance(from, ret);
+
  return (ret);
 }
 #else
@@ -403,7 +399,22 @@ static ssize_t
 zpl_aio_write(struct kiocb *kiocb, const struct iovec *iovp,
     unsigned long nr_segs, loff_t pos)
 {
- return (zpl_iter_write_common(kiocb, iovp, nr_segs, kiocb->ki_nbytes,
+ struct file *file = kiocb->ki_filp;
+ struct address_space *mapping = file->f_mapping;
+ struct inode *ip = mapping->host;
+ int isblk = S_ISBLK(ip->i_mode);
+ size_t count;
+ ssize_t ret;
+
+ ret = generic_segment_checks(iovp, &nr_segs, &count, VERIFY_READ);
+ if (ret)
+ return (ret);
+
+ ret = generic_write_checks(file, &pos, &count, isblk);
+ if (ret)
+ return (ret);
+
+ return (zpl_iter_write_common(kiocb, iovp, nr_segs, count,
     UIO_USERSPACE, 0));
 }
 #endif /* HAVE_VFS_RW_ITERATE */
@@ -827,8 +838,6 @@ const struct file_operations zpl_file_operations = {
  .open = zpl_open,
  .release = zpl_release,
  .llseek = zpl_llseek,
- .read = zpl_read,
- .write = zpl_write,
 #ifdef HAVE_VFS_RW_ITERATE
  .read_iter = zpl_iter_read,
  .write_iter = zpl_iter_write,
diff --git a/zfs/zfs_config.h.in b/zfs/zfs_config.h.in
index cdb6873..c8905ee 100644
--- a/zfs/zfs_config.h.in
+++ b/zfs/zfs_config.h.in
@@ -183,6 +183,9 @@
 /* generic_start_io_acct()/generic_end_io_acct() avaliable */
 #undef HAVE_GENERIC_IO_ACCT
 
+/* generic_write_checks() takes kiocb */
+#undef HAVE_GENERIC_WRITE_CHECKS_KIOCB
+
 /* iops->get_acl() exists */
 #undef HAVE_GET_ACL
 
--
2.9.3


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH][SRU][XENIAL] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.6-0ubuntu16

Tim Gardner-2
In reply to this post by Colin King
Just uploaded the corresponding user space and DKMS changes.
--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH][SRU][YAKKETY] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.8-0ubuntu4.2

Tim Gardner-2
In reply to this post by Colin King
Just uploaded corresponding user space and DKMS package changes

--
Tim Gardner [hidden email]

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Applied: [PATCH][SRU][XENIAL] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.6-0ubuntu16

brad.figg
In reply to this post by Colin King

Applied to xenial master-next.

--
Brad Figg [hidden email] http://www.canonical.com

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Applied: [PATCH][SRU][YAKKETY] UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.8-0ubuntu4.2

brad.figg
In reply to this post by Colin King

Applied to the master-next branch of yakkety.

--
Brad Figg [hidden email] http://www.canonical.com

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team