]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
UBUNTU: SAUCE: (noup) Update zfs to 0.6.5.6-0ubuntu16
authorColin Ian King <colin.king@canonical.com>
Fri, 17 Feb 2017 14:53:44 +0000 (14:53 +0000)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Thu, 6 Apr 2017 08:19:08 +0000 (09:19 +0100)
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.

Acked-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Brad Figg <brad.figg@canonical.com>
zfs/META
zfs/config/kernel-acl.m4
zfs/config/kernel-vfs-rw-iterate.m4
zfs/config/kernel.m4
zfs/configure
zfs/include/linux/vfs_compat.h
zfs/module/zfs/zpl_file.c
zfs/module/zfs/zpl_xattr.c
zfs/zfs_config.h.in

index 94784ee8d7d9617268789c4963597de42d268618..febf95621b355acaefecb522bf61d2ad56ad0f49 100644 (file)
--- 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
index 1cb28b25a6f4dd58d791073e7ee7c365ced26a88..85f4cfb25a0323ca7e327fc85e6dfcc7d29cbc86 100644 (file)
@@ -117,6 +117,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
index f8dc4222968680db788ee5b507875e26489f8475..af44beb7bcfce1633371f83ec166c8e8dab93374 100644 (file)
@@ -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)
+       ])
+])
index bac7d4d43a9cfdea7077fa22d91a16b58ed3574a..0eddc2f4e642752aa2afc922422a281f8cf665dd 100644 (file)
@@ -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
index ebbae100497e464ab9fd2e5963553076dfe94fab..c4e04b53f244311aca7206a5b340cfab2aeaacbe 100755 (executable)
 
 
 
+       { $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; }
 
@@ -22333,6 +22403,73 @@ $as_echo "no" >&6; }
 
 
 
+fi
+       rm -Rf build
+
+
+
+       { $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 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; }
 
@@ -31590,6 +31797,73 @@ $as_echo "no" >&6; }
 
 
 
+fi
+       rm -Rf build
+
+
+
+       { $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
 
index bcec1146a0c4cdd6a17e51e6b65c28909d64460f..80370559590ad4d512d91a969c53d4700886e23e 100644 (file)
@@ -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
index 5c430c7ca801d1647b8103c1191b273f22582303..466322f4ca05a1f38aec8c5b10cf3854e3f41f82 100644 (file)
@@ -250,20 +250,6 @@ zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t *ppos,
            flags, cr, 0));
 }
 
-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 */
@@ -352,20 +338,6 @@ zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t *ppos,
            flags, cr, 0));
 }
 
-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,
index d811da71eb82a5266c68ef17476ed088cdc7c5ee..b70cdf73ba21fa0c6546cf925bbd56a0deda8d81 100644 (file)
@@ -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);
index 86c566834ac719d44423b78bf325b24028b4ba69..1f5de55269df30205c020fb86cbe2b50d2ad84fc 100644 (file)
 /* 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
 
 /* 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