diffstat for zfs-linux-0.7.5 zfs-linux-0.7.5 changelog | 238 +++ control | 10 control.in | 10 patches/2100-zfs-load-module.patch | 87 + patches/2101-Take-user-namespaces-into-account-in-policy-checks.patch | 710 ++++++++++ patches/2102-Fix-ARC-hit-rate.patch | 197 ++ patches/2200-add-zfs-0.6.x-ioctl-compat-shim.patch | 247 +++ patches/2201-Fix-mmap-libaio-deadlock.patch | 339 ++++ patches/2202-Allow-mounting-datasets-more-than-once.patch | 377 +++++ patches/2300-OpenZFS-8373-TXG_WAIT-in-ZIL-commit-path.patch | 55 patches/2301-zfs-promote-rename-.-recv-should-be-an-error.patch | 232 +++ patches/2302-Fix-parsable-zfs-get-for-compressratios.patch | 44 patches/2303-Fix-zpool-events-scripted-mode-tab-separator.patch | 52 patches/2304-zv_suspend_lock-in-zvol_open-zvol_release.patch | 124 + patches/2305-Allow-longer-SPA-names-in-stats.patch | 208 ++ patches/2306-vdev_mirror-load-balancing-fixes.patch | 206 ++ patches/2307-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch | 52 patches/2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch | 53 patches/2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch | 40 patches/2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch | 39 patches/2311-dmu_objset-release-bonus-buffer-in-failure-path.patch | 49 patches/2312-Fix-false-config_cache_write-events.patch | 43 patches/2313-Fix-printk-calls-missing-log-level.patch | 29 patches/2314-Fix-abdstats-kstat-on-32-bit-systems.patch | 42 patches/2315-Relax-ASSERT-for-6526.patch | 33 patches/2316-Fix-coverity-defects-147480-147584.patch | 67 patches/2317-Fix-coverity-defects-CID-161388.patch | 43 patches/2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch | 33 patches/2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch | 274 +++ patches/2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch | 255 +++ patches/2321-Sort-output-of-tunables-in-arc_summary.py.patch | 45 patches/2322-Fix-data-on-evict_skips-in-arc_summary.py.patch | 49 patches/2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch | 66 patches/2324-ZTS-Fix-create-o_ashift-test-case.patch | 128 + patches/2325-Handle-invalid-options-in-arc_summary.patch | 130 + patches/2326-Call-commit-callbacks-from-the-tail-of-the-list.patch | 80 + patches/2327-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch | 198 ++ patches/2328-Fix-fsanitize-address-memory-leak.patch | 40 patches/2329-Revert-raidz_map-and-_col-structure-types.patch | 80 + patches/2330-Use-zap_count-instead-of-cached-z_size-for-unlink.patch | 60 patches/2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch | 46 patches/2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch | 69 patches/2333-Emit-an-error-message-before-MMP-suspends-pool.patch | 43 patches/2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch | 65 patches/2335-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch | 79 + patches/2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch | 50 patches/2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch | 40 patches/2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch | 69 patches/2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch | 53 patches/2340-Fix-zfs-receive-o-when-used-with-e-d.patch | 93 + patches/2341-Change-movaps-to-movups-in-AES-NI-code.patch | 279 +++ patches/2342-tx_waited-tx_dirty_delayed-in-trace_dmu.h.patch | 63 patches/2343-OpenZFS-8966-Source-file-zfs_acl.c-function-zfs_acls.patch | 47 patches/2344-Fix-zdb-c-traverse-stop-on-damaged-objset-root.patch | 95 + patches/2345-Fix-zle_decompress-out-of-bound-access.patch | 37 patches/2346-Fix-racy-assignment-of-zcb.zcb_haderrors.patch | 53 patches/2347-Fix-zdb-R-decompression.patch | 124 + patches/2348-Fix-zdb-E-segfault.patch | 40 patches/2349-Fix-zdb-ed-on-objset-for-exported-pool.patch | 210 ++ patches/series | 56 zfs-zed.preinst | 22 zfsutils-linux.install | 1 62 files changed, 6690 insertions(+), 8 deletions(-) diff -Nru zfs-linux-0.7.5/debian/changelog zfs-linux-0.7.5/debian/changelog --- zfs-linux-0.7.5/debian/changelog 2018-01-19 07:39:23.000000000 +0000 +++ zfs-linux-0.7.5/debian/changelog 2018-04-17 09:18:54.000000000 +0000 @@ -1,3 +1,241 @@ +zfs-linux (0.7.5-1ubuntu15) bionic; urgency=medium + + * Apply and/or backport upstream bugfixes (LP: #1764690) + - OpenZFS 8373 - TXG_WAIT in ZIL commit path + Closes zfsonlinux #6403 + - zfs promote|rename .../%recv should be an error + Closes zfsonlinux #4843, #6339 + - Fix parsable 'zfs get' for compressratios + Closes zfsonlinux #6436, #6449 + - Fix zpool events scripted mode tab separator + Closes zfsonlinux #6444, #6445 + - zv_suspend_lock in zvol_open()/zvol_release() + Closes zfsonlinux #6342 + - Allow longer SPA names in stats, allows bigger pool names + Closes zfsonlinux #6481 + - vdev_mirror: load balancing fixes + Closes zfsonlinux #6461 + - Fix zfs_ioc_pool_sync should not use fnvlist + Closes zfsonlinux #6529 + - OpenZFS 8375 - Kernel memory leak in nvpair code + Closes zfsonlinux #6578 + - OpenZFS 7261 - nvlist code should enforce name length limit + Closes zfsonlinux #6579 + - OpenZFS 5778 - nvpair_type_is_array() does not recognize + DATA_TYPE_INT8_ARRAY + Closes zfsonlinux #6580 + - dmu_objset: release bonus buffer in failure path + Closes zfsonlinux #6575 + - Fix false config_cache_write events + Closes zfsonlinux #6617 + - Fix printk() calls missing log level + Closes zfsonlinux #6672 + - Fix abdstats kstat on 32-bit systems + Closes zfsonlinux #6721 + - Relax ASSERT for #6526 + Closes zfsonlinux #6526 + - Fix coverity defects: 147480, 147584 (Logically dead code) + Closes zfsonlinux #6745 + - Fix coverity defects: CID 161388 (Resource Leak) + Closes zfsonlinux #6755 + - Use ashift=12 by default on SSDSC2BW48 disks + Closes zfsonlinux #6774 + - OpenZFS 8558, 8602 - lwp_create() returns EAGAIN + Closes zfsonlinux #6779 + - ZFS send fails to dump objects larger than 128PiB + Closes zfsonlinux #6760 + - Sort output of tunables in arc_summary.py + Closes zfsonlinux #6828 + - Fix data on evict_skips in arc_summary.py + Closes zfsonlinux #6882, #6883 + - Fix segfault in zpool iostat when adding VDEVs + Closes zfsonlinux #6748, #6872 + - ZTS: Fix create-o_ashift test case + Closes zfsonlinux #6924, #6877 + - Handle invalid options in arc_summary + Closes zfsonlinux #6983 + - Call commit callbacks from the tail of the list + Closes zfsonlinux #6986 + - Fix 'zpool add' handling of nested interior VDEVs + Closes zfsonlinux #6678, #6996 + - Fix -fsanitize=address memory leak + kmem_alloc(0, ...) in userspace returns a leakable pointer. + Closes zfsonlinux #6941 + - Revert raidz_map and _col structure types + Closes zfsonlinux #6981, #7023 + - Use zap_count instead of cached z_size for unlink + Closes zfsonlinux #7019 + - OpenZFS 8897 - zpool online -e fails assertion when run on non-leaf + vdevs + Closes zfsonlinux #7030 + - OpenZFS 8898 - creating fs with checksum=skein on the boot pools + fails ungracefully + Closes zfsonlinux #7031 + - Emit an error message before MMP suspends pool + Closes zfsonlinux #7048 + - OpenZFS 8641 - "zpool clear" and "zinject" don't work on "spare" + or "replacing" vdevs + Closes zfsonlinux #7060 + - OpenZFS 8835 - Speculative prefetch in ZFS not working for + misaligned reads + Closes zfsonlinux #7062 + - OpenZFS 8972 - zfs holds: In scripted mode, do not pad columns with + spaces + Closes zfsonlinux #7063 + - Revert "Remove wrong ASSERT in annotate_ecksum" + Closes zfsonlinux #7079 + - OpenZFS 8731 - ASSERT3U(nui64s, <=, UINT16_MAX) fails for large + blocks + Closes zfsonlinux #7079 + - Prevent zdb(8) from occasionally hanging on I/O + Closes zfsonlinux #6999 + - Fix 'zfs receive -o' when used with '-e|-d' + Closes zfsonlinux #7088 + - Change movaps to movups in AES-NI code + Closes zfsonlinux #7065, #7108 + - tx_waited -> tx_dirty_delayed in trace_dmu.h + Closes zfsonlinux #7096 + - OpenZFS 8966 - Source file zfs_acl.c, function + Closes zfsonlinux #7141 + - Fix zdb -c traverse stop on damaged objset root + Closes zfsonlinux #7099 + - Fix zle_decompress out of bound access + Closes zfsonlinux #7099 + - Fix racy assignment of zcb.zcb_haderrors + Closes zfsonlinux #7099 + - Fix zdb -R decompression + Closes zfsonlinux #7099, #4984 + - Fix zdb -E segfault + Closes zfsonlinux #7099 + - Fix zdb -ed on objset for exported pool + Closes zfsonlinux #7099, #6464 + + -- Colin Ian King Tue, 17 Apr 2018 10:18:54 +0100 + +zfs-linux (0.7.5-1ubuntu14) bionic; urgency=medium + + * Clean up symlink'd /etc/zfs/zed.d/zed-functions.sh (LP: #1757939) + If an existing zed-functions is a symlink then this needs removing + as the script in newer ZFS releases is no longer symlink'd and we + always want to upgrade to the newer updated script. + + -- Colin Ian King Mon, 9 Apr 2018 13:20:37 +0100 + +zfs-linux (0.7.5-1ubuntu13) bionic; urgency=medium + + * Allow multiple mounts of zfs datasets (LP: #1759848) + - Change zpl_mount() to call sget() directly with it's own test + callback. Passing the objset_t object as the fs data allows + checking if a superblock already exists for the dataset, and in + that case we just need to return a new reference for the sb's + root dentry. + + -- Colin Ian King Thu, 29 Mar 2018 13:58:22 +0100 + +zfs-linux (0.7.5-1ubuntu12) bionic; urgency=medium + + * Fix mmap'd libaio read on non-prefaulted page deadlock (LP: #1754584) + - Revert previous fix as there still is a potential for deadlock + on the prefaulted page(s). Resolve the issue by only taking a + reference on the page when copying it and not the page lock. + The inode range lock protects against concurrent updates via + zfs_read() and zfs_write(). + + -- Colin Ian King Wed, 28 Mar 2018 08:56:18 +0100 + +zfs-linux (0.7.5-1ubuntu11) bionic; urgency=medium + + * Fix mmap'd libaio read on non-prefaulted page deadlock (LP: #1754584) + - ensure page is pre-faulted in to avoid deadlock + + -- Colin Ian King Mon, 26 Mar 2018 09:29:23 +0100 + +zfs-linux (0.7.5-1ubuntu10) bionic; urgency=medium + + * debian/control.in: Make zfs-modules | zfs-dkms Suggests for zfs-zed too. + + -- Adam Conrad Sat, 24 Mar 2018 00:41:39 -0600 + +zfs-linux (0.7.5-1ubuntu9) bionic; urgency=medium + + * Move zfs-modules | zfs-dkms to Suggests for zfsutils-linux (LP: #1756116) + - redo this again, I should have modified ./debian/control.in, + modules are built-in, so we can make zfs-modules | zfs-dkms as + a Suggests for zfsutils-linux + + -- Colin Ian King Fri, 23 Mar 2018 14:28:11 +0000 + +zfs-linux (0.7.5-1ubuntu8) bionic; urgency=medium + + * Add ZFS 0.6.x kernel ioctl binary compat shim (LP: #1751796) + Detect ZFS kernel driver version and copy zfs ioctl command to the + newer ZFS 0.7.0 ioctl command layout. + + -- Colin Ian King Thu, 22 Mar 2018 12:00:32 +0000 + +zfs-linux (0.7.5-1ubuntu7) bionic; urgency=medium + + * Move zfs-modules | zfs-dkms to Suggests for zfsutils-linux (LP: #1756116) + - modules are built-in, so we can make zfs-modules | zfs-dkms as + a Suggests for zfsutils-linux + + -- Colin Ian King Thu, 15 Mar 2018 15:16:18 +0000 + +zfs-linux (0.7.5-1ubuntu6) bionic; urgency=medium + + * Fix ARC hit rate (LP: #1755158) + - Upstream fix, commit 0873bb6337452e3e028e40f5dad945b30deab185, + fixes issue that can impact ARC hit rate especially with a + small ARC + + -- Colin Ian King Mon, 12 Mar 2018 12:40:22 +0000 + +zfs-linux (0.7.5-1ubuntu5) bionic; urgency=medium + + * Fix ZFS setgid broken on 0.7 (LP: #1753288) + Pull in upstream commit 0e85048f53e4, namely: + "Take user namespaces into account in policy checks" + - Change file related checks to use user namespaces and make + sure involved uids/gids are mappable in the current + namespace. + + -- Colin Ian King Thu, 8 Mar 2018 09:10:00 +0000 + +zfs-linux (0.7.5-1ubuntu4) bionic; urgency=medium + + * Fix up broken systemd service scripts (LP: #1741081) + - Remove redundant Requires=zfs-load-module.service from + zfs-load-module.service and add missing + After=zfs-load-module.service from zfs-import-cache.service + and zfs-import-scan.service as suggested by comment #11 + of bug LP1741081 (kudos to Richard Laager for the suggested + fixes). + * Fix debian/control XSBC-Original-Maintainer and Maintainer fields + - ensure the correct email addresses are set + + -- Colin Ian King Sat, 3 Mar 2018 13:56:11 +0000 + +zfs-linux (0.7.5-1ubuntu3) bionic; urgency=medium + + * Add new module loading systemd service (LP: #1741081) + - loads zfs module unconditionally, and make the + zfs-import-cache.service and zfs-import-scan.service services + require this service. + + -- Colin Ian King Fri, 2 Mar 2018 11:47:12 +0000 + +zfs-linux (0.7.5-1ubuntu2) bionic; urgency=medium + + * Bump version and re-upload + + -- Colin Ian King Fri, 23 Feb 2018 11:15:17 +0000 + +zfs-linux (0.7.5-1ubuntu1) bionic; urgency=medium + + * New upstream version 0.7.5 (LP: #1734172) + + -- Colin Ian King Fri, 26 Jan 2018 14:41:22 +0000 + zfs-linux (0.7.5-1) unstable; urgency=medium [ Aron Xu ] diff -Nru zfs-linux-0.7.5/debian/control zfs-linux-0.7.5/debian/control --- zfs-linux-0.7.5/debian/control 2018-01-19 07:39:23.000000000 +0000 +++ zfs-linux-0.7.5/debian/control 2018-04-17 09:18:54.000000000 +0000 @@ -1,7 +1,8 @@ Source: zfs-linux Section: contrib/kernel Priority: optional -Maintainer: Debian ZFS on Linux maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian ZFS on Linux maintainers Uploaders: Aron Xu , Petter Reinholdtsen , Carlos Alberto Lopez Perez @@ -127,9 +128,9 @@ Section: contrib/admin Architecture: linux-any Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends}, python3 -Recommends: lsb-base, zfs-modules | zfs-dkms, zfs-zed +Recommends: lsb-base, zfs-zed Breaks: zfs-dkms (>> ${binary:Version}), zfs-dkms (<< ${binary:Version}) -Suggests: nfs-kernel-server, samba-common-bin (>= 3.0.23), zfs-initramfs | zfs-dracut +Suggests: nfs-kernel-server, samba-common-bin (>= 3.0.23), zfs-initramfs | zfs-dracut, zfs-modules | zfs-dkms Conflicts: zfs, zfs-fuse, zutils Provides: zfsutils Description: command-line tools to manage OpenZFS filesystems @@ -143,7 +144,8 @@ Package: zfs-zed Section: contrib/admin Architecture: linux-any -Depends: ${misc:Depends}, ${shlibs:Depends}, zfs-modules | zfs-dkms, zfsutils-linux (>= ${binary:Version}) +Depends: ${misc:Depends}, ${shlibs:Depends}, zfsutils-linux (>= ${binary:Version}) +Suggests: zfs-modules | zfs-dkms Description: OpenZFS Event Daemon The Z file system is a pooled filesystem designed for maximum data integrity, supporting data snapshots, multiple copies, and data diff -Nru zfs-linux-0.7.5/debian/control.in zfs-linux-0.7.5/debian/control.in --- zfs-linux-0.7.5/debian/control.in 2018-01-19 07:39:23.000000000 +0000 +++ zfs-linux-0.7.5/debian/control.in 2018-03-24 06:41:01.000000000 +0000 @@ -1,7 +1,8 @@ Source: zfs-linux Section: contrib/kernel Priority: optional -Maintainer: Debian ZFS on Linux maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian ZFS on Linux maintainers Uploaders: Aron Xu , Petter Reinholdtsen , Carlos Alberto Lopez Perez @@ -127,9 +128,9 @@ Section: contrib/admin Architecture: linux-any Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends}, python3 -Recommends: lsb-base, zfs-modules | zfs-dkms, zfs-zed +Recommends: lsb-base, zfs-zed Breaks: zfs-dkms (>> ${binary:Version}), zfs-dkms (<< ${binary:Version}) -Suggests: nfs-kernel-server, samba-common-bin (>= 3.0.23), zfs-initramfs | zfs-dracut +Suggests: nfs-kernel-server, samba-common-bin (>= 3.0.23), zfs-initramfs | zfs-dracut, zfs-modules | zfs-dkms Conflicts: zfs, zfs-fuse, zutils Provides: zfsutils Description: command-line tools to manage OpenZFS filesystems @@ -143,7 +144,8 @@ Package: zfs-zed Section: contrib/admin Architecture: linux-any -Depends: ${misc:Depends}, ${shlibs:Depends}, zfs-modules | zfs-dkms, zfsutils-linux (>= ${binary:Version}) +Depends: ${misc:Depends}, ${shlibs:Depends}, zfsutils-linux (>= ${binary:Version}) +Suggests: zfs-modules | zfs-dkms Description: OpenZFS Event Daemon The Z file system is a pooled filesystem designed for maximum data integrity, supporting data snapshots, multiple copies, and data diff -Nru zfs-linux-0.7.5/debian/patches/2100-zfs-load-module.patch zfs-linux-0.7.5/debian/patches/2100-zfs-load-module.patch --- zfs-linux-0.7.5/debian/patches/2100-zfs-load-module.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2100-zfs-load-module.patch 2018-03-03 13:53:13.000000000 +0000 @@ -0,0 +1,87 @@ +Index: zfs-linux-0.7.5/etc/systemd/system/zfs-load-module.service.in +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/etc/systemd/system/zfs-load-module.service.in +@@ -0,0 +1,18 @@ ++[Unit] ++Description=Install ZFS kernel module ++DefaultDependencies=no ++Requires=systemd-udev-settle.service ++After=systemd-udev-settle.service ++After=cryptsetup.target ++Before=dracut-mount.service ++After=systemd-remount-fs.service ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=/sbin/modprobe zfs ++ ++[Install] ++WantedBy=zfs-mount.service ++WantedBy=zfs.target ++ +Index: zfs-linux-0.7.5/etc/systemd/system/zfs-import-cache.service.in +=================================================================== +--- zfs-linux-0.7.5.orig/etc/systemd/system/zfs-import-cache.service.in ++++ zfs-linux-0.7.5/etc/systemd/system/zfs-import-cache.service.in +@@ -3,7 +3,9 @@ Description=Import ZFS pools by cache fi + Documentation=man:zpool(8) + DefaultDependencies=no + Requires=systemd-udev-settle.service ++Requires=zfs-load-module.service + After=systemd-udev-settle.service ++After=zfs-load-module.service + After=cryptsetup.target + After=systemd-remount-fs.service + Before=dracut-mount.service +@@ -13,7 +15,6 @@ ConditionPathExists=@sysconfdir@/zfs/zpo + [Service] + Type=oneshot + RemainAfterExit=yes +-ExecStartPre=/sbin/modprobe zfs + ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN + + [Install] +Index: zfs-linux-0.7.5/etc/systemd/system/zfs-import-scan.service.in +=================================================================== +--- zfs-linux-0.7.5.orig/etc/systemd/system/zfs-import-scan.service.in ++++ zfs-linux-0.7.5/etc/systemd/system/zfs-import-scan.service.in +@@ -3,7 +3,9 @@ Description=Import ZFS pools by device s + Documentation=man:zpool(8) + DefaultDependencies=no + Requires=systemd-udev-settle.service ++Requires=zfs-load-module.service + After=systemd-udev-settle.service ++After=zfs-load-module.service + After=cryptsetup.target + Before=dracut-mount.service + Before=zfs-import.target +@@ -12,7 +14,6 @@ ConditionPathExists=!@sysconfdir@/zfs/zp + [Service] + Type=oneshot + RemainAfterExit=yes +-ExecStartPre=/sbin/modprobe zfs + ExecStart=@sbindir@/zpool import -aN -o cachefile=none + + [Install] +Index: zfs-linux-0.7.5/etc/systemd/system/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/etc/systemd/system/Makefile.am ++++ zfs-linux-0.7.5/etc/systemd/system/Makefile.am +@@ -2,6 +2,7 @@ systemdpreset_DATA = \ + 50-zfs.preset + + systemdunit_DATA = \ ++ zfs-load-module.service \ + zfs-zed.service \ + zfs-import-cache.service \ + zfs-import-scan.service \ +@@ -11,6 +12,7 @@ systemdunit_DATA = \ + zfs.target + + EXTRA_DIST = \ ++ $(top_srcdir)/etc/systemd/system/zfs-load-module.service \ + $(top_srcdir)/etc/systemd/system/zfs-zed.service.in \ + $(top_srcdir)/etc/systemd/system/zfs-import-cache.service.in \ + $(top_srcdir)/etc/systemd/system/zfs-import-scan.service.in \ diff -Nru zfs-linux-0.7.5/debian/patches/2101-Take-user-namespaces-into-account-in-policy-checks.patch zfs-linux-0.7.5/debian/patches/2101-Take-user-namespaces-into-account-in-policy-checks.patch --- zfs-linux-0.7.5/debian/patches/2101-Take-user-namespaces-into-account-in-policy-checks.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2101-Take-user-namespaces-into-account-in-policy-checks.patch 2018-03-08 08:15:15.000000000 +0000 @@ -0,0 +1,710 @@ +Index: zfs-linux-0.7.5/config/kernel-userns-capabilities.m4 +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/config/kernel-userns-capabilities.m4 +@@ -0,0 +1,67 @@ ++dnl # ++dnl # 2.6.38 API change ++dnl # ns_capable() was introduced ++dnl # ++AC_DEFUN([ZFS_AC_KERNEL_NS_CAPABLE], [ ++ AC_MSG_CHECKING([whether ns_capable exists]) ++ ZFS_LINUX_TRY_COMPILE([ ++ #include ++ ],[ ++ ns_capable((struct user_namespace *)NULL, CAP_SYS_ADMIN); ++ ],[ ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_NS_CAPABLE, 1, ++ [ns_capable exists]) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) ++]) ++ ++dnl # ++dnl # 2.6.39 API change ++dnl # struct user_namespace was added to struct cred_t as ++dnl # cred->user_ns member ++dnl # Note that current_user_ns() was added in 2.6.28. ++dnl # ++AC_DEFUN([ZFS_AC_KERNEL_CRED_USER_NS], [ ++ AC_MSG_CHECKING([whether cred_t->user_ns exists]) ++ ZFS_LINUX_TRY_COMPILE([ ++ #include ++ ],[ ++ struct cred cr; ++ cr.user_ns = (struct user_namespace *)NULL; ++ ],[ ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_CRED_USER_NS, 1, ++ [cred_t->user_ns exists]) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) ++]) ++ ++dnl # ++dnl # 3.4 API change ++dnl # kuid_has_mapping() and kgid_has_mapping() were added to distinguish ++dnl # between internal kernel uids/gids and user namespace uids/gids. ++dnl # ++AC_DEFUN([ZFS_AC_KERNEL_KUID_HAS_MAPPING], [ ++ AC_MSG_CHECKING([whether kuid_has_mapping/kgid_has_mapping exist]) ++ ZFS_LINUX_TRY_COMPILE([ ++ #include ++ ],[ ++ kuid_has_mapping((struct user_namespace *)NULL, KUIDT_INIT(0)); ++ kgid_has_mapping((struct user_namespace *)NULL, KGIDT_INIT(0)); ++ ],[ ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_KUID_HAS_MAPPING, 1, ++ [kuid_has_mapping/kgid_has_mapping exist]) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) ++]) ++ ++AC_DEFUN([ZFS_AC_KERNEL_USERNS_CAPABILITIES], [ ++ ZFS_AC_KERNEL_NS_CAPABLE ++ ZFS_AC_KERNEL_CRED_USER_NS ++ ZFS_AC_KERNEL_KUID_HAS_MAPPING ++]) +Index: zfs-linux-0.7.5/config/kernel.m4 +=================================================================== +--- zfs-linux-0.7.5.orig/config/kernel.m4 ++++ zfs-linux-0.7.5/config/kernel.m4 +@@ -123,6 +123,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ + ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR + ZFS_AC_KERNEL_CURRENT_TIME + ZFS_AC_KERNEL_VM_NODE_STAT ++ ZFS_AC_KERNEL_USERNS_CAPABILITIES + + AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ + KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" +Index: zfs-linux-0.7.5/configure.ac +=================================================================== +--- zfs-linux-0.7.5.orig/configure.ac ++++ zfs-linux-0.7.5/configure.ac +@@ -151,6 +151,7 @@ AC_CONFIG_FILES([ + tests/zfs-tests/callbacks/Makefile + tests/zfs-tests/cmd/Makefile + tests/zfs-tests/cmd/chg_usr_exec/Makefile ++ tests/zfs-tests/cmd/user_ns_exec/Makefile + tests/zfs-tests/cmd/devname2devid/Makefile + tests/zfs-tests/cmd/dir_rd_update/Makefile + tests/zfs-tests/cmd/file_check/Makefile +@@ -282,6 +283,7 @@ AC_CONFIG_FILES([ + tests/zfs-tests/tests/functional/threadsappend/Makefile + tests/zfs-tests/tests/functional/tmpfile/Makefile + tests/zfs-tests/tests/functional/truncate/Makefile ++ tests/zfs-tests/tests/functional/user_namespace/Makefile + tests/zfs-tests/tests/functional/userquota/Makefile + tests/zfs-tests/tests/functional/upgrade/Makefile + tests/zfs-tests/tests/functional/vdev_zaps/Makefile +Index: zfs-linux-0.7.5/module/zfs/policy.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/policy.c ++++ zfs-linux-0.7.5/module/zfs/policy.c +@@ -42,19 +42,47 @@ + * all other cases this function must fail and return the passed err. + */ + static int +-priv_policy(const cred_t *cr, int capability, boolean_t all, int err) ++priv_policy_ns(const cred_t *cr, int capability, boolean_t all, int err, ++ struct user_namespace *ns) + { + ASSERT3S(all, ==, B_FALSE); + + if (cr != CRED() && (cr != kcred)) + return (err); + ++#if defined(CONFIG_USER_NS) && defined(HAVE_NS_CAPABLE) ++ if (!(ns ? ns_capable(ns, capability) : capable(capability))) ++#else + if (!capable(capability)) ++#endif + return (err); + + return (0); + } + ++static int ++priv_policy(const cred_t *cr, int capability, boolean_t all, int err) ++{ ++ return (priv_policy_ns(cr, capability, all, err, NULL)); ++} ++ ++static int ++priv_policy_user(const cred_t *cr, int capability, boolean_t all, int err) ++{ ++ /* ++ * All priv_policy_user checks are preceeded by kuid/kgid_has_mapping() ++ * checks. If we cannot do them, we shouldn't be using ns_capable() ++ * since we don't know whether the affected files are valid in our ++ * namespace. Note that kuid_has_mapping() came after cred->user_ns, so ++ * we shouldn't need to re-check for HAVE_CRED_USER_NS ++ */ ++#if defined(CONFIG_USER_NS) && defined(HAVE_KUID_HAS_MAPPING) ++ return (priv_policy_ns(cr, capability, all, err, cr->user_ns)); ++#else ++ return (priv_policy_ns(cr, capability, all, err, NULL)); ++#endif ++} ++ + /* + * Checks for operations that are either client-only or are used by + * both clients and servers. +@@ -102,10 +130,15 @@ secpolicy_vnode_any_access(const cred_t + if (zpl_inode_owner_or_capable(ip)) + return (0); + +- if (priv_policy(cr, CAP_DAC_OVERRIDE, B_FALSE, EPERM) == 0) ++#if defined(CONFIG_USER_NS) && defined(HAVE_KUID_HAS_MAPPING) ++ if (!kuid_has_mapping(cr->user_ns, SUID_TO_KUID(owner))) ++ return (EPERM); ++#endif ++ ++ if (priv_policy_user(cr, CAP_DAC_OVERRIDE, B_FALSE, EPERM) == 0) + return (0); + +- if (priv_policy(cr, CAP_DAC_READ_SEARCH, B_FALSE, EPERM) == 0) ++ if (priv_policy_user(cr, CAP_DAC_READ_SEARCH, B_FALSE, EPERM) == 0) + return (0); + + return (EPERM); +@@ -120,7 +153,12 @@ secpolicy_vnode_chown(const cred_t *cr, + if (crgetfsuid(cr) == owner) + return (0); + +- return (priv_policy(cr, CAP_FOWNER, B_FALSE, EPERM)); ++#if defined(CONFIG_USER_NS) && defined(HAVE_KUID_HAS_MAPPING) ++ if (!kuid_has_mapping(cr->user_ns, SUID_TO_KUID(owner))) ++ return (EPERM); ++#endif ++ ++ return (priv_policy_user(cr, CAP_FOWNER, B_FALSE, EPERM)); + } + + /* +@@ -152,7 +190,12 @@ secpolicy_vnode_setdac(const cred_t *cr, + if (crgetfsuid(cr) == owner) + return (0); + +- return (priv_policy(cr, CAP_FOWNER, B_FALSE, EPERM)); ++#if defined(CONFIG_USER_NS) && defined(HAVE_KUID_HAS_MAPPING) ++ if (!kuid_has_mapping(cr->user_ns, SUID_TO_KUID(owner))) ++ return (EPERM); ++#endif ++ ++ return (priv_policy_user(cr, CAP_FOWNER, B_FALSE, EPERM)); + } + + /* +@@ -175,8 +218,12 @@ secpolicy_vnode_setid_retain(const cred_ + int + secpolicy_vnode_setids_setgids(const cred_t *cr, gid_t gid) + { ++#if defined(CONFIG_USER_NS) && defined(HAVE_KUID_HAS_MAPPING) ++ if (!kgid_has_mapping(cr->user_ns, SGID_TO_KGID(gid))) ++ return (EPERM); ++#endif + if (crgetfsgid(cr) != gid && !groupmember(gid, cr)) +- return (priv_policy(cr, CAP_FSETID, B_FALSE, EPERM)); ++ return (priv_policy_user(cr, CAP_FSETID, B_FALSE, EPERM)); + + return (0); + } +@@ -222,7 +269,12 @@ secpolicy_vnode_setid_modify(const cred_ + if (crgetfsuid(cr) == owner) + return (0); + +- return (priv_policy(cr, CAP_FSETID, B_FALSE, EPERM)); ++#if defined(CONFIG_USER_NS) && defined(HAVE_KUID_HAS_MAPPING) ++ if (!kuid_has_mapping(cr->user_ns, SUID_TO_KUID(owner))) ++ return (EPERM); ++#endif ++ ++ return (priv_policy_user(cr, CAP_FSETID, B_FALSE, EPERM)); + } + + /* +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -648,6 +648,10 @@ tags = ['functional', 'truncate'] + tests = [ 'upgrade_userobj_001_pos' ] + tags = ['functional', 'upgrade'] + ++[tests/functional/user_namespace] ++tests = ['user_namespace_001'] ++tags = ['functional', 'user_namespace'] ++ + [tests/functional/userquota] + tests = [ + 'userquota_001_pos', 'userquota_002_pos', 'userquota_003_pos', +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/cmd/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/Makefile.am +@@ -2,6 +2,7 @@ EXTRA_DIST = file_common.h + + SUBDIRS = \ + chg_usr_exec \ ++ user_ns_exec \ + devname2devid \ + dir_rd_update \ + file_check \ +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/user_ns_exec/.gitignore +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/user_ns_exec/.gitignore +@@ -0,0 +1 @@ ++/user_ns_exec +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/user_ns_exec/Makefile.am +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/user_ns_exec/Makefile.am +@@ -0,0 +1,6 @@ ++include $(top_srcdir)/config/Rules.am ++ ++pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin ++ ++pkgexec_PROGRAMS = user_ns_exec ++user_ns_exec_SOURCES = user_ns_exec.c +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/user_ns_exec/user_ns_exec.c +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/user_ns_exec/user_ns_exec.c +@@ -0,0 +1,179 @@ ++/* ++ * CDDL HEADER START ++ * ++ * The contents of this file are subject to the terms of the ++ * Common Development and Distribution License (the "License"). ++ * You may not use this file except in compliance with the License. ++ * ++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++ * or http://www.opensolaris.org/os/licensing. ++ * See the License for the specific language governing permissions ++ * and limitations under the License. ++ * ++ * When distributing Covered Code, include this CDDL HEADER in each ++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++ * If applicable, add the following below this CDDL HEADER, with the ++ * fields enclosed by brackets "[]" replaced with your own identifying ++ * information: Portions Copyright [yyyy] [name of copyright owner] ++ * ++ * CDDL HEADER END ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define EXECSHELL "/bin/sh" ++#define UIDMAP "0 100000 65536" ++ ++static int ++child_main(int argc, char *argv[], int sync_pipe) ++{ ++ char sync_buf; ++ char cmds[BUFSIZ] = { 0 }; ++ char sep[] = " "; ++ int i, len; ++ ++ if (unshare(CLONE_NEWUSER | CLONE_NEWNS) != 0) { ++ perror("unshare"); ++ return (1); ++ } ++ ++ /* tell parent we entered the new namespace */ ++ if (write(sync_pipe, "1", 1) != 1) { ++ perror("write"); ++ return (1); ++ } ++ ++ /* wait for parent to setup the uid mapping */ ++ if (read(sync_pipe, &sync_buf, 1) != 1) { ++ (void) fprintf(stderr, "user namespace setup failed\n"); ++ return (1); ++ } ++ ++ close(sync_pipe); ++ ++ if (setuid(0) != 0) { ++ perror("setuid"); ++ return (1); ++ } ++ if (setgid(0) != 0) { ++ perror("setgid"); ++ return (1); ++ } ++ ++ len = 0; ++ for (i = 1; i < argc; i++) { ++ (void) snprintf(cmds+len, sizeof (cmds)-len, ++ "%s%s", argv[i], sep); ++ len += strlen(argv[i]) + strlen(sep); ++ } ++ ++ if (execl(EXECSHELL, "sh", "-c", cmds, (char *)NULL) != 0) { ++ perror("execl: " EXECSHELL); ++ return (1); ++ } ++ ++ return (0); ++} ++ ++static int ++set_idmap(pid_t pid, const char *file) ++{ ++ int result = 0; ++ int mapfd; ++ char path[PATH_MAX]; ++ ++ (void) snprintf(path, sizeof (path), "/proc/%d/%s", (int)pid, file); ++ ++ mapfd = open(path, O_WRONLY); ++ if (mapfd < 0) { ++ result = errno; ++ perror("open"); ++ return (errno); ++ } ++ ++ if (write(mapfd, UIDMAP, sizeof (UIDMAP)-1) != sizeof (UIDMAP)-1) { ++ perror("write"); ++ result = (errno); ++ } ++ ++ close(mapfd); ++ ++ return (result); ++} ++ ++int ++main(int argc, char *argv[]) ++{ ++ char sync_buf; ++ int result, wstatus; ++ int syncfd[2]; ++ pid_t child; ++ ++ if (argc < 2 || strlen(argv[1]) == 0) { ++ (void) printf("\tUsage: %s ...\n", argv[0]); ++ return (1); ++ } ++ ++ if (socketpair(AF_UNIX, SOCK_STREAM, 0, syncfd) != 0) { ++ perror("socketpair"); ++ return (1); ++ } ++ ++ child = fork(); ++ if (child == (pid_t)-1) { ++ perror("fork"); ++ return (1); ++ } ++ ++ if (child == 0) { ++ close(syncfd[0]); ++ return (child_main(argc, argv, syncfd[1])); ++ } ++ ++ close(syncfd[1]); ++ ++ result = 0; ++ /* wait for the child to have unshared its namespaces */ ++ if (read(syncfd[0], &sync_buf, 1) != 1) { ++ perror("read"); ++ kill(child, SIGKILL); ++ result = 1; ++ goto reap; ++ } ++ ++ /* write uid mapping */ ++ if (set_idmap(child, "uid_map") != 0 || ++ set_idmap(child, "gid_map") != 0) { ++ result = 1; ++ kill(child, SIGKILL); ++ goto reap; ++ } ++ ++ /* tell the child to proceed */ ++ if (write(syncfd[0], "1", 1) != 1) { ++ perror("write"); ++ kill(child, SIGKILL); ++ result = 1; ++ goto reap; ++ } ++ close(syncfd[0]); ++ ++reap: ++ while (waitpid(child, &wstatus, 0) != child) ++ kill(child, SIGKILL); ++ if (result == 0) ++ result = WEXITSTATUS(wstatus); ++ ++ return (result); ++} +Index: zfs-linux-0.7.5/tests/zfs-tests/include/commands.cfg +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/include/commands.cfg ++++ zfs-linux-0.7.5/tests/zfs-tests/include/commands.cfg +@@ -163,4 +163,5 @@ export ZFSTEST_FILES='chg_usr_exec + rename_dir + rm_lnkcnt_zero_file + threadsappend ++ user_ns_exec + xattrtest' +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/Makefile.am +@@ -58,6 +58,7 @@ SUBDIRS = \ + tmpfile \ + truncate \ + upgrade \ ++ user_namespace \ + userquota \ + vdev_zaps \ + write_dirs \ +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/Makefile.am +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/Makefile.am +@@ -0,0 +1,7 @@ ++pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/user_namespace ++dist_pkgdata_SCRIPTS = \ ++ setup.ksh \ ++ cleanup.ksh \ ++ user_namespace_common.kshlib \ ++ user_namespace.cfg \ ++ user_namespace_001.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/cleanup.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/cleanup.ksh +@@ -0,0 +1,25 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++. $STF_SUITE/include/libtest.shlib ++ ++default_cleanup +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/setup.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/setup.ksh +@@ -0,0 +1,32 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++. $STF_SUITE/include/libtest.shlib ++ ++if ! [ -f /proc/self/uid_map ]; then ++ log_unsupported "The kernel doesn't support user namespaces." ++fi ++ ++verify_runnable "both" ++ ++DISK=${DISKS%% *} ++default_setup $DISK +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/user_namespace.cfg +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/user_namespace.cfg +@@ -0,0 +1,23 @@ ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++export ROOT_UID=100000 ++export OTHER_UID=101000 +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/user_namespace_001.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/user_namespace_001.ksh +@@ -0,0 +1,89 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++. $STF_SUITE/tests/functional/user_namespace/user_namespace_common.kshlib ++ ++# ++# ++# DESCRIPTION: ++# Regression test for secpolicy_vnode_setids_setgids ++# ++# ++# STRATEGY: ++# 1. Create files with various owners. ++# 2. Try to set setgid bit. ++# ++ ++verify_runnable "both" ++ ++# rroot: real root, ++# uroot: root within user namespace ++# uother: other user within user namespace ++set -A files rroot_rroot uroot_uroot uroot_other uother_uroot uother_uother ++ ++function cleanup ++{ ++ for i in ${files[*]}; do ++ log_must rm -f $TESTDIR/$i ++ done ++} ++ ++log_onexit cleanup ++ ++log_assert "Check root in user namespaces" ++ ++TOUCH=$(readlink -e $(which touch)) ++CHMOD=$(readlink -e $(which chmod)) ++ ++for i in ${files[*]}; do ++ log_must $TOUCH $TESTDIR/$i ++ log_must $CHMOD 0644 $TESTDIR/$i ++done ++ ++log_must chown 0:0 $TESTDIR/rroot_rroot ++log_must chown $ROOT_UID:$ROOT_UID $TESTDIR/uroot_uroot ++log_must chown $ROOT_UID:$OTHER_UID $TESTDIR/uroot_other ++log_must chown $OTHER_UID:$ROOT_UID $TESTDIR/uother_uroot ++log_must chown $OTHER_UID:$OTHER_UID $TESTDIR/uother_uother ++ ++log_mustnot user_ns_exec $CHMOD 02755 $TESTDIR/rroot_rroot ++log_mustnot test -g $TESTDIR/rroot_rroot ++ ++log_must user_ns_exec $CHMOD 02755 $TESTDIR/uroot_uroot ++log_must test -g $TESTDIR/uroot_uroot ++ ++log_must user_ns_exec $CHMOD 02755 $TESTDIR/uroot_other ++log_must test -g $TESTDIR/uroot_other ++ ++log_must user_ns_exec $CHMOD 02755 $TESTDIR/uother_uroot ++log_must test -g $TESTDIR/uother_uroot ++ ++log_must user_ns_exec $CHMOD 02755 $TESTDIR/uother_uother ++log_must test -g $TESTDIR/uother_uother ++ ++log_mustnot user_ns_exec $TOUCH $TESTDIR/rroot_rroot ++log_must $CHMOD 0666 $TESTDIR/rroot_rroot ++for i in ${files[*]}; do ++ log_must user_ns_exec $TOUCH $TESTDIR/$i ++done ++ ++log_pass "Check root in user namespaces" +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/user_namespace_common.kshlib +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/user_namespace/user_namespace_common.kshlib +@@ -0,0 +1,23 @@ ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++. $STF_SUITE/include/libtest.shlib ++. $STF_SUITE/tests/functional/user_namespace/user_namespace.cfg diff -Nru zfs-linux-0.7.5/debian/patches/2102-Fix-ARC-hit-rate.patch zfs-linux-0.7.5/debian/patches/2102-Fix-ARC-hit-rate.patch --- zfs-linux-0.7.5/debian/patches/2102-Fix-ARC-hit-rate.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2102-Fix-ARC-hit-rate.patch 2018-03-12 12:40:22.000000000 +0000 @@ -0,0 +1,197 @@ +From 0873bb6337452e3e028e40f5dad945b30deab185 Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf +Date: Mon, 8 Jan 2018 09:52:36 -0800 +Subject: [PATCH] Fix ARC hit rate +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +When the compressed ARC feature was added in commit d3c2ae1 +the method of reference counting in the ARC was modified. As +part of this accounting change the arc_buf_add_ref() function +was removed entirely. + +This would have be fine but the arc_buf_add_ref() function +served a second undocumented purpose of updating the ARC access +information when taking a hold on a dbuf. Without this logic +in place a cached dbuf would not migrate its associated +arc_buf_hdr_t to the MFU list. This would negatively impact +the ARC hit rate, particularly on systems with a small ARC. + +This change reinstates the missing call to arc_access() from +dbuf_hold() by implementing a new arc_buf_access() function. + +Reviewed-by: Giuseppe Di Natale +Reviewed-by: Tony Hutter +Reviewed-by: Tim Chase +Reviewed by: George Wilson +Reviewed-by: George Melikov +Signed-off-by: Brian Behlendorf +Closes #6171 +Closes #6852 +Closes #6989 + +Index: zfs-linux-0.7.5/include/sys/arc.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/sys/arc.h ++++ zfs-linux-0.7.5/include/sys/arc.h +@@ -95,35 +95,36 @@ typedef enum arc_flags + ARC_FLAG_CACHED = 1 << 3, /* I/O was in cache */ + ARC_FLAG_L2CACHE = 1 << 4, /* cache in L2ARC */ + ARC_FLAG_PREDICTIVE_PREFETCH = 1 << 5, /* I/O from zfetch */ ++ ARC_FLAG_PRESCIENT_PREFETCH = 1 << 6, /* long min lifespan */ + + /* + * Private ARC flags. These flags are private ARC only flags that + * will show up in b_flags in the arc_hdr_buf_t. These flags should + * only be set by ARC code. + */ +- ARC_FLAG_IN_HASH_TABLE = 1 << 6, /* buffer is hashed */ +- ARC_FLAG_IO_IN_PROGRESS = 1 << 7, /* I/O in progress */ +- ARC_FLAG_IO_ERROR = 1 << 8, /* I/O failed for buf */ +- ARC_FLAG_INDIRECT = 1 << 9, /* indirect block */ ++ ARC_FLAG_IN_HASH_TABLE = 1 << 7, /* buffer is hashed */ ++ ARC_FLAG_IO_IN_PROGRESS = 1 << 8, /* I/O in progress */ ++ ARC_FLAG_IO_ERROR = 1 << 9, /* I/O failed for buf */ ++ ARC_FLAG_INDIRECT = 1 << 10, /* indirect block */ + /* Indicates that block was read with ASYNC priority. */ +- ARC_FLAG_PRIO_ASYNC_READ = 1 << 10, +- ARC_FLAG_L2_WRITING = 1 << 11, /* write in progress */ +- ARC_FLAG_L2_EVICTED = 1 << 12, /* evicted during I/O */ +- ARC_FLAG_L2_WRITE_HEAD = 1 << 13, /* head of write list */ ++ ARC_FLAG_PRIO_ASYNC_READ = 1 << 11, ++ ARC_FLAG_L2_WRITING = 1 << 12, /* write in progress */ ++ ARC_FLAG_L2_EVICTED = 1 << 13, /* evicted during I/O */ ++ ARC_FLAG_L2_WRITE_HEAD = 1 << 14, /* head of write list */ + /* indicates that the buffer contains metadata (otherwise, data) */ +- ARC_FLAG_BUFC_METADATA = 1 << 14, ++ ARC_FLAG_BUFC_METADATA = 1 << 15, + + /* Flags specifying whether optional hdr struct fields are defined */ +- ARC_FLAG_HAS_L1HDR = 1 << 15, +- ARC_FLAG_HAS_L2HDR = 1 << 16, ++ ARC_FLAG_HAS_L1HDR = 1 << 16, ++ ARC_FLAG_HAS_L2HDR = 1 << 17, + + /* + * Indicates the arc_buf_hdr_t's b_pdata matches the on-disk data. + * This allows the l2arc to use the blkptr's checksum to verify + * the data without having to store the checksum in the hdr. + */ +- ARC_FLAG_COMPRESSED_ARC = 1 << 17, +- ARC_FLAG_SHARED_DATA = 1 << 18, ++ ARC_FLAG_COMPRESSED_ARC = 1 << 18, ++ ARC_FLAG_SHARED_DATA = 1 << 19, + + /* + * The arc buffer's compression mode is stored in the top 7 bits of the +@@ -221,6 +222,7 @@ void arc_buf_destroy(arc_buf_t *buf, voi + void arc_buf_info(arc_buf_t *buf, arc_buf_info_t *abi, int state_index); + uint64_t arc_buf_size(arc_buf_t *buf); + uint64_t arc_buf_lsize(arc_buf_t *buf); ++void arc_buf_access(arc_buf_t *buf); + void arc_release(arc_buf_t *buf, void *tag); + int arc_released(arc_buf_t *buf); + void arc_buf_sigsegv(int sig, siginfo_t *si, void *unused); +Index: zfs-linux-0.7.5/module/zfs/arc.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/arc.c ++++ zfs-linux-0.7.5/module/zfs/arc.c +@@ -430,8 +430,13 @@ typedef struct arc_stats { + */ + kstat_named_t arcstat_mutex_miss; + /* ++ * Number of buffers skipped when updating the access state due to the ++ * header having already been released after acquiring the hash lock. ++ */ ++ kstat_named_t arcstat_access_skip; ++ /* + * Number of buffers skipped because they have I/O in progress, are +- * indrect prefetch buffers that have not lived long enough, or are ++ * indirect prefetch buffers that have not lived long enough, or are + * not from the spa we're trying to evict from. + */ + kstat_named_t arcstat_evict_skip; +@@ -667,6 +672,7 @@ static arc_stats_t arc_stats = { + { "mfu_ghost_hits", KSTAT_DATA_UINT64 }, + { "deleted", KSTAT_DATA_UINT64 }, + { "mutex_miss", KSTAT_DATA_UINT64 }, ++ { "access_skip", KSTAT_DATA_UINT64 }, + { "evict_skip", KSTAT_DATA_UINT64 }, + { "evict_not_enough", KSTAT_DATA_UINT64 }, + { "evict_l2_cached", KSTAT_DATA_UINT64 }, +@@ -840,6 +846,8 @@ static taskq_t *arc_prune_taskq; + #define HDR_IO_IN_PROGRESS(hdr) ((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) + #define HDR_IO_ERROR(hdr) ((hdr)->b_flags & ARC_FLAG_IO_ERROR) + #define HDR_PREFETCH(hdr) ((hdr)->b_flags & ARC_FLAG_PREFETCH) ++#define HDR_PRESCIENT_PREFETCH(hdr) \ ++ ((hdr)->b_flags & ARC_FLAG_PRESCIENT_PREFETCH) + #define HDR_COMPRESSION_ENABLED(hdr) \ + ((hdr)->b_flags & ARC_FLAG_COMPRESSED_ARC) + +@@ -4926,6 +4934,50 @@ arc_access(arc_buf_hdr_t *hdr, kmutex_t + } + } + ++/* ++ * This routine is called by dbuf_hold() to update the arc_access() state ++ * which otherwise would be skipped for entries in the dbuf cache. ++ */ ++void ++arc_buf_access(arc_buf_t *buf) ++{ ++ mutex_enter(&buf->b_evict_lock); ++ arc_buf_hdr_t *hdr = buf->b_hdr; ++ ++ /* ++ * Avoid taking the hash_lock when possible as an optimization. ++ * The header must be checked again under the hash_lock in order ++ * to handle the case where it is concurrently being released. ++ */ ++ if (hdr->b_l1hdr.b_state == arc_anon || HDR_EMPTY(hdr)) { ++ mutex_exit(&buf->b_evict_lock); ++ return; ++ } ++ ++ kmutex_t *hash_lock = HDR_LOCK(hdr); ++ mutex_enter(hash_lock); ++ ++ if (hdr->b_l1hdr.b_state == arc_anon || HDR_EMPTY(hdr)) { ++ mutex_exit(hash_lock); ++ mutex_exit(&buf->b_evict_lock); ++ ARCSTAT_BUMP(arcstat_access_skip); ++ return; ++ } ++ ++ mutex_exit(&buf->b_evict_lock); ++ ++ ASSERT(hdr->b_l1hdr.b_state == arc_mru || ++ hdr->b_l1hdr.b_state == arc_mfu); ++ ++ DTRACE_PROBE1(arc__hit, arc_buf_hdr_t *, hdr); ++ arc_access(hdr, hash_lock); ++ mutex_exit(hash_lock); ++ ++ ARCSTAT_BUMP(arcstat_hits); ++ ARCSTAT_CONDSTAT(!HDR_PREFETCH(hdr) && !HDR_PRESCIENT_PREFETCH(hdr), ++ demand, prefetch, !HDR_ISTYPE_METADATA(hdr), data, metadata, hits); ++} ++ + /* a generic arc_done_func_t which you can use */ + /* ARGSUSED */ + void +Index: zfs-linux-0.7.5/module/zfs/dbuf.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dbuf.c ++++ zfs-linux-0.7.5/module/zfs/dbuf.c +@@ -2719,8 +2719,10 @@ __dbuf_hold_impl(struct dbuf_hold_impl_d + return (SET_ERROR(ENOENT)); + } + +- if (dh->dh_db->db_buf != NULL) ++ if (dh->dh_db->db_buf != NULL) { ++ arc_buf_access(dh->dh_db->db_buf); + ASSERT3P(dh->dh_db->db.db_data, ==, dh->dh_db->db_buf->b_data); ++ } + + ASSERT(dh->dh_db->db_buf == NULL || arc_referenced(dh->dh_db->db_buf)); + diff -Nru zfs-linux-0.7.5/debian/patches/2200-add-zfs-0.6.x-ioctl-compat-shim.patch zfs-linux-0.7.5/debian/patches/2200-add-zfs-0.6.x-ioctl-compat-shim.patch --- zfs-linux-0.7.5/debian/patches/2200-add-zfs-0.6.x-ioctl-compat-shim.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2200-add-zfs-0.6.x-ioctl-compat-shim.patch 2018-03-22 12:00:32.000000000 +0000 @@ -0,0 +1,247 @@ +Add a ZFS 0.6.x ioctl compat shim for 0.7.x userspace + +This adds a compat shim that transforms a 0.6.x userspace ioctl +command structure to/from a 0.7.x version. Also add in a kernel ZFS +driver version number check to allow the ioctl interface use either +0.6.x or 0.7.x kernel driver. + +Signed-off-by: Colin Ian King + +Index: zfs-linux-0.7.5/include/sys/zfs_ioctl.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/sys/zfs_ioctl.h ++++ zfs-linux-0.7.5/include/sys/zfs_ioctl.h +@@ -328,6 +328,25 @@ typedef struct zinject_record { + uint32_t zi_pad; + } zinject_record_t; + ++typedef struct zinject_record_V065 { ++ uint64_t zi_objset; ++ uint64_t zi_object; ++ uint64_t zi_start; ++ uint64_t zi_end; ++ uint64_t zi_guid; ++ uint32_t zi_level; ++ uint32_t zi_error; ++ uint64_t zi_type; ++ uint32_t zi_freq; ++ uint32_t zi_failfast; ++ char zi_func[MAXNAMELEN]; ++ uint32_t zi_iotype; ++ int32_t zi_duration; ++ uint64_t zi_timer; ++ uint32_t zi_cmd; ++ uint32_t zi_pad; ++} zinject_record_V065_t; ++ + #define ZINJECT_NULL 0x1 + #define ZINJECT_FLUSH_ARC 0x2 + #define ZINJECT_UNLOAD_SPA 0x4 +@@ -420,6 +439,48 @@ typedef struct zfs_cmd { + zfs_stat_t zc_stat; + } zfs_cmd_t; + ++typedef struct zfs_cmd_V065 { ++ char zc_name[MAXPATHLEN]; /* name of pool or dataset */ ++ uint64_t zc_nvlist_src; /* really (char *) */ ++ uint64_t zc_nvlist_src_size; ++ uint64_t zc_nvlist_dst; /* really (char *) */ ++ uint64_t zc_nvlist_dst_size; ++ boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ ++ int zc_pad2; ++ ++ /* ++ * The following members are for legacy ioctls which haven't been ++ * converted to the new method. ++ */ ++ uint64_t zc_history; /* really (char *) */ ++ char zc_value[MAXPATHLEN * 2]; ++ char zc_string[MAXNAMELEN]; ++ uint64_t zc_guid; ++ uint64_t zc_nvlist_conf; /* really (char *) */ ++ uint64_t zc_nvlist_conf_size; ++ uint64_t zc_cookie; ++ uint64_t zc_objset_type; ++ uint64_t zc_perm_action; ++ uint64_t zc_history_len; ++ uint64_t zc_history_offset; ++ uint64_t zc_obj; ++ uint64_t zc_iflags; /* internal to zfs(7fs) */ ++ zfs_share_t zc_share; ++ dmu_objset_stats_t zc_objset_stats; ++ struct drr_begin zc_begin_record; ++ zinject_record_V065_t zc_inject_record; ++ uint32_t zc_defer_destroy; ++ uint32_t zc_flags; ++ uint64_t zc_action_handle; ++ int zc_cleanup_fd; ++ uint8_t zc_simple; ++ uint8_t zc_pad[3]; /* alignment */ ++ uint64_t zc_sendobj; ++ uint64_t zc_fromobj; ++ uint64_t zc_createtxg; ++ zfs_stat_t zc_stat; ++} zfs_cmd_V065_t; ++ + typedef struct zfs_useracct { + char zu_domain[256]; + uid_t zu_rid; +Index: zfs-linux-0.7.5/lib/libzfs/libzfs_util.c +=================================================================== +--- zfs-linux-0.7.5.orig/lib/libzfs/libzfs_util.c ++++ zfs-linux-0.7.5/lib/libzfs/libzfs_util.c +@@ -50,6 +50,8 @@ + #include + #include + ++static int zfs_major_ver, zfs_minor_ver; ++ + #include "libzfs_impl.h" + #include "zfs_prop.h" + #include "zfeature_common.h" +@@ -745,12 +747,23 @@ libzfs_print_on_error(libzfs_handle_t *h + static int + libzfs_module_loaded(const char *module) + { ++ FILE *fp; + const char path_prefix[] = "/sys/module/"; + char path[256]; + + memcpy(path, path_prefix, sizeof (path_prefix) - 1); + strcpy(path + sizeof (path_prefix) - 1, module); + ++ strcpy(path + sizeof (path_prefix) - 1 + strlen(module), "/version"); ++ fp = fopen(path, "r"); ++ if (fp) { ++ if (fscanf(fp, "%d.%d", &zfs_major_ver, &zfs_minor_ver) != 2) { ++ zfs_major_ver = 0; ++ zfs_minor_ver = 0; ++ } ++ fclose(fp); ++ } ++ + return (access(path, F_OK) == 0); + } + +@@ -1445,7 +1458,120 @@ zcmd_read_dst_nvlist(libzfs_handle_t *hd + int + zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc) + { +- return (ioctl(hdl->libzfs_fd, request, zc)); ++ zfs_cmd_V065_t zc_065; ++ int rc; ++ ++ if ((zfs_major_ver * 100) + zfs_minor_ver >= 7) ++ return (ioctl(hdl->libzfs_fd, request, zc)); ++ ++ memcpy(zc_065.zc_name, zc->zc_name, sizeof zc_065.zc_name); ++ zc_065.zc_nvlist_src = zc->zc_nvlist_src; ++ zc_065.zc_nvlist_src_size = zc->zc_nvlist_src_size; ++ zc_065.zc_nvlist_dst = zc->zc_nvlist_dst; ++ zc_065.zc_nvlist_dst_size = zc->zc_nvlist_dst_size; ++ zc_065.zc_nvlist_dst_filled = zc->zc_nvlist_dst_filled; ++ zc_065.zc_pad2 = zc->zc_pad2; ++ zc_065.zc_history = zc->zc_history; ++ memcpy(zc_065.zc_value, zc->zc_value, sizeof zc_065.zc_value); ++ memcpy(zc_065.zc_string, zc->zc_string, sizeof zc_065.zc_string); ++ zc_065.zc_guid = zc->zc_guid; ++ zc_065.zc_nvlist_conf = zc->zc_nvlist_conf; ++ zc_065.zc_nvlist_conf_size = zc->zc_nvlist_conf_size; ++ zc_065.zc_cookie = zc->zc_cookie; ++ zc_065.zc_objset_type = zc->zc_objset_type; ++ zc_065.zc_perm_action = zc->zc_perm_action; ++ zc_065.zc_history_len = zc->zc_history_len; ++ zc_065.zc_history_offset = zc->zc_history_offset; ++ zc_065.zc_obj = zc->zc_obj; ++ zc_065.zc_iflags = zc->zc_iflags; ++ zc_065.zc_share = zc->zc_share; ++ zc_065.zc_objset_stats = zc->zc_objset_stats; ++ zc_065.zc_begin_record = zc->zc_begin_record; ++ ++ zc_065.zc_inject_record.zi_objset = zc->zc_inject_record.zi_objset; ++ zc_065.zc_inject_record.zi_object = zc->zc_inject_record.zi_object; ++ zc_065.zc_inject_record.zi_start = zc->zc_inject_record.zi_start; ++ zc_065.zc_inject_record.zi_end = zc->zc_inject_record.zi_end; ++ zc_065.zc_inject_record.zi_guid = zc->zc_inject_record.zi_guid; ++ zc_065.zc_inject_record.zi_level = zc->zc_inject_record.zi_level; ++ zc_065.zc_inject_record.zi_error = zc->zc_inject_record.zi_error; ++ zc_065.zc_inject_record.zi_type = zc->zc_inject_record.zi_type; ++ zc_065.zc_inject_record.zi_freq = zc->zc_inject_record.zi_freq; ++ zc_065.zc_inject_record.zi_failfast = zc->zc_inject_record.zi_failfast; ++ memcpy(zc_065.zc_inject_record.zi_func, zc->zc_inject_record.zi_func, sizeof zc_065.zc_inject_record.zi_func); ++ zc_065.zc_inject_record.zi_iotype = zc->zc_inject_record.zi_iotype; ++ zc_065.zc_inject_record.zi_duration = zc->zc_inject_record.zi_duration; ++ zc_065.zc_inject_record.zi_timer = zc->zc_inject_record.zi_timer; ++ zc_065.zc_inject_record.zi_cmd = zc->zc_inject_record.zi_cmd; ++ zc_065.zc_inject_record.zi_pad = zc->zc_inject_record.zi_pad; ++ ++ zc_065.zc_defer_destroy = zc->zc_defer_destroy; ++ zc_065.zc_flags = zc->zc_flags; ++ zc_065.zc_action_handle = zc->zc_action_handle; ++ zc_065.zc_cleanup_fd = zc->zc_cleanup_fd; ++ zc_065.zc_simple = zc->zc_simple; ++ memcpy(zc_065.zc_pad, zc->zc_pad, sizeof zc_065.zc_pad); ++ zc_065.zc_sendobj = zc->zc_sendobj; ++ zc_065.zc_fromobj = zc->zc_fromobj; ++ zc_065.zc_createtxg = zc->zc_createtxg; ++ zc_065.zc_stat = zc->zc_stat; ++ ++ rc = ioctl(hdl->libzfs_fd, request, &zc_065); ++ ++ memcpy(zc->zc_name, zc_065.zc_name, sizeof zc->zc_name); ++ zc->zc_nvlist_src = zc_065.zc_nvlist_src; ++ zc->zc_nvlist_src_size = zc_065.zc_nvlist_src_size; ++ zc->zc_nvlist_dst = zc_065.zc_nvlist_dst; ++ zc->zc_nvlist_dst_size = zc_065.zc_nvlist_dst_size; ++ zc->zc_nvlist_dst_filled = zc_065.zc_nvlist_dst_filled; ++ zc->zc_pad2 = zc_065.zc_pad2; ++ zc->zc_history = zc_065.zc_history; ++ memcpy(zc->zc_value, zc_065.zc_value, sizeof zc->zc_value); ++ memcpy(zc->zc_string, zc_065.zc_string, sizeof zc->zc_string); ++ zc->zc_guid = zc_065.zc_guid; ++ zc->zc_nvlist_conf = zc_065.zc_nvlist_conf; ++ zc->zc_nvlist_conf_size = zc_065.zc_nvlist_conf_size; ++ zc->zc_cookie = zc_065.zc_cookie; ++ zc->zc_objset_type = zc_065.zc_objset_type; ++ zc->zc_perm_action = zc_065.zc_perm_action; ++ zc->zc_history_len = zc_065.zc_history_len; ++ zc->zc_history_offset = zc_065.zc_history_offset; ++ zc->zc_obj = zc_065.zc_obj; ++ zc->zc_iflags = zc_065.zc_iflags; ++ zc->zc_share = zc_065.zc_share; ++ zc->zc_objset_stats = zc_065.zc_objset_stats; ++ zc->zc_begin_record = zc_065.zc_begin_record; ++ ++ zc->zc_inject_record.zi_objset = zc_065.zc_inject_record.zi_objset; ++ zc->zc_inject_record.zi_object = zc_065.zc_inject_record.zi_object; ++ zc->zc_inject_record.zi_start = zc_065.zc_inject_record.zi_start; ++ zc->zc_inject_record.zi_end = zc_065.zc_inject_record.zi_end; ++ zc->zc_inject_record.zi_guid = zc_065.zc_inject_record.zi_guid; ++ zc->zc_inject_record.zi_level = zc_065.zc_inject_record.zi_level; ++ zc->zc_inject_record.zi_error = zc_065.zc_inject_record.zi_error; ++ zc->zc_inject_record.zi_type = zc_065.zc_inject_record.zi_type; ++ zc->zc_inject_record.zi_freq = zc_065.zc_inject_record.zi_freq; ++ zc->zc_inject_record.zi_failfast = zc_065.zc_inject_record.zi_failfast; ++ memcpy(zc->zc_inject_record.zi_func, zc_065.zc_inject_record.zi_func, sizeof zc->zc_inject_record.zi_func); ++ zc->zc_inject_record.zi_iotype = zc_065.zc_inject_record.zi_iotype; ++ zc->zc_inject_record.zi_duration = zc_065.zc_inject_record.zi_duration; ++ zc->zc_inject_record.zi_timer = zc_065.zc_inject_record.zi_timer; ++ zc->zc_inject_record.zi_nlanes = 0; ++ zc->zc_inject_record.zi_cmd = zc_065.zc_inject_record.zi_cmd; ++ zc->zc_inject_record.zi_pad = zc_065.zc_inject_record.zi_pad; ++ ++ zc->zc_defer_destroy = zc_065.zc_defer_destroy; ++ zc->zc_flags = zc_065.zc_flags; ++ zc->zc_action_handle = zc_065.zc_action_handle; ++ zc->zc_cleanup_fd = zc_065.zc_cleanup_fd; ++ zc->zc_simple = zc_065.zc_simple; ++ memcpy(zc->zc_pad, zc_065.zc_pad, sizeof zc->zc_pad); ++ zc->zc_sendobj = zc_065.zc_sendobj; ++ zc->zc_fromobj = zc_065.zc_fromobj; ++ zc->zc_createtxg = zc_065.zc_createtxg; ++ zc->zc_stat = zc_065.zc_stat; ++ ++ return rc; + } + + /* diff -Nru zfs-linux-0.7.5/debian/patches/2201-Fix-mmap-libaio-deadlock.patch zfs-linux-0.7.5/debian/patches/2201-Fix-mmap-libaio-deadlock.patch --- zfs-linux-0.7.5/debian/patches/2201-Fix-mmap-libaio-deadlock.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2201-Fix-mmap-libaio-deadlock.patch 2018-03-28 07:52:21.000000000 +0000 @@ -0,0 +1,339 @@ +From e2652650726802c8b3066d0aa22651658448a8e3 Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf +Date: Mon, 26 Mar 2018 17:44:19 -0700 +Subject: [PATCH] Fix mmap / libaio deadlock +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Calling uiomove() in mappedread() can result in deadlock if the +user space page needs to be faulted in. + +Resolve the issue by only taking a reference on the page when +copying it and not the page lock. The inode range lock protects +against concurrent updates via zfs_read() and zfs_write(). + +Signed-off-by: Brian Behlendorf +Issue #7335 +(backported from upstream, early hotfix, not commit sha) +Signed-off-by: Colin Ian King + +Index: zfs-linux-0.7.5/config/user-libaio.m4 +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/config/user-libaio.m4 +@@ -0,0 +1,14 @@ ++dnl # ++dnl # Check for libaio - only used for libaiot test cases. ++dnl # ++AC_DEFUN([ZFS_AC_CONFIG_USER_LIBAIO], [ ++ LIBAIO= ++ ++ AC_CHECK_HEADER([libaio.h], [ ++ user_libaio=yes ++ AC_SUBST([LIBAIO], ["-laio"]) ++ AC_DEFINE([HAVE_LIBAIO], 1, [Define if you have libaio]) ++ ], [ ++ user_libaio=no ++ ]) ++]) +Index: zfs-linux-0.7.5/config/user.m4 +=================================================================== +--- zfs-linux-0.7.5.orig/config/user.m4 ++++ zfs-linux-0.7.5/config/user.m4 +@@ -14,6 +14,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ + ZFS_AC_CONFIG_USER_LIBBLKID + ZFS_AC_CONFIG_USER_LIBATTR + ZFS_AC_CONFIG_USER_LIBUDEV ++ ZFS_AC_CONFIG_USER_LIBAIO + ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN + ZFS_AC_CONFIG_USER_RUNSTATEDIR + ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS +Index: zfs-linux-0.7.5/config/zfs-build.m4 +=================================================================== +--- zfs-linux-0.7.5.orig/config/zfs-build.m4 ++++ zfs-linux-0.7.5/config/zfs-build.m4 +@@ -79,11 +79,11 @@ AC_DEFUN([ZFS_AC_CONFIG], [ + AM_CONDITIONAL([CONFIG_KERNEL], + [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] && + [test "x$enable_linux_builtin" != xyes ]) +- AM_CONDITIONAL([WANT_DEVNAME2DEVID], +- [test "x$user_libudev" = xyes ]) + AM_CONDITIONAL([CONFIG_QAT], + [test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] && + [test "x$qatsrc" != x ]) ++ AM_CONDITIONAL([WANT_DEVNAME2DEVID], [test "x$user_libudev" = xyes ]) ++ AM_CONDITIONAL([WANT_MMAP_LIBAIO], [test "x$user_libaio" = xyes ]) + ]) + + dnl # +Index: zfs-linux-0.7.5/configure.ac +=================================================================== +--- zfs-linux-0.7.5.orig/configure.ac ++++ zfs-linux-0.7.5/configure.ac +@@ -163,6 +163,7 @@ AC_CONFIG_FILES([ + tests/zfs-tests/cmd/mkfiles/Makefile + tests/zfs-tests/cmd/mktree/Makefile + tests/zfs-tests/cmd/mmap_exec/Makefile ++ tests/zfs-tests/cmd/mmap_libaio/Makefile + tests/zfs-tests/cmd/mmapwrite/Makefile + tests/zfs-tests/cmd/randfree_file/Makefile + tests/zfs-tests/cmd/readmmap/Makefile +Index: zfs-linux-0.7.5/module/zfs/zfs_vnops.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zfs_vnops.c ++++ zfs-linux-0.7.5/module/zfs/zfs_vnops.c +@@ -398,6 +398,7 @@ mappedread(struct inode *ip, int nbytes, + pp = find_lock_page(mp, start >> PAGE_SHIFT); + if (pp) { + ASSERT(PageUptodate(pp)); ++ unlock_page(pp); + + pb = kmap(pp); + error = uiomove(pb + off, bytes, UIO_READ, uio); +@@ -407,7 +408,6 @@ mappedread(struct inode *ip, int nbytes, + flush_dcache_page(pp); + + mark_page_accessed(pp); +- unlock_page(pp); + put_page(pp); + } else { + error = dmu_read_uio_dbuf(sa_get_db(zp->z_sa_hdl), +Index: zfs-linux-0.7.5/rpm/generic/zfs.spec.in +=================================================================== +--- zfs-linux-0.7.5.orig/rpm/generic/zfs.spec.in ++++ zfs-linux-0.7.5/rpm/generic/zfs.spec.in +@@ -182,6 +182,7 @@ Requires: fio + Requires: acl + Requires: sudo + Requires: sysstat ++Requires: libaio + Requires: rng-tools + AutoReqProv: no + +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -485,7 +485,7 @@ tests = ['migration_001_pos', 'migration + tags = ['functional', 'migration'] + + [tests/functional/mmap] +-tests = ['mmap_write_001_pos', 'mmap_read_001_pos'] ++tests = ['mmap_write_001_pos', 'mmap_read_001_pos', 'mmap_libaio_001_pos'] + tags = ['functional', 'mmap'] + + [tests/functional/mmp] +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/cmd/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/Makefile.am +@@ -14,6 +14,7 @@ SUBDIRS = \ + mkfiles \ + mktree \ + mmap_exec \ ++ mmap_libaio \ + mmapwrite \ + randfree_file \ + readmmap \ +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/mmap_libaio/.gitignore +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/mmap_libaio/.gitignore +@@ -0,0 +1 @@ ++/mmap_libaio +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/mmap_libaio/Makefile.am +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/mmap_libaio/Makefile.am +@@ -0,0 +1,9 @@ ++include $(top_srcdir)/config/Rules.am ++ ++pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin ++ ++if WANT_MMAP_LIBAIO ++pkgexec_PROGRAMS = mmap_libaio ++mmap_libaio_SOURCES = mmap_libaio.c ++mmap_libaio_LDADD = $(LIBAIO) ++endif +Index: zfs-linux-0.7.5/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c +@@ -0,0 +1,88 @@ ++/* ++ * CDDL HEADER START ++ * ++ * The contents of this file are subject to the terms of the ++ * Common Development and Distribution License (the "License"). ++ * You may not use this file except in compliance with the License. ++ * ++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++ * or http://www.opensolaris.org/os/licensing. ++ * See the License for the specific language governing permissions ++ * and limitations under the License. ++ * ++ * When distributing Covered Code, include this CDDL HEADER in each ++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++ * If applicable, add the following below this CDDL HEADER, with the ++ * fields enclosed by brackets "[]" replaced with your own identifying ++ * information: Portions Copyright [yyyy] [name of copyright owner] ++ * ++ * CDDL HEADER END ++ */ ++ ++/* ++ * Copyright 2018 Canonical. All rights reserved. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++io_context_t io_ctx; ++ ++static void ++do_sync_io(struct iocb *iocb) ++{ ++ struct io_event event; ++ struct iocb *iocbs[] = { iocb }; ++ struct timespec ts = { 30, 0 }; ++ ++ if (io_submit(io_ctx, 1, iocbs) != 1) ++ err(1, "io_submit failed"); ++ ++ if (io_getevents(io_ctx, 0, 1, &event, &ts) != 1) ++ err(1, "io_getevents failed"); ++} ++ ++int ++main(int argc, char **argv) ++{ ++ char *buf; ++ int page_size = getpagesize(); ++ int buf_size = strtol(argv[2], NULL, 0); ++ int rwfd; ++ struct iocb iocb; ++ ++ if (io_queue_init(1024, &io_ctx)) ++ err(1, "io_queue_init failed"); ++ ++ rwfd = open(argv[1], O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); ++ if (rwfd < 0) ++ err(1, "open failed"); ++ ++ if (ftruncate(rwfd, buf_size) < 0) ++ err(1, "ftruncate failed"); ++ ++ buf = mmap(0, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, rwfd, 0); ++ if (buf == MAP_FAILED) ++ err(1, "mmap failed"); ++ ++ (void) io_prep_pwrite(&iocb, rwfd, buf, buf_size, 0); ++ do_sync_io(&iocb); ++ ++ (void) io_prep_pread(&iocb, rwfd, buf, buf_size, 0); ++ do_sync_io(&iocb); ++ ++ if (close(rwfd)) ++ err(1, "close failed"); ++ ++ if (io_queue_release(io_ctx) != 0) ++ err(1, "io_queue_release failed"); ++ ++ return (0); ++} +Index: zfs-linux-0.7.5/tests/zfs-tests/include/commands.cfg +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/include/commands.cfg ++++ zfs-linux-0.7.5/tests/zfs-tests/include/commands.cfg +@@ -157,6 +157,7 @@ export ZFSTEST_FILES='chg_usr_exec + mkfiles + mktree + mmap_exec ++ mmap_libaio + mmapwrite + randfree_file + readmmap +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/mmap/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/mmap/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/mmap/Makefile.am +@@ -4,4 +4,5 @@ dist_pkgdata_SCRIPTS = \ + cleanup.ksh \ + mmap.cfg \ + mmap_read_001_pos.ksh \ +- mmap_write_001_pos.ksh ++ mmap_write_001_pos.ksh \ ++ mmap_libaio_001_pos.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh +@@ -0,0 +1,61 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++# ++# Copyright 2018 Canonical. All rights reserved. ++# ++ ++. $STF_SUITE/include/libtest.shlib ++. $STF_SUITE/tests/functional/mmap/mmap.cfg ++ ++# ++# DESCRIPTION: ++# Verify libaio functions correctly with mmap()'d files. ++# ++# STRATEGY: ++# 1. Call mmap_libaio binary ++# 2. Verify the file exists and is the expected size ++# 3. Verify the filesystem is intact and not hung in any way ++# ++ ++verify_runnable "global" ++ ++log_assert "verify mmap'd pages work with libaio" ++ ++# mmap_libaio is built when the libaio-devel package is installed. ++if ! which mmap_libaio; then ++ log_unsupported "This test requires mmap_libaio." ++fi ++ ++log_must chmod 777 $TESTDIR ++ ++for size in 512 4096 8192; do ++ log_mustnot stat $TESTDIR/test-libaio-file ++ log_must mmap_libaio $TESTDIR/test-libaio-file $size ++ log_must verify_eq $(stat --format=%s $TESTDIR/test-libaio-file) $size ++ log_must rm $TESTDIR/test-libaio-file ++done ++ ++typeset dir=$(get_device_dir $DISKS) ++verify_filesys "$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir" ++ ++log_pass "mmap'd pages work with libaio" diff -Nru zfs-linux-0.7.5/debian/patches/2202-Allow-mounting-datasets-more-than-once.patch zfs-linux-0.7.5/debian/patches/2202-Allow-mounting-datasets-more-than-once.patch --- zfs-linux-0.7.5/debian/patches/2202-Allow-mounting-datasets-more-than-once.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2202-Allow-mounting-datasets-more-than-once.patch 2018-03-29 12:58:22.000000000 +0000 @@ -0,0 +1,377 @@ +From 1a5b486c105ff5ddc4bc7560bb303630cf2ce1bb Mon Sep 17 00:00:00 2001 +From: Seth Forshee +Date: Tue, 20 Mar 2018 15:20:52 -0400 +Subject: [PATCH] Allow mounting datasets more than once + +Currently mounting an already mounted zfs dataset results in an +error, whereas it is typically allowed with other filesystems. +This causes some bad interactions with mount namespaces. Take +this sequence for example: + + - Create a dataset + - Create a snapshot of the dataset + - Create a clone of the snapshot + - Create a new mount namespace + - Rename the original dataset + +The rename results in unmounting and remounting the clone in the +original mount namespace, however the remount fails because the +dataset is still mounted in the new mount namespace. (Note that +this means the mount in the new mount namespace is never being +unmounted, so perhaps the unmount/remount of the clone isn't +actually necessary.) + +The problem here is a result of the way mounting is implemented +in the kernel module. Since it is not mounting block devices it +uses mount_nodev() instead of the usual mount_bdev(). However, +mount_nodev() is written for filesystems for which each mount is +a new instance (i.e. a new super block), and zfs should be able +to detect when a mount request can be satisfied using an existing +super block. + +Change zpl_mount() to call sget() directly with it's own test +callback. Passing the objset_t object as the fs data allows +checking if a superblock already exists for the dataset, and in +that case we just need to return a new reference for the sb's +root dentry. + +Signed-off-by: Seth Forshee +Closes #5796 +(minor backport wiggle required on tests/runfiles/linux.run) +Signed-off-by: Colin Ian King + +Index: zfs-linux-0.7.5/config/kernel-fst-mount.m4 +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/config/kernel-fst-mount.m4 +@@ -0,0 +1,28 @@ ++dnl # ++dnl # 2.6.38 API change ++dnl # The .get_sb callback has been replaced by a .mount callback ++dnl # in the file_system_type structure. ++dnl # ++AC_DEFUN([ZFS_AC_KERNEL_FST_MOUNT], [ ++ AC_MSG_CHECKING([whether fst->mount() exists]) ++ ZFS_LINUX_TRY_COMPILE([ ++ #include ++ ++ static struct dentry * ++ mount(struct file_system_type *fs_type, int flags, ++ const char *osname, void *data) { ++ struct dentry *d = NULL; ++ return (d); ++ } ++ ++ static struct file_system_type fst __attribute__ ((unused)) = { ++ .mount = mount, ++ }; ++ ],[ ++ ],[ ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_FST_MOUNT, 1, [fst->mount() exists]) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) ++]) +Index: zfs-linux-0.7.5/config/kernel-mount-nodev.m4 +=================================================================== +--- zfs-linux-0.7.5.orig/config/kernel-mount-nodev.m4 ++++ /dev/null +@@ -1,20 +0,0 @@ +-dnl # +-dnl # 2.6.39 API change +-dnl # The .get_sb callback has been replaced by a .mount callback +-dnl # in the file_system_type structure. When using the new +-dnl # interface the caller must now use the mount_nodev() helper. +-dnl # This updated callback and helper no longer pass the vfsmount. +-dnl # +-AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV], +- [AC_MSG_CHECKING([whether mount_nodev() is available]) +- ZFS_LINUX_TRY_COMPILE_SYMBOL([ +- #include +- ], [ +- mount_nodev(NULL, 0, NULL, NULL); +- ], [mount_nodev], [fs/super.c], [ +- AC_MSG_RESULT(yes) +- AC_DEFINE(HAVE_MOUNT_NODEV, 1, [mount_nodev() is available]) +- ], [ +- AC_MSG_RESULT(no) +- ]) +-]) +Index: zfs-linux-0.7.5/config/kernel.m4 +=================================================================== +--- zfs-linux-0.7.5.orig/config/kernel.m4 ++++ zfs-linux-0.7.5/config/kernel.m4 +@@ -98,7 +98,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ + ZFS_AC_KERNEL_TRUNCATE_SETSIZE + ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY + ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY +- ZFS_AC_KERNEL_MOUNT_NODEV ++ ZFS_AC_KERNEL_FST_MOUNT + ZFS_AC_KERNEL_SHRINK + ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID + ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD +Index: zfs-linux-0.7.5/include/linux/vfs_compat.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/linux/vfs_compat.h ++++ zfs-linux-0.7.5/include/linux/vfs_compat.h +@@ -183,6 +183,30 @@ zpl_bdi_destroy(struct super_block *sb) + #endif + + /* ++ * 4.14 adds SB_* flag definitions, define them to MS_* equivalents ++ * if not set. ++ */ ++#ifndef SB_RDONLY ++#define SB_RDONLY MS_RDONLY ++#endif ++ ++#ifndef SB_SILENT ++#define SB_SILENT MS_SILENT ++#endif ++ ++#ifndef SB_ACTIVE ++#define SB_ACTIVE MS_ACTIVE ++#endif ++ ++#ifndef SB_POSIXACL ++#define SB_POSIXACL MS_POSIXACL ++#endif ++ ++#ifndef SB_MANDLOCK ++#define SB_MANDLOCK MS_MANDLOCK ++#endif ++ ++/* + * 2.6.38 API change, + * LOOKUP_RCU flag introduced to distinguish rcu-walk from ref-walk cases. + */ +Index: zfs-linux-0.7.5/module/zfs/zpl_super.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zpl_super.c ++++ zfs-linux-0.7.5/module/zfs/zpl_super.c +@@ -248,14 +248,61 @@ zpl_fill_super(struct super_block *sb, v + return (error); + } + +-#ifdef HAVE_MOUNT_NODEV ++static int ++zpl_test_super(struct super_block *s, void *data) ++{ ++ zfsvfs_t *zfsvfs = s->s_fs_info; ++ objset_t *os = data; ++ ++ if (zfsvfs == NULL) ++ return (0); ++ ++ return (os == zfsvfs->z_os); ++} ++ ++static struct super_block * ++zpl_mount_impl(struct file_system_type *fs_type, int flags, zfs_mnt_t *zm) ++{ ++ struct super_block *s; ++ objset_t *os; ++ int err; ++ ++ err = dmu_objset_hold(zm->mnt_osname, FTAG, &os); ++ if (err) ++ return (ERR_PTR(-err)); ++ ++ s = zpl_sget(fs_type, zpl_test_super, set_anon_super, flags, os); ++ dmu_objset_rele(os, FTAG); ++ if (IS_ERR(s)) ++ return (ERR_CAST(s)); ++ ++ if (s->s_root == NULL) { ++ err = zpl_fill_super(s, zm, flags & SB_SILENT ? 1 : 0); ++ if (err) { ++ deactivate_locked_super(s); ++ return (ERR_PTR(err)); ++ } ++ s->s_flags |= SB_ACTIVE; ++ } else if ((flags ^ s->s_flags) & SB_RDONLY) { ++ deactivate_locked_super(s); ++ return (ERR_PTR(-EBUSY)); ++ } ++ ++ return (s); ++} ++ ++#ifdef HAVE_FST_MOUNT + static struct dentry * + zpl_mount(struct file_system_type *fs_type, int flags, + const char *osname, void *data) + { + zfs_mnt_t zm = { .mnt_osname = osname, .mnt_data = data }; + +- return (mount_nodev(fs_type, flags, &zm, zpl_fill_super)); ++ struct super_block *sb = zpl_mount_impl(fs_type, flags, &zm); ++ if (IS_ERR(sb)) ++ return (ERR_CAST(sb)); ++ ++ return (dget(sb->s_root)); + } + #else + static int +@@ -264,9 +311,15 @@ zpl_get_sb(struct file_system_type *fs_t + { + zfs_mnt_t zm = { .mnt_osname = osname, .mnt_data = data }; + +- return (get_sb_nodev(fs_type, flags, &zm, zpl_fill_super, mnt)); ++ struct super_block *sb = zpl_mount_impl(fs_type, flags, &zm); ++ if (IS_ERR(sb)) ++ return (PTR_ERR(sb)); ++ ++ (void) simple_set_mnt(mnt, sb); ++ ++ return (0); + } +-#endif /* HAVE_MOUNT_NODEV */ ++#endif /* HAVE_FST_MOUNT */ + + static void + zpl_kill_sb(struct super_block *sb) +@@ -333,10 +386,10 @@ const struct super_operations zpl_super_ + struct file_system_type zpl_fs_type = { + .owner = THIS_MODULE, + .name = ZFS_DRIVER, +-#ifdef HAVE_MOUNT_NODEV ++#ifdef HAVE_FST_MOUNT + .mount = zpl_mount, + #else + .get_sb = zpl_get_sb, +-#endif /* HAVE_MOUNT_NODEV */ ++#endif /* HAVE_FST_MOUNT */ + .kill_sb = zpl_kill_sb, + }; +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -127,7 +127,7 @@ tests = ['zfs_mount_001_pos', 'zfs_mount + 'zfs_mount_004_pos', 'zfs_mount_005_pos', 'zfs_mount_007_pos', + 'zfs_mount_008_pos', 'zfs_mount_009_neg', 'zfs_mount_010_neg', + 'zfs_mount_011_neg', 'zfs_mount_012_neg', 'zfs_mount_all_001_pos', +- 'zfs_mount_remount'] ++ 'zfs_mount_remount', 'zfs_multi_mount'] + tags = ['functional', 'cli_root', 'zfs_mount'] + + [tests/functional/cli_root/zfs_promote] +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am +@@ -17,4 +17,5 @@ dist_pkgdata_SCRIPTS = \ + zfs_mount_011_neg.ksh \ + zfs_mount_012_neg.ksh \ + zfs_mount_all_001_pos.ksh \ +- zfs_mount_remount.ksh ++ zfs_mount_remount.ksh \ ++ zfs_multi_mount.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh +@@ -0,0 +1,101 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# This file and its contents are supplied under the terms of the ++# Common Development and Distribution License ("CDDL"), version 1.0. ++# You may only use this file in accordance with the terms of version ++# 1.0 of the CDDL. ++# ++# A full copy of the text of the CDDL should have accompanied this ++# source. A copy is of the CDDL is also available via the Internet ++# at http://www.illumos.org/license/CDDL. ++# ++# CDDL HEADER END ++# ++ ++# ++# Copyright(c) 2018 Datto Inc. ++# ++ ++. $STF_SUITE/include/libtest.shlib ++ ++# ++# DESCRIPTION: ++# Verify multi mount functionality ++# ++# STRATEGY: ++# 1. Create fs ++# 2. Create and hold open file in filesystem ++# 3. Lazy unmount ++# 4. Verify remounting fs that was lazily unmounted is possible ++# 5. Verify multiple mounts of the same dataset are possible ++# 6. Verify bind mount doesn't prevent rename ++# ++ ++verify_runnable "both" ++ ++function cleanup ++{ ++ log_must pkill -P $TAILPPID tail ++ return 0 ++} ++ ++log_assert "Verify multiple mounts into one namespace are possible" ++ ++log_onexit cleanup ++ ++# 1. Create fs ++TESTDS="$TESTPOOL/multi-mount-test" ++log_must zfs create $TESTDS ++ ++# 2. Create and hold open file in filesystem ++MNTPFS="$(get_prop mountpoint $TESTDS)" ++FILENAME="$MNTPFS/file" ++log_must mkfile 128k $FILENAME ++log_must tail -f $FILENAME 1>/dev/null 2>/dev/null & ++TAILPPID=$! ++ ++# 3. Lazy umount ++log_must umount -l $MNTPFS ++if [ -f $FILENAME ]; then ++ log_fail "Lazy unmount failed" ++fi ++ ++# 4. Verify remounting fs that was lazily unmounted is possible ++log_must zfs mount $TESTDS ++if [ ! -f $FILENAME ]; then ++ log_fail "Lazy remount failed" ++fi ++ ++# 5. Verify multiple mounts of the same dataset are possible ++MNTPFS2="$MNTPFS-second" ++FILENAME="$MNTPFS2/file" ++log_must mkdir $MNTPFS2 ++log_must mount -t zfs -o zfsutil $TESTDS $MNTPFS2 ++if [ ! -f $FILENAME ]; then ++ log_fail "First multi mount failed" ++fi ++ ++MNTPFS3="$MNTPFS-third" ++FILENAME="$MNTPFS3/file" ++log_must mkdir $MNTPFS3 ++log_must mount -t zfs -o zfsutil $TESTDS $MNTPFS3 ++if [ ! -f $FILENAME ]; then ++ log_fail "Second multi mount failed" ++fi ++ ++# 6. Verify bind mount doesn't prevent rename ++RENAMEFS="$TESTDS-newname" ++MNTPFS4="$MNTPFS-fourth" ++log_must mkdir $MNTPFS4 ++log_must mount --bind $MNTPFS $MNTPFS4 ++log_must zfs rename $TESTDS $RENAMEFS ++RENAMEMNT="$(get_prop mountpoint $RENAMEFS)" ++FILENAME="$RENAMEMNT/file" ++if [ ! -f $FILENAME ]; then ++ log_fail "Rename failed" ++fi ++log_must zfs rename $RENAMEFS $TESTDS ++ ++log_pass "Multiple mounts are possible" diff -Nru zfs-linux-0.7.5/debian/patches/2300-OpenZFS-8373-TXG_WAIT-in-ZIL-commit-path.patch zfs-linux-0.7.5/debian/patches/2300-OpenZFS-8373-TXG_WAIT-in-ZIL-commit-path.patch --- zfs-linux-0.7.5/debian/patches/2300-OpenZFS-8373-TXG_WAIT-in-ZIL-commit-path.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2300-OpenZFS-8373-TXG_WAIT-in-ZIL-commit-path.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,55 @@ +From e98b6117252acb4931bbcc0ff6b164269273de4e Mon Sep 17 00:00:00 2001 +From: Andriy Gapon +Date: Mon, 17 Jul 2017 15:31:30 +0300 +Subject: [PATCH] OpenZFS 8373 - TXG_WAIT in ZIL commit path +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Andriy Gapon +Reviewed by: Prakash Surya +Reviewed by: Matthew Ahrens +Approved by: Dan McDonald +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Ported-by: Giuseppe Di Natale + +OpenZFS-issue: https://www.illumos.org/issues/8373 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/7f04961 +Closes #6403 +--- + module/zfs/zil.c | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/module/zfs/zil.c b/module/zfs/zil.c +index 6a1f190f5..6b0346893 100644 +--- a/module/zfs/zil.c ++++ b/module/zfs/zil.c +@@ -1009,7 +1009,24 @@ zil_lwb_write_start(zilog_t *zilog, lwb_t *lwb) + * to clean up in the event of allocation failure or I/O failure. + */ + tx = dmu_tx_create(zilog->zl_os); +- VERIFY(dmu_tx_assign(tx, TXG_WAIT) == 0); ++ ++ /* ++ * Since we are not going to create any new dirty data and we can even ++ * help with clearing the existing dirty data, we should not be subject ++ * to the dirty data based delays. ++ * We (ab)use TXG_WAITED to bypass the delay mechanism. ++ * One side effect from using TXG_WAITED is that dmu_tx_assign() can ++ * fail if the pool is suspended. Those are dramatic circumstances, ++ * so we return NULL to signal that the normal ZIL processing is not ++ * possible and txg_wait_synced() should be used to ensure that the data ++ * is on disk. ++ */ ++ error = dmu_tx_assign(tx, TXG_WAITED); ++ if (error != 0) { ++ ASSERT3S(error, ==, EIO); ++ dmu_tx_abort(tx); ++ return (NULL); ++ } + dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); + txg = dmu_tx_get_txg(tx); + +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2301-zfs-promote-rename-.-recv-should-be-an-error.patch zfs-linux-0.7.5/debian/patches/2301-zfs-promote-rename-.-recv-should-be-an-error.patch --- zfs-linux-0.7.5/debian/patches/2301-zfs-promote-rename-.-recv-should-be-an-error.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2301-zfs-promote-rename-.-recv-should-be-an-error.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,232 @@ +From 650258d7c786b8e62ca847a926f6f038cd3e5d94 Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Fri, 28 Jul 2017 23:12:34 +0200 +Subject: [PATCH] zfs promote|rename .../%recv should be an error +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +If we are in the middle of an incremental 'zfs receive', the child +.../%recv will exist. If we run 'zfs promote' .../%recv, it will "work", +but then zfs gets confused about the status of the new dataset. +Attempting to do this promote should be an error. + +Similarly renaming .../%recv datasets should not be allowed. + +Reviewed-by: Giuseppe Di Natale +Reviewed-by: Brian Behlendorf +Signed-off-by: loli10K +Closes #4843 +Closes #6339 +--- + lib/libzfs/libzfs_dataset.c | 7 +++++ + module/zfs/zfs_ioctl.c | 12 ++++++-- + tests/zfs-tests/include/libtest.shlib | 35 ++++++++++++++++++++++ + .../cli_root/zfs_promote/zfs_promote_006_neg.ksh | 15 ++++++---- + .../functional/cli_root/zfs_rename/zfs_rename.cfg | 1 + + .../cli_root/zfs_rename/zfs_rename.kshlib | 5 ++++ + .../cli_root/zfs_rename/zfs_rename_004_neg.ksh | 4 +-- + 7 files changed, 70 insertions(+), 9 deletions(-) + +diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c +index d6e85024d..b37c89e41 100644 +--- a/lib/libzfs/libzfs_dataset.c ++++ b/lib/libzfs/libzfs_dataset.c +@@ -3751,6 +3751,9 @@ zfs_promote(zfs_handle_t *zhp) + return (zfs_error(hdl, EZFS_BADTYPE, errbuf)); + } + ++ if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE)) ++ return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); ++ + ret = lzc_promote(zhp->zfs_name, snapname, sizeof (snapname)); + + if (ret != 0) { +@@ -4080,6 +4083,10 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive, + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, + "cannot rename to '%s'"), target); + ++ /* make sure source name is valid */ ++ if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE)) ++ return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); ++ + /* + * Make sure the target name is valid + */ +diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c +index d195eded7..21fefe57f 100644 +--- a/module/zfs/zfs_ioctl.c ++++ b/module/zfs/zfs_ioctl.c +@@ -3738,9 +3738,12 @@ zfs_ioc_rename(zfs_cmd_t *zc) + boolean_t recursive = zc->zc_cookie & 1; + char *at; + ++ /* "zfs rename" from and to ...%recv datasets should both fail */ ++ zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; + zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; +- if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || +- strchr(zc->zc_value, '%')) ++ if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || ++ dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || ++ strchr(zc->zc_name, '%') || strchr(zc->zc_value, '%')) + return (SET_ERROR(EINVAL)); + + at = strchr(zc->zc_name, '@'); +@@ -5002,6 +5005,11 @@ zfs_ioc_promote(zfs_cmd_t *zc) + char *cp; + int error; + ++ zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; ++ if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || ++ strchr(zc->zc_name, '%')) ++ return (SET_ERROR(EINVAL)); ++ + error = dsl_pool_hold(zc->zc_name, FTAG, &dp); + if (error != 0) + return (error); +diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib +index 88594c201..b6ac41dfa 100644 +--- a/tests/zfs-tests/include/libtest.shlib ++++ b/tests/zfs-tests/include/libtest.shlib +@@ -351,6 +351,41 @@ function create_bookmark + log_must zfs bookmark $fs_vol@$snap $fs_vol#$bkmark + } + ++# ++# Create a temporary clone result of an interrupted resumable 'zfs receive' ++# $1 Destination filesystem name. Must not exist, will be created as the result ++# of this function along with its %recv temporary clone ++# $2 Source filesystem name. Must not exist, will be created and destroyed ++# ++function create_recv_clone ++{ ++ typeset recvfs="$1" ++ typeset sendfs="${2:-$TESTPOOL/create_recv_clone}" ++ typeset snap="$sendfs@snap1" ++ typeset incr="$sendfs@snap2" ++ typeset mountpoint="$TESTDIR/create_recv_clone" ++ typeset sendfile="$TESTDIR/create_recv_clone.zsnap" ++ ++ [[ -z $recvfs ]] && log_fail "Recv filesystem's name is undefined." ++ ++ datasetexists $recvfs && log_fail "Recv filesystem must not exist." ++ datasetexists $sendfs && log_fail "Send filesystem must not exist." ++ ++ log_must zfs create -o mountpoint="$mountpoint" $sendfs ++ log_must zfs snapshot $snap ++ log_must eval "zfs send $snap | zfs recv -u $recvfs" ++ log_must mkfile 1m "$mountpoint/data" ++ log_must zfs snapshot $incr ++ log_must eval "zfs send -i $snap $incr | dd bs=10K count=1 > $sendfile" ++ log_mustnot eval "zfs recv -su $recvfs < $sendfile" ++ log_must zfs destroy -r $sendfs ++ log_must rm -f "$sendfile" ++ ++ if [[ $(get_prop 'inconsistent' "$recvfs/%recv") -ne 1 ]]; then ++ log_fail "Error creating temporary $recvfs/%recv clone" ++ fi ++} ++ + function default_mirror_setup + { + default_mirror_setup_noexit $1 $2 $3 +diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh +index cedfa676a..286c14ac1 100755 +--- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh ++++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh +@@ -40,6 +40,7 @@ + # pool, fs, snapshot,volume + # (4) too many arguments. + # (5) invalid options ++# (6) temporary %recv datasets + # + # STRATEGY: + # 1. Create an array of invalid arguments +@@ -50,11 +51,14 @@ + verify_runnable "both" + + snap=$TESTPOOL/$TESTFS@$TESTSNAP ++clone=$TESTPOOL/$TESTCLONE ++recvfs=$TESTPOOL/recvfs + set -A args "" \ + "$TESTPOOL/blah" \ + "$TESTPOOL" "$TESTPOOL/$TESTFS" "$snap" \ + "$TESTPOOL/$TESTVOL" "$TESTPOOL $TESTPOOL/$TESTFS" \ +- "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" ++ "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" \ ++ "$recvfs/%recv" + + function cleanup + { +@@ -62,6 +66,10 @@ function cleanup + log_must zfs destroy $clone + fi + ++ if datasetexists $recvfs; then ++ log_must zfs destroy -r $recvfs ++ fi ++ + if snapexists $snap; then + destroy_snapshot $snap + fi +@@ -70,10 +78,7 @@ function cleanup + log_assert "'zfs promote' will fail with invalid arguments. " + log_onexit cleanup + +-snap=$TESTPOOL/$TESTFS@$TESTSNAP +-clone=$TESTPOOL/$TESTCLONE +-log_must zfs snapshot $snap +-log_must zfs clone $snap $clone ++create_recv_clone $recvfs + + typeset -i i=0 + while (( i < ${#args[*]} )); do +diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg +index 8c33b58b3..9a8f38dc2 100644 +--- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg ++++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg +@@ -36,3 +36,4 @@ export BS=512 + export CNT=2048 + export VOL_R_PATH=$ZVOL_RDEVDIR/$TESTPOOL/$TESTVOL + export VOLDATA=$TESTDIR2/voldata.rename ++export RECVFS=recvfs +diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib +index f408d7120..9b8fb6b0e 100644 +--- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib ++++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib +@@ -63,6 +63,8 @@ function additional_setup + log_must cp $DATA $(get_prop mountpoint $TESTPOOL/$TESTVOL)/$TESTFILE0 + fi + ++ # Create temporary %recv clone ++ create_recv_clone $TESTPOOL/$RECVFS + } + + function rename_dataset # src dest +@@ -110,6 +112,9 @@ function cleanup + log_must zfs destroy -fR $TESTPOOL/$TESTFS@snapshot + fi + ++ if datasetexists $TESTPOOL/$RECVFS; then ++ log_must zfs destroy -r $TESTPOOL/$RECVFS ++ fi + } + + function cmp_data #<$1 src data, $2 tgt data> +diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh +index cafa74366..b1438e866 100755 +--- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh ++++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh +@@ -77,8 +77,8 @@ set -A bad_dataset $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTCTR1 \ + $TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%x \ + $TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%p \ + $TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%s \ +- $TESTPOOL/$TESTFS@snapshot \ +- $TESTPOOL/$TESTFS@snapshot/fs ++ $TESTPOOL/$TESTFS@snapshot $TESTPOOL/$TESTFS@snapshot/fs \ ++ $TESTPOOL/$RECVFS/%recv $TESTPOOL/renamed.$$ + + # + # cleanup defined in zfs_rename.kshlib +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2302-Fix-parsable-zfs-get-for-compressratios.patch zfs-linux-0.7.5/debian/patches/2302-Fix-parsable-zfs-get-for-compressratios.patch --- zfs-linux-0.7.5/debian/patches/2302-Fix-parsable-zfs-get-for-compressratios.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2302-Fix-parsable-zfs-get-for-compressratios.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,44 @@ +From b0bd8ffecd70b46e584e2e52ea74f2373b544217 Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Thu, 3 Aug 2017 18:43:17 +0200 +Subject: [PATCH] Fix parsable 'zfs get' for compressratios +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +This is consistent with the change introduced in bc2d809 where +'zpool get -p dedupratio' does not add a trailing "x" to the output. + +Reviewed-by: Tony Hutter +Reviewed-by: Giuseppe Di Natale +Signed-off-by: loli10K +Closes #6436 +Closes #6449 +--- + lib/libzfs/libzfs_dataset.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c +index b37c89e41..1270072b2 100644 +--- a/lib/libzfs/libzfs_dataset.c ++++ b/lib/libzfs/libzfs_dataset.c +@@ -2601,9 +2601,14 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, + case ZFS_PROP_COMPRESSRATIO: + if (get_numeric_property(zhp, prop, src, &source, &val) != 0) + return (-1); +- (void) snprintf(propbuf, proplen, "%llu.%02llux", +- (u_longlong_t)(val / 100), +- (u_longlong_t)(val % 100)); ++ if (literal) ++ (void) snprintf(propbuf, proplen, "%llu.%02llu", ++ (u_longlong_t)(val / 100), ++ (u_longlong_t)(val % 100)); ++ else ++ (void) snprintf(propbuf, proplen, "%llu.%02llux", ++ (u_longlong_t)(val / 100), ++ (u_longlong_t)(val % 100)); + break; + + case ZFS_PROP_TYPE: +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2303-Fix-zpool-events-scripted-mode-tab-separator.patch zfs-linux-0.7.5/debian/patches/2303-Fix-zpool-events-scripted-mode-tab-separator.patch --- zfs-linux-0.7.5/debian/patches/2303-Fix-zpool-events-scripted-mode-tab-separator.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2303-Fix-zpool-events-scripted-mode-tab-separator.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,52 @@ +From 1e1c398033384106c8ee96435ba0683797b41a46 Mon Sep 17 00:00:00 2001 +From: Sen Haerens +Date: Thu, 3 Aug 2017 18:56:15 +0200 +Subject: [PATCH] Fix zpool events scripted mode tab separator +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Reviewed-by: Tony Hutter +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Sen Haerens +Closes #6444 +Closes #6445 +--- + cmd/zpool/zpool_main.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zpool/zpool_main.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zpool/zpool_main.c ++++ zfs-linux-0.7.5/cmd/zpool/zpool_main.c +@@ -7348,7 +7348,7 @@ typedef struct ev_opts { + } ev_opts_t; + + static void +-zpool_do_events_short(nvlist_t *nvl) ++zpool_do_events_short(nvlist_t *nvl, ev_opts_t *opts) + { + char ctime_str[26], str[32], *ptr; + int64_t *tv; +@@ -7361,7 +7361,10 @@ zpool_do_events_short(nvlist_t *nvl) + (void) strncpy(str+7, ctime_str+20, 4); /* '1993' */ + (void) strncpy(str+12, ctime_str+11, 8); /* '21:49:08' */ + (void) sprintf(str+20, ".%09lld", (longlong_t)tv[1]); /* '.123456789' */ +- (void) printf(gettext("%s "), str); ++ if (opts->scripted) ++ (void) printf(gettext("%s\t"), str); ++ else ++ (void) printf(gettext("%s "), str); + + verify(nvlist_lookup_string(nvl, FM_CLASS, &ptr) == 0); + (void) printf(gettext("%s\n"), ptr); +@@ -7625,7 +7628,7 @@ zpool_do_events_next(ev_opts_t *opts) + if (dropped > 0) + (void) printf(gettext("dropped %d events\n"), dropped); + +- zpool_do_events_short(nvl); ++ zpool_do_events_short(nvl, opts); + + if (opts->verbose) { + zpool_do_events_nvprint(nvl, 8); diff -Nru zfs-linux-0.7.5/debian/patches/2304-zv_suspend_lock-in-zvol_open-zvol_release.patch zfs-linux-0.7.5/debian/patches/2304-zv_suspend_lock-in-zvol_open-zvol_release.patch --- zfs-linux-0.7.5/debian/patches/2304-zv_suspend_lock-in-zvol_open-zvol_release.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2304-zv_suspend_lock-in-zvol_open-zvol_release.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,124 @@ +From 5146d802b4e371cab1d6db79bea482c056be7bf2 Mon Sep 17 00:00:00 2001 +From: Boris Protopopov +Date: Wed, 9 Aug 2017 14:10:47 -0400 +Subject: [PATCH] zv_suspend_lock in zvol_open()/zvol_release() +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Acquire zv_suspend_lock on first open and last close only. + +Reviewed-by: Brian Behlendorf +Signed-off-by: Boris Protopopov +Closes #6342 +--- + module/zfs/zvol.c | 64 +++++++++++++++++++++++++++++++++++-------------------- + 1 file changed, 41 insertions(+), 23 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/zvol.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zvol.c ++++ zfs-linux-0.7.5/module/zfs/zvol.c +@@ -1347,9 +1347,9 @@ zvol_open(struct block_device *bdev, fmo + { + zvol_state_t *zv; + int error = 0; +- boolean_t drop_suspend = B_FALSE; ++ boolean_t drop_suspend = B_TRUE; + +- ASSERT(!mutex_owned(&zvol_state_lock)); ++ ASSERT(!MUTEX_HELD(&zvol_state_lock)); + + mutex_enter(&zvol_state_lock); + /* +@@ -1364,23 +1364,31 @@ zvol_open(struct block_device *bdev, fmo + return (SET_ERROR(-ENXIO)); + } + +- /* take zv_suspend_lock before zv_state_lock */ +- rw_enter(&zv->zv_suspend_lock, RW_READER); +- + mutex_enter(&zv->zv_state_lock); +- + /* + * make sure zvol is not suspended during first open +- * (hold zv_suspend_lock), otherwise, drop the lock ++ * (hold zv_suspend_lock) and respect proper lock acquisition ++ * ordering - zv_suspend_lock before zv_state_lock + */ + if (zv->zv_open_count == 0) { +- drop_suspend = B_TRUE; ++ if (!rw_tryenter(&zv->zv_suspend_lock, RW_READER)) { ++ mutex_exit(&zv->zv_state_lock); ++ rw_enter(&zv->zv_suspend_lock, RW_READER); ++ mutex_enter(&zv->zv_state_lock); ++ /* check to see if zv_suspend_lock is needed */ ++ if (zv->zv_open_count != 0) { ++ rw_exit(&zv->zv_suspend_lock); ++ drop_suspend = B_FALSE; ++ } ++ } + } else { +- rw_exit(&zv->zv_suspend_lock); ++ drop_suspend = B_FALSE; + } +- + mutex_exit(&zvol_state_lock); + ++ ASSERT(MUTEX_HELD(&zv->zv_state_lock)); ++ ASSERT(zv->zv_open_count != 0 || RW_READ_HELD(&zv->zv_suspend_lock)); ++ + if (zv->zv_open_count == 0) { + error = zvol_first_open(zv); + if (error) +@@ -1417,28 +1425,38 @@ static int + zvol_release(struct gendisk *disk, fmode_t mode) + { + zvol_state_t *zv; +- boolean_t drop_suspend = B_FALSE; ++ boolean_t drop_suspend = B_TRUE; + +- ASSERT(!mutex_owned(&zvol_state_lock)); ++ ASSERT(!MUTEX_HELD(&zvol_state_lock)); + + mutex_enter(&zvol_state_lock); + zv = disk->private_data; +- ASSERT(zv && zv->zv_open_count > 0); +- +- /* take zv_suspend_lock before zv_state_lock */ +- rw_enter(&zv->zv_suspend_lock, RW_READER); + + mutex_enter(&zv->zv_state_lock); +- mutex_exit(&zvol_state_lock); +- ++ ASSERT(zv->zv_open_count > 0); + /* + * make sure zvol is not suspended during last close +- * (hold zv_suspend_lock), otherwise, drop the lock ++ * (hold zv_suspend_lock) and respect proper lock acquisition ++ * ordering - zv_suspend_lock before zv_state_lock + */ +- if (zv->zv_open_count == 1) +- drop_suspend = B_TRUE; +- else +- rw_exit(&zv->zv_suspend_lock); ++ if (zv->zv_open_count == 1) { ++ if (!rw_tryenter(&zv->zv_suspend_lock, RW_READER)) { ++ mutex_exit(&zv->zv_state_lock); ++ rw_enter(&zv->zv_suspend_lock, RW_READER); ++ mutex_enter(&zv->zv_state_lock); ++ /* check to see if zv_suspend_lock is needed */ ++ if (zv->zv_open_count != 1) { ++ rw_exit(&zv->zv_suspend_lock); ++ drop_suspend = B_FALSE; ++ } ++ } ++ } else { ++ drop_suspend = B_FALSE; ++ } ++ mutex_exit(&zvol_state_lock); ++ ++ ASSERT(MUTEX_HELD(&zv->zv_state_lock)); ++ ASSERT(zv->zv_open_count != 1 || RW_READ_HELD(&zv->zv_suspend_lock)); + + zv->zv_open_count--; + if (zv->zv_open_count == 0) diff -Nru zfs-linux-0.7.5/debian/patches/2305-Allow-longer-SPA-names-in-stats.patch zfs-linux-0.7.5/debian/patches/2305-Allow-longer-SPA-names-in-stats.patch --- zfs-linux-0.7.5/debian/patches/2305-Allow-longer-SPA-names-in-stats.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2305-Allow-longer-SPA-names-in-stats.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,208 @@ +From 761b8ec6bf98f39550353173ad7bec5306073f9c Mon Sep 17 00:00:00 2001 +From: gaurkuma +Date: Fri, 11 Aug 2017 08:56:24 -0700 +Subject: [PATCH] Allow longer SPA names in stats +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +The pool name can be 256 chars long. Today, in /proc/spl/kstat/zfs/ +the name is limited to < 32 characters. This change is to allows +bigger pool names. + +Reviewed-by: Giuseppe Di Natale +Reviewed-by: loli10K +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Signed-off-by: gaurkuma +Closes #6481 +--- + lib/libspl/include/sys/kstat.h | 2 +- + module/icp/spi/kcf_spi.c | 11 ++++++----- + module/zfs/spa_stats.c | 25 +++++++++++++++---------- + 3 files changed, 22 insertions(+), 16 deletions(-) + +diff --git a/lib/libspl/include/sys/kstat.h b/lib/libspl/include/sys/kstat.h +index fcd3ed98b..24c71e27c 100644 +--- a/lib/libspl/include/sys/kstat.h ++++ b/lib/libspl/include/sys/kstat.h +@@ -59,7 +59,7 @@ typedef int kid_t; /* unique kstat id */ + * kcid = ioctl(kd, KSTAT_IOC_WRITE, kstat_t *); + */ + +-#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */ ++#define KSTAT_STRLEN 255 /* 254 chars + NULL; must be 16 * n - 1 */ + + /* + * The generic kstat header +diff --git a/module/icp/spi/kcf_spi.c b/module/icp/spi/kcf_spi.c +index c2c2b54bc..0a6e38df8 100644 +--- a/module/icp/spi/kcf_spi.c ++++ b/module/icp/spi/kcf_spi.c +@@ -111,7 +111,7 @@ int + crypto_register_provider(crypto_provider_info_t *info, + crypto_kcf_provider_handle_t *handle) + { +- char ks_name[KSTAT_STRLEN]; ++ char *ks_name; + + kcf_provider_desc_t *prov_desc = NULL; + int ret = CRYPTO_ARGUMENTS_BAD; +@@ -238,12 +238,12 @@ crypto_register_provider(crypto_provider_info_t *info, + * This kstat is deleted, when the provider unregisters. + */ + if (prov_desc->pd_prov_type == CRYPTO_SW_PROVIDER) { +- (void) snprintf(ks_name, KSTAT_STRLEN, "%s_%s", ++ ks_name = kmem_asprintf("%s_%s", + "NONAME", "provider_stats"); + } else { +- (void) snprintf(ks_name, KSTAT_STRLEN, "%s_%d_%u_%s", +- "NONAME", 0, +- prov_desc->pd_prov_id, "provider_stats"); ++ ks_name = kmem_asprintf("%s_%d_%u_%s", ++ "NONAME", 0, prov_desc->pd_prov_id, ++ "provider_stats"); + } + + prov_desc->pd_kstat = kstat_create("kcf", 0, ks_name, "crypto", +@@ -261,6 +261,7 @@ crypto_register_provider(crypto_provider_info_t *info, + prov_desc->pd_kstat->ks_update = kcf_prov_kstat_update; + kstat_install(prov_desc->pd_kstat); + } ++ strfree(ks_name); + } + + if (prov_desc->pd_prov_type == CRYPTO_HW_PROVIDER) +diff --git a/module/zfs/spa_stats.c b/module/zfs/spa_stats.c +index 7ca359806..8c4dba29e 100644 +--- a/module/zfs/spa_stats.c ++++ b/module/zfs/spa_stats.c +@@ -142,7 +142,7 @@ static void + spa_read_history_init(spa_t *spa) + { + spa_stats_history_t *ssh = &spa->spa_stats.read_history; +- char name[KSTAT_STRLEN]; ++ char *name; + kstat_t *ksp; + + mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL); +@@ -153,7 +153,7 @@ spa_read_history_init(spa_t *spa) + ssh->size = 0; + ssh->private = NULL; + +- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa)); ++ name = kmem_asprintf("zfs/%s", spa_name(spa)); + + ksp = kstat_create(name, 0, "reads", "misc", + KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL); +@@ -168,6 +168,7 @@ spa_read_history_init(spa_t *spa) + spa_read_history_data, spa_read_history_addr); + kstat_install(ksp); + } ++ strfree(name); + } + + static void +@@ -365,7 +366,7 @@ static void + spa_txg_history_init(spa_t *spa) + { + spa_stats_history_t *ssh = &spa->spa_stats.txg_history; +- char name[KSTAT_STRLEN]; ++ char *name; + kstat_t *ksp; + + mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL); +@@ -376,7 +377,7 @@ spa_txg_history_init(spa_t *spa) + ssh->size = 0; + ssh->private = NULL; + +- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa)); ++ name = kmem_asprintf("zfs/%s", spa_name(spa)); + + ksp = kstat_create(name, 0, "txgs", "misc", + KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL); +@@ -391,6 +392,7 @@ spa_txg_history_init(spa_t *spa) + spa_txg_history_data, spa_txg_history_addr); + kstat_install(ksp); + } ++ strfree(name); + } + + static void +@@ -598,7 +600,7 @@ static void + spa_tx_assign_init(spa_t *spa) + { + spa_stats_history_t *ssh = &spa->spa_stats.tx_assign_histogram; +- char name[KSTAT_STRLEN]; ++ char *name; + kstat_named_t *ks; + kstat_t *ksp; + int i; +@@ -609,7 +611,7 @@ spa_tx_assign_init(spa_t *spa) + ssh->size = ssh->count * sizeof (kstat_named_t); + ssh->private = kmem_alloc(ssh->size, KM_SLEEP); + +- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa)); ++ name = kmem_asprintf("zfs/%s", spa_name(spa)); + + for (i = 0; i < ssh->count; i++) { + ks = &((kstat_named_t *)ssh->private)[i]; +@@ -632,6 +634,7 @@ spa_tx_assign_init(spa_t *spa) + ksp->ks_update = spa_tx_assign_update; + kstat_install(ksp); + } ++ strfree(name); + } + + static void +@@ -678,12 +681,12 @@ static void + spa_io_history_init(spa_t *spa) + { + spa_stats_history_t *ssh = &spa->spa_stats.io_history; +- char name[KSTAT_STRLEN]; ++ char *name; + kstat_t *ksp; + + mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL); + +- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa)); ++ name = kmem_asprintf("zfs/%s", spa_name(spa)); + + ksp = kstat_create(name, 0, "io", "disk", KSTAT_TYPE_IO, 1, 0); + ssh->kstat = ksp; +@@ -694,6 +697,7 @@ spa_io_history_init(spa_t *spa) + ksp->ks_update = spa_io_history_update; + kstat_install(ksp); + } ++ strfree(name); + } + + static void +@@ -806,7 +810,7 @@ static void + spa_mmp_history_init(spa_t *spa) + { + spa_stats_history_t *ssh = &spa->spa_stats.mmp_history; +- char name[KSTAT_STRLEN]; ++ char *name; + kstat_t *ksp; + + mutex_init(&ssh->lock, NULL, MUTEX_DEFAULT, NULL); +@@ -817,7 +821,7 @@ spa_mmp_history_init(spa_t *spa) + ssh->size = 0; + ssh->private = NULL; + +- (void) snprintf(name, KSTAT_STRLEN, "zfs/%s", spa_name(spa)); ++ name = kmem_asprintf("zfs/%s", spa_name(spa)); + + ksp = kstat_create(name, 0, "multihost", "misc", + KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL); +@@ -832,6 +836,7 @@ spa_mmp_history_init(spa_t *spa) + spa_mmp_history_data, spa_mmp_history_addr); + kstat_install(ksp); + } ++ strfree(name); + } + + static void +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2306-vdev_mirror-load-balancing-fixes.patch zfs-linux-0.7.5/debian/patches/2306-vdev_mirror-load-balancing-fixes.patch --- zfs-linux-0.7.5/debian/patches/2306-vdev_mirror-load-balancing-fixes.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2306-vdev_mirror-load-balancing-fixes.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,206 @@ +From d6c6590c5dd727832a58e77f7830049631b0c266 Mon Sep 17 00:00:00 2001 +From: Gvozden Neskovic +Date: Fri, 4 Aug 2017 11:29:56 +0200 +Subject: [PATCH] vdev_mirror: load balancing fixes +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +vdev_queue: +- Track the last position of each vdev, including the io size, + in order to detect linear access of the following zio. +- Remove duplicate `vq_lastoffset` + +vdev_mirror: +- Correctly calculate the zio offset (signedness issue) +- Deprecate `vdev_queue_register_lastoffset()` +- Add `VDEV_LABEL_START_SIZE` to zio offset of leaf vdevs + +Reviewed-by: Brian Behlendorf +Signed-off-by: Gvozden Neskovic +Closes #6461 +--- + include/sys/vdev.h | 3 +-- + include/sys/vdev_impl.h | 1 - + module/zfs/vdev_mirror.c | 36 ++++++++++++++++-------------------- + module/zfs/vdev_queue.c | 21 +++++++-------------- + 4 files changed, 24 insertions(+), 37 deletions(-) + +diff --git a/include/sys/vdev.h b/include/sys/vdev.h +index 7157ef43f..473d2691c 100644 +--- a/include/sys/vdev.h ++++ b/include/sys/vdev.h +@@ -125,8 +125,7 @@ extern zio_t *vdev_queue_io(zio_t *zio); + extern void vdev_queue_io_done(zio_t *zio); + + extern int vdev_queue_length(vdev_t *vd); +-extern uint64_t vdev_queue_lastoffset(vdev_t *vd); +-extern void vdev_queue_register_lastoffset(vdev_t *vd, zio_t *zio); ++extern uint64_t vdev_queue_last_offset(vdev_t *vd); + + extern void vdev_config_dirty(vdev_t *vd); + extern void vdev_config_clean(vdev_t *vd); +diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h +index 7c5e54b08..4c2e3cd2e 100644 +--- a/include/sys/vdev_impl.h ++++ b/include/sys/vdev_impl.h +@@ -127,7 +127,6 @@ struct vdev_queue { + hrtime_t vq_io_delta_ts; + zio_t vq_io_search; /* used as local for stack reduction */ + kmutex_t vq_lock; +- uint64_t vq_lastoffset; + }; + + /* +diff --git a/module/zfs/vdev_mirror.c b/module/zfs/vdev_mirror.c +index 15d1f204f..0cf2bc665 100644 +--- a/module/zfs/vdev_mirror.c ++++ b/module/zfs/vdev_mirror.c +@@ -116,7 +116,8 @@ static const zio_vsd_ops_t vdev_mirror_vsd_ops = { + static int + vdev_mirror_load(mirror_map_t *mm, vdev_t *vd, uint64_t zio_offset) + { +- uint64_t lastoffset; ++ uint64_t last_offset; ++ int64_t offset_diff; + int load; + + /* All DVAs have equal weight at the root. */ +@@ -129,13 +130,17 @@ vdev_mirror_load(mirror_map_t *mm, vdev_t *vd, uint64_t zio_offset) + * worse overall when resilvering with compared to without. + */ + ++ /* Fix zio_offset for leaf vdevs */ ++ if (vd->vdev_ops->vdev_op_leaf) ++ zio_offset += VDEV_LABEL_START_SIZE; ++ + /* Standard load based on pending queue length. */ + load = vdev_queue_length(vd); +- lastoffset = vdev_queue_lastoffset(vd); ++ last_offset = vdev_queue_last_offset(vd); + + if (vd->vdev_nonrot) { + /* Non-rotating media. */ +- if (lastoffset == zio_offset) ++ if (last_offset == zio_offset) + return (load + zfs_vdev_mirror_non_rotating_inc); + + /* +@@ -148,16 +153,16 @@ vdev_mirror_load(mirror_map_t *mm, vdev_t *vd, uint64_t zio_offset) + } + + /* Rotating media I/O's which directly follow the last I/O. */ +- if (lastoffset == zio_offset) ++ if (last_offset == zio_offset) + return (load + zfs_vdev_mirror_rotating_inc); + + /* + * Apply half the seek increment to I/O's within seek offset +- * of the last I/O queued to this vdev as they should incur less ++ * of the last I/O issued to this vdev as they should incur less + * of a seek increment. + */ +- if (ABS(lastoffset - zio_offset) < +- zfs_vdev_mirror_rotating_seek_offset) ++ offset_diff = (int64_t)(last_offset - zio_offset); ++ if (ABS(offset_diff) < zfs_vdev_mirror_rotating_seek_offset) + return (load + (zfs_vdev_mirror_rotating_seek_inc / 2)); + + /* Apply the full seek increment to all other I/O's. */ +@@ -382,29 +387,20 @@ vdev_mirror_child_select(zio_t *zio) + mm->mm_preferred_cnt++; + } + +- if (mm->mm_preferred_cnt == 1) { +- vdev_queue_register_lastoffset( +- mm->mm_child[mm->mm_preferred[0]].mc_vd, zio); ++ if (mm->mm_preferred_cnt == 1) + return (mm->mm_preferred[0]); +- } + +- if (mm->mm_preferred_cnt > 1) { +- int c = vdev_mirror_preferred_child_randomize(zio); + +- vdev_queue_register_lastoffset(mm->mm_child[c].mc_vd, zio); +- return (c); +- } ++ if (mm->mm_preferred_cnt > 1) ++ return (vdev_mirror_preferred_child_randomize(zio)); + + /* + * Every device is either missing or has this txg in its DTL. + * Look for any child we haven't already tried before giving up. + */ + for (c = 0; c < mm->mm_children; c++) { +- if (!mm->mm_child[c].mc_tried) { +- vdev_queue_register_lastoffset(mm->mm_child[c].mc_vd, +- zio); ++ if (!mm->mm_child[c].mc_tried) + return (c); +- } + } + + /* +diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c +index 6b3e87291..40cba340a 100644 +--- a/module/zfs/vdev_queue.c ++++ b/module/zfs/vdev_queue.c +@@ -393,7 +393,7 @@ vdev_queue_init(vdev_t *vd) + sizeof (zio_t), offsetof(struct zio, io_queue_node)); + } + +- vq->vq_lastoffset = 0; ++ vq->vq_last_offset = 0; + } + + void +@@ -699,9 +699,8 @@ again: + */ + tree = vdev_queue_class_tree(vq, p); + vq->vq_io_search.io_timestamp = 0; +- vq->vq_io_search.io_offset = vq->vq_last_offset + 1; +- VERIFY3P(avl_find(tree, &vq->vq_io_search, +- &idx), ==, NULL); ++ vq->vq_io_search.io_offset = vq->vq_last_offset - 1; ++ VERIFY3P(avl_find(tree, &vq->vq_io_search, &idx), ==, NULL); + zio = avl_nearest(tree, idx, AVL_AFTER); + if (zio == NULL) + zio = avl_first(tree); +@@ -728,7 +727,7 @@ again: + } + + vdev_queue_pending_add(vq, zio); +- vq->vq_last_offset = zio->io_offset; ++ vq->vq_last_offset = zio->io_offset + zio->io_size; + + return (zio); + } +@@ -806,7 +805,7 @@ vdev_queue_io_done(zio_t *zio) + } + + /* +- * As these three methods are only used for load calculations we're not ++ * As these two methods are only used for load calculations we're not + * concerned if we get an incorrect value on 32bit platforms due to lack of + * vq_lock mutex use here, instead we prefer to keep it lock free for + * performance. +@@ -818,15 +817,9 @@ vdev_queue_length(vdev_t *vd) + } + + uint64_t +-vdev_queue_lastoffset(vdev_t *vd) ++vdev_queue_last_offset(vdev_t *vd) + { +- return (vd->vdev_queue.vq_lastoffset); +-} +- +-void +-vdev_queue_register_lastoffset(vdev_t *vd, zio_t *zio) +-{ +- vd->vdev_queue.vq_lastoffset = zio->io_offset + zio->io_size; ++ return (vd->vdev_queue.vq_last_offset); + } + + #if defined(_KERNEL) && defined(HAVE_SPL) +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2307-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch zfs-linux-0.7.5/debian/patches/2307-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch --- zfs-linux-0.7.5/debian/patches/2307-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2307-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,52 @@ +From 05f85a6a64e999748ffbdf7a76b406f0f0ceb8b3 Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Mon, 21 Aug 2017 13:11:11 -0700 +Subject: [PATCH] Fix zfs_ioc_pool_sync should not use fnvlist +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Use fnvlist on user input would allow user to easily panic zfs. + +Reviewed-by: Brian Behlendorf +Reviewed-by: Giuseppe Di Natale +Reviewed-by: Alek Pinchuk +Signed-off-by: Chunwei Chen +Closes #6529 +--- + module/zfs/zfs_ioctl.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/zfs_ioctl.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zfs_ioctl.c ++++ zfs-linux-0.7.5/module/zfs/zfs_ioctl.c +@@ -5909,20 +5909,26 @@ static int + zfs_ioc_pool_sync(const char *pool, nvlist_t *innvl, nvlist_t *onvl) + { + int err; +- boolean_t force; ++ boolean_t force = B_FALSE; + spa_t *spa; + + if ((err = spa_open(pool, &spa, FTAG)) != 0) + return (err); + +- force = fnvlist_lookup_boolean_value(innvl, "force"); ++ if (innvl) { ++ if (nvlist_lookup_boolean_value(innvl, "force", &force) != 0) { ++ err = SET_ERROR(EINVAL); ++ goto out; ++ } ++ } ++ + if (force) { + spa_config_enter(spa, SCL_CONFIG, FTAG, RW_WRITER); + vdev_config_dirty(spa->spa_root_vdev); + spa_config_exit(spa, SCL_CONFIG, FTAG); + } + txg_wait_synced(spa_get_dsl(spa), 0); +- ++out: + spa_close(spa, FTAG); + + return (err); diff -Nru zfs-linux-0.7.5/debian/patches/2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch zfs-linux-0.7.5/debian/patches/2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch --- zfs-linux-0.7.5/debian/patches/2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,53 @@ +From 006309e8d75b22efc7418095e408b3b3774ef8ea Mon Sep 17 00:00:00 2001 +From: Matthew Ahrens +Date: Mon, 3 Apr 2017 09:47:11 -0700 +Subject: [PATCH] OpenZFS 8375 - Kernel memory leak in nvpair code +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Matthew Ahrens +Reviewed by: Pavel Zakharov +Reviewed by: George Wilson +Reviewed by: Prashanth Sreenivasa +Reviewed by: Robert Mustacchi +Approved by: Dan McDonald +Reviewed-by: Don Brady +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Ported-by: Giuseppe Di Natale + +OpenZFS-issue: https://www.illumos.org/issues/8375 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/843c211 +Closes #6578 +--- + module/nvpair/nvpair.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c +index 2e3820981..8e654053c 100644 +--- a/module/nvpair/nvpair.c ++++ b/module/nvpair/nvpair.c +@@ -21,7 +21,7 @@ + + /* + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +- * Copyright (c) 2015, 2016 by Delphix. All rights reserved. ++ * Copyright (c) 2015, 2017 by Delphix. All rights reserved. + */ + + #include +@@ -2200,8 +2200,10 @@ nvs_embedded(nvstream_t *nvs, nvlist_t *embedded) + + nvlist_init(embedded, embedded->nvl_nvflag, priv); + +- if (nvs->nvs_recursion >= nvpair_max_recursion) ++ if (nvs->nvs_recursion >= nvpair_max_recursion) { ++ nvlist_free(embedded); + return (EINVAL); ++ } + nvs->nvs_recursion++; + if ((err = nvs_operation(nvs, embedded, NULL)) != 0) + nvlist_free(embedded); +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch zfs-linux-0.7.5/debian/patches/2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch --- zfs-linux-0.7.5/debian/patches/2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,40 @@ +From 24ded86e8dd528b056d73630ff33e526f9540dbc Mon Sep 17 00:00:00 2001 +From: Matthew Ahrens +Date: Thu, 4 Aug 2016 16:16:29 -0700 +Subject: [PATCH] OpenZFS 7261 - nvlist code should enforce name length limit +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Matthew Ahrens +Reviewed by: Sebastien Roy +Reviewed by: George Wilson +Reviewed by: Robert Mustacchi +Approved by: Dan McDonald +Reviewed-by: Don Brady +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Ported-by: Giuseppe Di Natale + +OpenZFS-issue: https://www.illumos.org/issues/7261 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/48dd5e6 +Closes #6579 +--- + module/nvpair/nvpair.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c +index 8e654053c..dffb226a2 100644 +--- a/module/nvpair/nvpair.c ++++ b/module/nvpair/nvpair.c +@@ -916,6 +916,8 @@ nvlist_add_common(nvlist_t *nvl, const char *name, + + /* calculate sizes of the nvpair elements and the nvpair itself */ + name_sz = strlen(name) + 1; ++ if (name_sz >= 1ULL << (sizeof (nvp->nvp_name_sz) * NBBY - 1)) ++ return (EINVAL); + + nvp_sz = NVP_SIZE_CALC(name_sz, value_sz); + +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch zfs-linux-0.7.5/debian/patches/2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch --- zfs-linux-0.7.5/debian/patches/2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,39 @@ +From ecaebdbcf693d9f08844e04dc97f6859b7c37c80 Mon Sep 17 00:00:00 2001 +From: Andriy Gapon +Date: Thu, 12 Nov 2015 11:23:37 -0800 +Subject: [PATCH] OpenZFS 5778 - nvpair_type_is_array() does not recognize + DATA_TYPE_INT8_ARRAY +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Andriy Gapon +Reviewed by: Matthew Ahrens +Reviewed by: Prakash Surya +Approved by: Dan McDonald +Reviewed-by: Don Brady +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Ported-by: Giuseppe Di Natale + +OpenZFS-issue: https://www.illumos.org/issues/5778 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/bf4d553 +Closes #6580 +--- + module/nvpair/nvpair.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c +index dffb226a2..24ef61e93 100644 +--- a/module/nvpair/nvpair.c ++++ b/module/nvpair/nvpair.c +@@ -1244,6 +1244,7 @@ nvpair_type_is_array(nvpair_t *nvp) + data_type_t type = NVP_TYPE(nvp); + + if ((type == DATA_TYPE_BYTE_ARRAY) || ++ (type == DATA_TYPE_INT8_ARRAY) || + (type == DATA_TYPE_UINT8_ARRAY) || + (type == DATA_TYPE_INT16_ARRAY) || + (type == DATA_TYPE_UINT16_ARRAY) || +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2311-dmu_objset-release-bonus-buffer-in-failure-path.patch zfs-linux-0.7.5/debian/patches/2311-dmu_objset-release-bonus-buffer-in-failure-path.patch --- zfs-linux-0.7.5/debian/patches/2311-dmu_objset-release-bonus-buffer-in-failure-path.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2311-dmu_objset-release-bonus-buffer-in-failure-path.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,49 @@ +From d22323e89f13975e1a60860aa78609584f00a606 Mon Sep 17 00:00:00 2001 +From: Gvozden Neskovic +Date: Wed, 30 Aug 2017 21:09:18 +0200 +Subject: [PATCH] dmu_objset: release bonus buffer in failure path +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Reported by kmemleak during testing of a new patch: + +``` +unreferenced object 0xffff9f1c12e38800 (size 1024): + comm "z_upgrade", pid 17842, jiffies 4296870904 (age 8746.268s) + backtrace: + kmemleak_alloc+0x7a/0x100 + __kmalloc_node+0x26c/0x510 + range_tree_create+0x39/0xa0 [zfs] + dmu_zfetch_init+0x73/0xe0 [zfs] + dnode_create+0x12c/0x3b0 [zfs] + dnode_hold_impl+0x1096/0x1130 [zfs] + dnode_hold+0x23/0x30 [zfs] + dmu_bonus_hold_impl+0x6b/0x370 [zfs] + dmu_bonus_hold+0x1e/0x30 [zfs] + dmu_objset_space_upgrade+0x114/0x310 [zfs] + dmu_objset_userobjspace_upgrade_cb+0xd8/0x150 [zfs] + dmu_objset_upgrade_task_cb+0x136/0x1e0 [zfs] + kthread+0x119/0x150 +``` + +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Gvozden Neskovic +Closes #6575 +--- + module/zfs/dmu_objset.c | 1 + + 1 file changed, 1 insertion(+) + +Index: zfs-linux-0.7.5/module/zfs/dmu_objset.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dmu_objset.c ++++ zfs-linux-0.7.5/module/zfs/dmu_objset.c +@@ -1853,6 +1853,7 @@ dmu_objset_space_upgrade(objset_t *os) + dmu_tx_hold_bonus(tx, obj); + objerr = dmu_tx_assign(tx, TXG_WAIT); + if (objerr != 0) { ++ dmu_buf_rele(db, FTAG); + dmu_tx_abort(tx); + continue; + } diff -Nru zfs-linux-0.7.5/debian/patches/2312-Fix-false-config_cache_write-events.patch zfs-linux-0.7.5/debian/patches/2312-Fix-false-config_cache_write-events.patch --- zfs-linux-0.7.5/debian/patches/2312-Fix-false-config_cache_write-events.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2312-Fix-false-config_cache_write-events.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,43 @@ +From d9549cba9640cd3b09d76b8cbd54387728b7be24 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Arkadiusz=20Buba=C5=82a?= +Date: Mon, 11 Sep 2017 19:25:01 +0200 +Subject: [PATCH] Fix false config_cache_write events +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +On pool import when the old cache file is removed +the ereport.fs.zfs.config_cache_write event is generated. +Because zpool export always removes cache file it happens +every export - import sequence. + +Reviewed-by: George Melikov +Reviewed-by: loli10K +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Arkadiusz Bubała +Closes #6617 +--- + module/zfs/spa_config.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c +index 7e712d368..8459e7362 100644 +--- a/module/zfs/spa_config.c ++++ b/module/zfs/spa_config.c +@@ -162,6 +162,11 @@ spa_config_write(spa_config_dirent_t *dp, nvlist_t *nvl) + */ + if (nvl == NULL) { + err = vn_remove(dp->scd_path, UIO_SYSSPACE, RMFILE); ++ /* ++ * Don't report an error when the cache file is already removed ++ */ ++ if (err == ENOENT) ++ err = 0; + return (err); + } + +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2313-Fix-printk-calls-missing-log-level.patch zfs-linux-0.7.5/debian/patches/2313-Fix-printk-calls-missing-log-level.patch --- zfs-linux-0.7.5/debian/patches/2313-Fix-printk-calls-missing-log-level.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2313-Fix-printk-calls-missing-log-level.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,29 @@ +From 7e98073379353a05498ac5a2f1a5df2a2257d6b0 Mon Sep 17 00:00:00 2001 +From: DeHackEd +Date: Mon, 25 Sep 2017 13:38:27 -0400 +Subject: [PATCH] Fix printk() calls missing log level +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Reviewed-by: George Melikov +Reviewed-by: Giuseppe Di Natale +Reviewed-by: Brian Behlendorf +Signed-off-by: DHE +Closes #6672 +--- + module/zfs/vdev_disk.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/vdev_disk.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/vdev_disk.c ++++ zfs-linux-0.7.5/module/zfs/vdev_disk.c +@@ -98,7 +98,7 @@ static void + vdev_disk_error(zio_t *zio) + { + #ifdef ZFS_DEBUG +- printk("ZFS: zio error=%d type=%d offset=%llu size=%llu " ++ printk(KERN_WARNING "ZFS: zio error=%d type=%d offset=%llu size=%llu " + "flags=%x\n", zio->io_error, zio->io_type, + (u_longlong_t)zio->io_offset, (u_longlong_t)zio->io_size, + zio->io_flags); diff -Nru zfs-linux-0.7.5/debian/patches/2314-Fix-abdstats-kstat-on-32-bit-systems.patch zfs-linux-0.7.5/debian/patches/2314-Fix-abdstats-kstat-on-32-bit-systems.patch --- zfs-linux-0.7.5/debian/patches/2314-Fix-abdstats-kstat-on-32-bit-systems.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2314-Fix-abdstats-kstat-on-32-bit-systems.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,42 @@ +From 57f4ef2e819670f8b28760b32745e0729f8d80d7 Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf +Date: Fri, 6 Oct 2017 11:23:12 -0700 +Subject: [PATCH] Fix abdstats kstat on 32-bit systems +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +When decrementing the struct_size and scatter_chunk_waste kstats +the value needs to be cast to an int on 32-bit systems. + +Reviewed-by: George Melikov +Signed-off-by: Brian Behlendorf +Closes #6721 +--- + module/zfs/abd.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/module/zfs/abd.c b/module/zfs/abd.c +index 765ac7fb7..3c7893dcd 100644 +--- a/module/zfs/abd.c ++++ b/module/zfs/abd.c +@@ -571,7 +571,7 @@ static inline void + abd_free_struct(abd_t *abd) + { + kmem_cache_free(abd_cache, abd); +- ABDSTAT_INCR(abdstat_struct_size, -sizeof (abd_t)); ++ ABDSTAT_INCR(abdstat_struct_size, -(int)sizeof (abd_t)); + } + + /* +@@ -618,7 +618,7 @@ abd_free_scatter(abd_t *abd) + ABDSTAT_BUMPDOWN(abdstat_scatter_cnt); + ABDSTAT_INCR(abdstat_scatter_data_size, -(int)abd->abd_size); + ABDSTAT_INCR(abdstat_scatter_chunk_waste, +- abd->abd_size - P2ROUNDUP(abd->abd_size, PAGESIZE)); ++ (int)abd->abd_size - (int)P2ROUNDUP(abd->abd_size, PAGESIZE)); + + abd_free_struct(abd); + } +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2315-Relax-ASSERT-for-6526.patch zfs-linux-0.7.5/debian/patches/2315-Relax-ASSERT-for-6526.patch --- zfs-linux-0.7.5/debian/patches/2315-Relax-ASSERT-for-6526.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2315-Relax-ASSERT-for-6526.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,33 @@ +From 94d49e8f9bd2e58a783066327c84b7d3b605ac0f Mon Sep 17 00:00:00 2001 +From: Tom Caputi +Date: Wed, 11 Oct 2017 12:12:48 -0400 +Subject: [PATCH] Relax ASSERT for #6526 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +This patch resolves a minor issue where an ASSERT in +metaslab_passivate() that only applies to non weight-based +metaslabs was erroneously applied to all metaslabs. + +Signed-off-by: Tom Caputi +--- + module/zfs/metaslab.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c +index 5e413c065..01e5234c7 100644 +--- a/module/zfs/metaslab.c ++++ b/module/zfs/metaslab.c +@@ -1937,7 +1937,8 @@ metaslab_passivate(metaslab_t *msp, uint64_t weight) + * this metaslab again. In that case, it had better be empty, + * or we would be leaving space on the table. + */ +- ASSERT(size >= SPA_MINBLOCKSIZE || ++ ASSERT(!WEIGHT_IS_SPACEBASED(msp->ms_weight) || ++ size >= SPA_MINBLOCKSIZE || + range_tree_space(msp->ms_tree) == 0); + ASSERT0(weight & METASLAB_ACTIVE_MASK); + +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2316-Fix-coverity-defects-147480-147584.patch zfs-linux-0.7.5/debian/patches/2316-Fix-coverity-defects-147480-147584.patch --- zfs-linux-0.7.5/debian/patches/2316-Fix-coverity-defects-147480-147584.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2316-Fix-coverity-defects-147480-147584.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,67 @@ +From ced28193b06b3d93f404a5d67713c124731a2a0d Mon Sep 17 00:00:00 2001 +From: Tobin Harding +Date: Tue, 17 Oct 2017 09:32:48 +1100 +Subject: [PATCH] Fix coverity defects: 147480, 147584 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +CID 147480: Logically dead code (DEADCODE) + +Remove non-null check and subsequent function call. Add ASSERT to future +proof the code. + +usage label is only jumped to before `zhp` is initialized. + +CID 147584: Out-of-bounds access (OVERRUN) + +Subtract length of current string from buffer length for `size` argument +to `snprintf`. + +Starting address for the write is the start of the buffer + the current +string length. We need to subtract this string length else risk a buffer +overflow. + +Reviewed-by: Brian Behlendorf +Signed-off-by: Tobin C. Harding +Closes #6745 +--- + cmd/zdb/zdb.c | 8 ++++---- + cmd/zfs/zfs_main.c | 3 +-- + 2 files changed, 5 insertions(+), 6 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -1982,13 +1982,13 @@ dump_object(objset_t *os, uint64_t objec + aux[0] = '\0'; + + if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) { +- (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)", +- ZDB_CHECKSUM_NAME(doi.doi_checksum)); ++ (void) snprintf(aux + strlen(aux), sizeof (aux) - strlen(aux), ++ " (K=%s)", ZDB_CHECKSUM_NAME(doi.doi_checksum)); + } + + if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) { +- (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)", +- ZDB_COMPRESS_NAME(doi.doi_compress)); ++ (void) snprintf(aux + strlen(aux), sizeof (aux) - strlen(aux), ++ " (Z=%s)", ZDB_COMPRESS_NAME(doi.doi_compress)); + } + + (void) printf("%10lld %3u %5s %5s %5s %6s %5s %6s %s%s\n", +Index: zfs-linux-0.7.5/cmd/zfs/zfs_main.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zfs/zfs_main.c ++++ zfs-linux-0.7.5/cmd/zfs/zfs_main.c +@@ -764,8 +764,7 @@ zfs_do_clone(int argc, char **argv) + return (!!ret); + + usage: +- if (zhp) +- zfs_close(zhp); ++ ASSERT3P(zhp, ==, NULL); + nvlist_free(props); + usage(B_FALSE); + return (-1); diff -Nru zfs-linux-0.7.5/debian/patches/2317-Fix-coverity-defects-CID-161388.patch zfs-linux-0.7.5/debian/patches/2317-Fix-coverity-defects-CID-161388.patch --- zfs-linux-0.7.5/debian/patches/2317-Fix-coverity-defects-CID-161388.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2317-Fix-coverity-defects-CID-161388.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,43 @@ +From c721ba435fc7d2fb61a6e586c5cc11c27f67b480 Mon Sep 17 00:00:00 2001 +From: Tobin Harding +Date: Wed, 18 Oct 2017 03:37:50 +1100 +Subject: [PATCH] Fix coverity defects: CID 161388 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +CID 161388: Resource Leak (REASOURCE_LEAK) + +Jump to errout so that file descriptor gets closed before returning +from function. + +Reviewed-by: Brian Behlendorf +Signed-off-by: Tobin C. Harding +Closes #6755 +--- + cmd/zpool/zpool_main.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zpool/zpool_main.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zpool/zpool_main.c ++++ zfs-linux-0.7.5/cmd/zpool/zpool_main.c +@@ -895,7 +895,8 @@ zpool_do_labelclear(int argc, char **arg + if (zpool_read_label(fd, &config, NULL) != 0 || config == NULL) { + (void) fprintf(stderr, + gettext("failed to check state for %s\n"), vdev); +- return (1); ++ ret = 1; ++ goto errout; + } + nvlist_free(config); + +@@ -903,7 +904,8 @@ zpool_do_labelclear(int argc, char **arg + if (ret != 0) { + (void) fprintf(stderr, + gettext("failed to check state for %s\n"), vdev); +- return (1); ++ ret = 1; ++ goto errout; + } + + if (!inuse) diff -Nru zfs-linux-0.7.5/debian/patches/2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch zfs-linux-0.7.5/debian/patches/2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch --- zfs-linux-0.7.5/debian/patches/2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,33 @@ +From f8cd871a01a5e38e35cb4d44768dce09265265f4 Mon Sep 17 00:00:00 2001 +From: adisbladis +Date: Tue, 24 Oct 2017 02:00:45 +0800 +Subject: [PATCH] Use ashift=12 by default on SSDSC2BW48 disks +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Currently the 480GB models of this disk do not use ashift=12 by +default. SSDSC2BW48 is also optimized for 4k blocks. + +Reviewed-by: Brian Behlendorf +Reviewed-by: George Melikov +Signed-off-by: adisbladis +Closes #6774 +--- + cmd/zpool/zpool_vdev.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c +index 4c3793d6e..04a2611f9 100644 +--- a/cmd/zpool/zpool_vdev.c ++++ b/cmd/zpool/zpool_vdev.c +@@ -188,6 +188,7 @@ static vdev_disk_db_entry_t vdev_disk_database[] = { + {"ATA INTEL SSDSC2BB60", 4096}, + {"ATA INTEL SSDSC2BB80", 4096}, + {"ATA INTEL SSDSC2BW24", 4096}, ++ {"ATA INTEL SSDSC2BW48", 4096}, + {"ATA INTEL SSDSC2BP24", 4096}, + {"ATA INTEL SSDSC2BP48", 4096}, + {"NA SmrtStorSDLKAE9W", 4096}, +-- +2.15.1 + diff -Nru zfs-linux-0.7.5/debian/patches/2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch zfs-linux-0.7.5/debian/patches/2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch --- zfs-linux-0.7.5/debian/patches/2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,274 @@ +From a032ac4b3819408b2e17085224290b6a762de79a Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf +Date: Thu, 26 Oct 2017 12:57:53 -0700 +Subject: [PATCH] OpenZFS 8558, 8602 - lwp_create() returns EAGAIN +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +8558 lwp_create() returns EAGAIN on system with more than 80K ZFS filesystems + +On a system with more than 80K ZFS filesystems, we've seen cases +where lwp_create() will start to fail by returning EAGAIN. The +problem being, for each of those 80K ZFS filesystems, a taskq will +be created for each dataset as part of the ZIL for each dataset. + +Porting Notes: +- The new nomem taskq kstat was dropped. +- Added module options and documentation for new tunings + zfs_zil_clean_taskq_nthr_pct, zfs_zil_clean_taskq_minalloc, + zfs_zil_clean_taskq_maxalloc, and zfs_sync_taskq_batch_pct. + +Reviewed by: George Wilson +Reviewed by: Sebastien Roy +Approved by: Robert Mustacchi +Authored by: Prakash Surya +Reviewed-by: George Melikov +Reviewed-by: Chris Dunlop +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8558 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/216d772 + +8602 remove unused "dp_early_sync_tasks" field from "dsl_pool" structure + +Reviewed by: Serapheim Dimitropoulos +Reviewed by: Matthew Ahrens +Approved by: Robert Mustacchi +Authored by: Prakash Surya +Reviewed-by: George Melikov +Reviewed-by: Chris Dunlop +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8602 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/2bcb545 +Closes #6779 +--- + include/sys/dsl_pool.h | 1 + + include/sys/zil_impl.h | 1 - + man/man5/zfs-module-parameters.5 | 48 ++++++++++++++++++++++++++++++ + module/zfs/dsl_pool.c | 50 ++++++++++++++++++++++++++++++++ + module/zfs/zil.c | 15 ++++------ + 5 files changed, 105 insertions(+), 10 deletions(-) + +Index: zfs-linux-0.7.5/include/sys/dsl_pool.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/sys/dsl_pool.h ++++ zfs-linux-0.7.5/include/sys/dsl_pool.h +@@ -126,6 +126,7 @@ typedef struct dsl_pool { + txg_list_t dp_dirty_dirs; + txg_list_t dp_sync_tasks; + taskq_t *dp_sync_taskq; ++ taskq_t *dp_zil_clean_taskq; + + /* + * Protects administrative changes (properties, namespace) +Index: zfs-linux-0.7.5/include/sys/zil_impl.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/sys/zil_impl.h ++++ zfs-linux-0.7.5/include/sys/zil_impl.h +@@ -124,7 +124,6 @@ struct zilog { + list_t zl_lwb_list; /* in-flight log write list */ + kmutex_t zl_vdev_lock; /* protects zl_vdev_tree */ + avl_tree_t zl_vdev_tree; /* vdevs to flush in zil_commit() */ +- taskq_t *zl_clean_taskq; /* runs lwb and itx clean tasks */ + avl_tree_t zl_bp_tree; /* track bps during log parse */ + clock_t zl_replay_time; /* lbolt of when replay started */ + uint64_t zl_replay_blks; /* number of log blocks replayed */ +Index: zfs-linux-0.7.5/man/man5/zfs-module-parameters.5 +=================================================================== +--- zfs-linux-0.7.5.orig/man/man5/zfs-module-parameters.5 ++++ zfs-linux-0.7.5/man/man5/zfs-module-parameters.5 +@@ -1746,6 +1746,18 @@ Default value: \fB2\fR. + .sp + .ne 2 + .na ++\fBzfs_sync_taskq_batch_pct\fR (int) ++.ad ++.RS 12n ++This controls the number of threads used by the dp_sync_taskq. The default ++value of 75% will create a maximum of one thread per cpu. ++.sp ++Default value: \fB75\fR. ++.RE ++ ++.sp ++.ne 2 ++.na + \fBzfs_sync_pass_dont_compress\fR (int) + .ad + .RS 12n +@@ -2021,6 +2033,42 @@ Default value: \fB0\fR. + .RE + + .sp ++.ne 2 ++.na ++\fBzfs_zil_clean_taskq_maxalloc\fR (int) ++.ad ++.RS 12n ++The maximum number of taskq entries that are allowed to be cached. When this ++limit is exceeded itx's will be cleaned synchronously. ++.sp ++Default value: \fB1048576\fR. ++.RE ++ ++.sp ++.ne 2 ++.na ++\fBzfs_zil_clean_taskq_minalloc\fR (int) ++.ad ++.RS 12n ++The number of taskq entries that are pre-populated when the taskq is first ++created and are immediately available for use. ++.sp ++Default value: \fB1024\fR. ++.RE ++ ++.sp ++.ne 2 ++.na ++\fBzfs_zil_clean_taskq_nthr_pct\fR (int) ++.ad ++.RS 12n ++This controls the number of threads used by the dp_zil_clean_taskq. The default ++value of 100% will create a maximum of one thread per cpu. ++.sp ++Default value: \fB100\fR. ++.RE ++ ++.sp + .ne 2 + .na + \fBzil_replay_disable\fR (int) +Index: zfs-linux-0.7.5/module/zfs/dsl_pool.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dsl_pool.c ++++ zfs-linux-0.7.5/module/zfs/dsl_pool.c +@@ -135,6 +135,36 @@ unsigned long zfs_delay_scale = 1000 * 1 + */ + int zfs_sync_taskq_batch_pct = 75; + ++/* ++ * These tunables determine the behavior of how zil_itxg_clean() is ++ * called via zil_clean() in the context of spa_sync(). When an itxg ++ * list needs to be cleaned, TQ_NOSLEEP will be used when dispatching. ++ * If the dispatch fails, the call to zil_itxg_clean() will occur ++ * synchronously in the context of spa_sync(), which can negatively ++ * impact the performance of spa_sync() (e.g. in the case of the itxg ++ * list having a large number of itxs that needs to be cleaned). ++ * ++ * Thus, these tunables can be used to manipulate the behavior of the ++ * taskq used by zil_clean(); they determine the number of taskq entries ++ * that are pre-populated when the taskq is first created (via the ++ * "zfs_zil_clean_taskq_minalloc" tunable) and the maximum number of ++ * taskq entries that are cached after an on-demand allocation (via the ++ * "zfs_zil_clean_taskq_maxalloc"). ++ * ++ * The idea being, we want to try reasonably hard to ensure there will ++ * already be a taskq entry pre-allocated by the time that it is needed ++ * by zil_clean(). This way, we can avoid the possibility of an ++ * on-demand allocation of a new taskq entry from failing, which would ++ * result in zil_itxg_clean() being called synchronously from zil_clean() ++ * (which can adversely affect performance of spa_sync()). ++ * ++ * Additionally, the number of threads used by the taskq can be ++ * configured via the "zfs_zil_clean_taskq_nthr_pct" tunable. ++ */ ++int zfs_zil_clean_taskq_nthr_pct = 100; ++int zfs_zil_clean_taskq_minalloc = 1024; ++int zfs_zil_clean_taskq_maxalloc = 1024 * 1024; ++ + int + dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **ddp) + { +@@ -176,6 +206,12 @@ dsl_pool_open_impl(spa_t *spa, uint64_t + zfs_sync_taskq_batch_pct, minclsyspri, 1, INT_MAX, + TASKQ_THREADS_CPU_PCT); + ++ dp->dp_zil_clean_taskq = taskq_create("dp_zil_clean_taskq", ++ zfs_zil_clean_taskq_nthr_pct, minclsyspri, ++ zfs_zil_clean_taskq_minalloc, ++ zfs_zil_clean_taskq_maxalloc, ++ TASKQ_PREPOPULATE | TASKQ_THREADS_CPU_PCT); ++ + mutex_init(&dp->dp_lock, NULL, MUTEX_DEFAULT, NULL); + cv_init(&dp->dp_spaceavail_cv, NULL, CV_DEFAULT, NULL); + +@@ -334,6 +370,7 @@ dsl_pool_close(dsl_pool_t *dp) + txg_list_destroy(&dp->dp_sync_tasks); + txg_list_destroy(&dp->dp_dirty_dirs); + ++ taskq_destroy(dp->dp_zil_clean_taskq); + taskq_destroy(dp->dp_sync_taskq); + + /* +@@ -1142,5 +1179,18 @@ MODULE_PARM_DESC(zfs_delay_scale, "how q + module_param(zfs_sync_taskq_batch_pct, int, 0644); + MODULE_PARM_DESC(zfs_sync_taskq_batch_pct, + "max percent of CPUs that are used to sync dirty data"); ++ ++module_param(zfs_zil_clean_taskq_nthr_pct, int, 0644); ++MODULE_PARM_DESC(zfs_zil_clean_taskq_nthr_pct, ++ "max percent of CPUs that are used per dp_sync_taskq"); ++ ++module_param(zfs_zil_clean_taskq_minalloc, int, 0644); ++MODULE_PARM_DESC(zfs_zil_clean_taskq_minalloc, ++ "number of taskq entries that are pre-populated"); ++ ++module_param(zfs_zil_clean_taskq_maxalloc, int, 0644); ++MODULE_PARM_DESC(zfs_zil_clean_taskq_maxalloc, ++ "max number of taskq entries that are cached"); ++ + /* END CSTYLED */ + #endif +Index: zfs-linux-0.7.5/module/zfs/zil.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zil.c ++++ zfs-linux-0.7.5/module/zfs/zil.c +@@ -1452,8 +1452,7 @@ zil_clean(zilog_t *zilog, uint64_t synce + return; + } + ASSERT3U(itxg->itxg_txg, <=, synced_txg); +- ASSERT(itxg->itxg_txg != 0); +- ASSERT(zilog->zl_clean_taskq != NULL); ++ ASSERT3U(itxg->itxg_txg, !=, 0); + clean_me = itxg->itxg_itxs; + itxg->itxg_itxs = NULL; + itxg->itxg_txg = 0; +@@ -1464,8 +1463,11 @@ zil_clean(zilog_t *zilog, uint64_t synce + * free it in-line. This should be rare. Note, using TQ_SLEEP + * created a bad performance problem. + */ +- if (taskq_dispatch(zilog->zl_clean_taskq, +- (void (*)(void *))zil_itxg_clean, clean_me, TQ_NOSLEEP) == 0) ++ ASSERT3P(zilog->zl_dmu_pool, !=, NULL); ++ ASSERT3P(zilog->zl_dmu_pool->dp_zil_clean_taskq, !=, NULL); ++ taskqid_t id = taskq_dispatch(zilog->zl_dmu_pool->dp_zil_clean_taskq, ++ (void (*)(void *))zil_itxg_clean, clean_me, TQ_NOSLEEP); ++ if (id == TASKQID_INVALID) + zil_itxg_clean(clean_me); + } + +@@ -1938,13 +1940,10 @@ zil_open(objset_t *os, zil_get_data_t *g + { + zilog_t *zilog = dmu_objset_zil(os); + +- ASSERT(zilog->zl_clean_taskq == NULL); + ASSERT(zilog->zl_get_data == NULL); + ASSERT(list_is_empty(&zilog->zl_lwb_list)); + + zilog->zl_get_data = get_data; +- zilog->zl_clean_taskq = taskq_create("zil_clean", 1, defclsyspri, +- 2, 2, TASKQ_PREPOPULATE); + + return (zilog); + } +@@ -1979,8 +1978,6 @@ zil_close(zilog_t *zilog) + if (txg < spa_freeze_txg(zilog->zl_spa)) + VERIFY(!zilog_is_dirty(zilog)); + +- taskq_destroy(zilog->zl_clean_taskq); +- zilog->zl_clean_taskq = NULL; + zilog->zl_get_data = NULL; + + /* diff -Nru zfs-linux-0.7.5/debian/patches/2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch zfs-linux-0.7.5/debian/patches/2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch --- zfs-linux-0.7.5/debian/patches/2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,255 @@ +From ee45fbd89465f12b39e97173a088175d4b712b5f Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Fri, 27 Oct 2017 01:58:38 +0200 +Subject: [PATCH] ZFS send fails to dump objects larger than 128PiB +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +When dumping objects larger than 128PiB it's possible for do_dump() to +miscalculate the FREE_RECORD offset due to an integer overflow +condition: this prevents the receiving end from correctly restoring +the dumped object. + +Reviewed-by: Brian Behlendorf +Signed-off-by: Fabian Grünbichler +Signed-off-by: loli10K +Closes #6760 +--- + +Index: zfs-linux-0.7.5/module/zfs/bpobj.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/bpobj.c ++++ zfs-linux-0.7.5/module/zfs/bpobj.c +@@ -261,7 +261,7 @@ bpobj_iterate_impl(bpobj_t *bpo, bpobj_i + } + if (free) { + VERIFY3U(0, ==, dmu_free_range(bpo->bpo_os, bpo->bpo_object, +- (i + 1) * sizeof (blkptr_t), -1ULL, tx)); ++ (i + 1) * sizeof (blkptr_t), DMU_OBJECT_END, tx)); + } + if (err || !bpo->bpo_havesubobj || bpo->bpo_phys->bpo_subobjs == 0) + goto out; +@@ -339,7 +339,7 @@ bpobj_iterate_impl(bpobj_t *bpo, bpobj_i + if (free) { + VERIFY3U(0, ==, dmu_free_range(bpo->bpo_os, + bpo->bpo_phys->bpo_subobjs, +- (i + 1) * sizeof (uint64_t), -1ULL, tx)); ++ (i + 1) * sizeof (uint64_t), DMU_OBJECT_END, tx)); + } + + out: +Index: zfs-linux-0.7.5/module/zfs/dmu.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dmu.c ++++ zfs-linux-0.7.5/module/zfs/dmu.c +@@ -887,7 +887,7 @@ dmu_free_range(objset_t *os, uint64_t ob + if (err) + return (err); + ASSERT(offset < UINT64_MAX); +- ASSERT(size == -1ULL || size <= UINT64_MAX - offset); ++ ASSERT(size == DMU_OBJECT_END || size <= UINT64_MAX - offset); + dnode_free_range(dn, offset, size, tx); + dnode_rele(dn, FTAG); + return (0); +Index: zfs-linux-0.7.5/module/zfs/dmu_send.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dmu_send.c ++++ zfs-linux-0.7.5/module/zfs/dmu_send.c +@@ -224,9 +224,6 @@ dump_free(dmu_sendarg_t *dsp, uint64_t o + (object == dsp->dsa_last_data_object && + offset > dsp->dsa_last_data_offset)); + +- if (length != -1ULL && offset + length < offset) +- length = -1ULL; +- + /* + * If there is a pending op, but it's not PENDING_FREE, push it out, + * since free block aggregation can only be done for blocks of the +@@ -243,19 +240,22 @@ dump_free(dmu_sendarg_t *dsp, uint64_t o + + if (dsp->dsa_pending_op == PENDING_FREE) { + /* +- * There should never be a PENDING_FREE if length is -1 +- * (because dump_dnode is the only place where this +- * function is called with a -1, and only after flushing +- * any pending record). ++ * There should never be a PENDING_FREE if length is ++ * DMU_OBJECT_END (because dump_dnode is the only place where ++ * this function is called with a DMU_OBJECT_END, and only after ++ * flushing any pending record). + */ +- ASSERT(length != -1ULL); ++ ASSERT(length != DMU_OBJECT_END); + /* + * Check to see whether this free block can be aggregated + * with pending one. + */ + if (drrf->drr_object == object && drrf->drr_offset + + drrf->drr_length == offset) { +- drrf->drr_length += length; ++ if (offset + length < offset) ++ drrf->drr_length = DMU_OBJECT_END; ++ else ++ drrf->drr_length += length; + return (0); + } else { + /* not a continuation. Push out pending record */ +@@ -269,9 +269,12 @@ dump_free(dmu_sendarg_t *dsp, uint64_t o + dsp->dsa_drr->drr_type = DRR_FREE; + drrf->drr_object = object; + drrf->drr_offset = offset; +- drrf->drr_length = length; ++ if (offset + length < offset) ++ drrf->drr_length = DMU_OBJECT_END; ++ else ++ drrf->drr_length = length; + drrf->drr_toguid = dsp->dsa_toguid; +- if (length == -1ULL) { ++ if (length == DMU_OBJECT_END) { + if (dump_record(dsp, NULL, 0) != 0) + return (SET_ERROR(EINTR)); + } else { +@@ -530,7 +533,7 @@ dump_dnode(dmu_sendarg_t *dsp, uint64_t + + /* Free anything past the end of the file. */ + if (dump_free(dsp, object, (dnp->dn_maxblkid + 1) * +- (dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), -1ULL) != 0) ++ (dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), DMU_OBJECT_END) != 0) + return (SET_ERROR(EINTR)); + if (dsp->dsa_err != 0) + return (SET_ERROR(EINTR)); +@@ -666,7 +669,9 @@ do_dump(dmu_sendarg_t *dsa, struct send_ + } else if (BP_IS_HOLE(bp)) { + uint64_t span = BP_SPAN(dblkszsec, indblkshift, zb->zb_level); + uint64_t offset = zb->zb_blkid * span; +- err = dump_free(dsa, zb->zb_object, offset, span); ++ /* Don't dump free records for offsets > DMU_OBJECT_END */ ++ if (zb->zb_blkid == 0 || span <= DMU_OBJECT_END / zb->zb_blkid) ++ err = dump_free(dsa, zb->zb_object, offset, span); + } else if (zb->zb_level > 0 || type == DMU_OT_OBJSET) { + return (0); + } else if (type == DMU_OT_DNODE) { +@@ -2498,7 +2503,7 @@ receive_free(struct receive_writer_arg * + { + int err; + +- if (drrf->drr_length != -1ULL && ++ if (drrf->drr_length != DMU_OBJECT_END && + drrf->drr_offset + drrf->drr_length < drrf->drr_offset) + return (SET_ERROR(EINVAL)); + +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -172,7 +172,7 @@ tags = ['functional', 'cli_root', 'zfs_r + [tests/functional/cli_root/zfs_send] + tests = ['zfs_send_001_pos', 'zfs_send_002_pos', 'zfs_send_003_pos', + 'zfs_send_004_neg', 'zfs_send_005_pos', 'zfs_send_006_pos', +- 'zfs_send_007_pos'] ++ 'zfs_send_007_pos', 'zfs_send_sparse'] + tags = ['functional', 'cli_root', 'zfs_send'] + + [tests/functional/cli_root/zfs_set] +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am +@@ -9,4 +9,5 @@ dist_pkgdata_SCRIPTS = \ + zfs_send_004_neg.ksh \ + zfs_send_005_pos.ksh \ + zfs_send_006_pos.ksh \ +- zfs_send_007_pos.ksh ++ zfs_send_007_pos.ksh \ ++ zfs_send_sparse.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh +@@ -0,0 +1,83 @@ ++#!/bin/ksh -p ++# ++# This file and its contents are supplied under the terms of the ++# Common Development and Distribution License ("CDDL"), version 1.0. ++# You may only use this file in accordance with the terms of version ++# 1.0 of the CDDL. ++# ++# A full copy of the text of the CDDL should have accompanied this ++# source. A copy of the CDDL is also available via the Internet at ++# http://www.illumos.org/license/CDDL. ++# ++ ++# ++# Copyright 2017, loli10K . All rights reserved. ++# ++ ++. $STF_SUITE/include/libtest.shlib ++ ++# ++# DESCRIPTION: ++# 'zfs send' should be able to send (big) sparse files correctly. ++# ++# STRATEGY: ++# 1. Create sparse files of various size ++# 2. Snapshot and send these sparse files ++# 3. Verify these files are received correctly and we don't trigger any issue ++# like the one described in https://github.com/zfsonlinux/zfs/pull/6760 ++# ++ ++verify_runnable "both" ++ ++function cleanup ++{ ++ datasetexists $SENDFS && log_must zfs destroy -r $SENDFS ++ datasetexists $RECVFS && log_must zfs destroy -r $RECVFS ++} ++ ++# ++# Write 1 random byte at $offset of "source" file in $sendfs dataset ++# Snapshot and send $sendfs dataset to $recvfs ++# Compare the received file with its source ++# ++function write_compare_files # ++{ ++ typeset sendfs="$1" ++ typeset recvfs="$2" ++ typeset offset="$3" ++ ++ # create source filesystem ++ log_must zfs create $sendfs ++ # write sparse file ++ sendfile="$(get_prop mountpoint $sendfs)/data.bin" ++ log_must dd if=/dev/urandom of=$sendfile bs=1 count=1 seek=$offset ++ # send/receive the file ++ log_must zfs snapshot $sendfs@snap ++ log_must eval "zfs send $sendfs@snap | zfs receive $recvfs" ++ # compare sparse files ++ recvfile="$(get_prop mountpoint $recvfs)/data.bin" ++ log_must cmp $sendfile $recvfile $offset $offset ++ sendsz=$(stat -c '%s' $sendfile) ++ recvsz=$(stat -c '%s' $recvfile) ++ if [[ $sendsz -ne $recvsz ]]; then ++ log_fail "$sendfile ($sendsz) and $recvfile ($recvsz) differ." ++ fi ++ # cleanup ++ log_must zfs destroy -r $sendfs ++ log_must zfs destroy -r $recvfs ++} ++ ++log_assert "'zfs send' should be able to send (big) sparse files correctly." ++log_onexit cleanup ++ ++SENDFS="$TESTPOOL/sendfs" ++RECVFS="$TESTPOOL/recvfs" ++OFF_T_MAX="$(echo '2 ^ 40 * 8 - 1' | bc)" ++ ++for i in {1..60}; do ++ offset=$(echo "2 ^ $i" | bc) ++ [[ is_32bit ]] && [[ $offset -ge $OFF_T_MAX ]] && continue; ++ write_compare_files $SENDFS $RECVFS $offset ++done ++ ++log_pass "'zfs send' sends (big) sparse files correctly." diff -Nru zfs-linux-0.7.5/debian/patches/2321-Sort-output-of-tunables-in-arc_summary.py.patch zfs-linux-0.7.5/debian/patches/2321-Sort-output-of-tunables-in-arc_summary.py.patch --- zfs-linux-0.7.5/debian/patches/2321-Sort-output-of-tunables-in-arc_summary.py.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2321-Sort-output-of-tunables-in-arc_summary.py.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,45 @@ +From 681957fe2efc6a15b9675387075514957cbcd821 Mon Sep 17 00:00:00 2001 +From: "Scot W. Stevenson" +Date: Tue, 7 Nov 2017 23:50:15 +0100 +Subject: [PATCH] Sort output of tunables in arc_summary.py +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Sort list of tunables printed by _tunable_summary() +alphabetically + +Reviewed-by: Brian Behlendorf +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Scot W. Stevenson +Closes #6828 +--- + cmd/arc_summary/arc_summary.py | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +Index: zfs-linux-0.7.5/cmd/arc_summary/arc_summary.py +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/arc_summary/arc_summary.py ++++ zfs-linux-0.7.5/cmd/arc_summary/arc_summary.py +@@ -881,14 +881,18 @@ def _tunable_summary(Kstat): + sys.stderr.write("Tunable descriptions will be disabled.\n") + + sys.stdout.write("ZFS Tunable:\n") ++ names.sort() ++ ++ if alternate_tunable_layout: ++ format = "\t%s=%s\n" ++ else: ++ format = "\t%-50s%s\n" ++ + for name in names: ++ + if not name: + continue + +- format = "\t%-50s%s\n" +- if alternate_tunable_layout: +- format = "\t%s=%s\n" +- + if show_tunable_descriptions and name in descriptions: + sys.stdout.write("\t# %s\n" % descriptions[name]) + diff -Nru zfs-linux-0.7.5/debian/patches/2322-Fix-data-on-evict_skips-in-arc_summary.py.patch zfs-linux-0.7.5/debian/patches/2322-Fix-data-on-evict_skips-in-arc_summary.py.patch --- zfs-linux-0.7.5/debian/patches/2322-Fix-data-on-evict_skips-in-arc_summary.py.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2322-Fix-data-on-evict_skips-in-arc_summary.py.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,49 @@ +From 8d187769736688044c3c58a6a56069a54210a656 Mon Sep 17 00:00:00 2001 +From: "Scot W. Stevenson" +Date: Sat, 18 Nov 2017 23:07:04 +0100 +Subject: [PATCH] Fix data on evict_skips in arc_summary.py +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Display correct data from kstat arcstats for evict_skips, +which is currently repeating the data from mutex_misses. +Fixes #6882 + +Reviewed-by: Brian Behlendorf +Reviewed-by: George Melikov +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Scot W. Stevenson +Closes #6882 +Closes #6883 +--- + cmd/arc_summary/arc_summary.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/cmd/arc_summary/arc_summary.py +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/arc_summary/arc_summary.py ++++ zfs-linux-0.7.5/cmd/arc_summary/arc_summary.py +@@ -176,12 +176,13 @@ def get_arc_summary(Kstat): + # ARC Misc. + deleted = Kstat["kstat.zfs.misc.arcstats.deleted"] + mutex_miss = Kstat["kstat.zfs.misc.arcstats.mutex_miss"] ++ evict_skip = Kstat["kstat.zfs.misc.arcstats.evict_skip"] + + # ARC Misc. + output["arc_misc"] = {} + output["arc_misc"]["deleted"] = fHits(deleted) + output["arc_misc"]['mutex_miss'] = fHits(mutex_miss) +- output["arc_misc"]['evict_skips'] = fHits(mutex_miss) ++ output["arc_misc"]['evict_skips'] = fHits(evict_skip) + + # ARC Sizing + arc_size = Kstat["kstat.zfs.misc.arcstats.size"] +@@ -276,7 +277,7 @@ def _arc_summary(Kstat): + sys.stdout.write("\tMutex Misses:\t\t\t\t%s\n" % + arc['arc_misc']['mutex_miss']) + sys.stdout.write("\tEvict Skips:\t\t\t\t%s\n" % +- arc['arc_misc']['mutex_miss']) ++ arc['arc_misc']['evict_skips']) + sys.stdout.write("\n") + + # ARC Sizing diff -Nru zfs-linux-0.7.5/debian/patches/2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch zfs-linux-0.7.5/debian/patches/2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch --- zfs-linux-0.7.5/debian/patches/2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,66 @@ +From 674b89342e43bd83659285d730b5b6a98f8b4b48 Mon Sep 17 00:00:00 2001 +From: Tony Hutter +Date: Wed, 6 Dec 2017 11:43:07 -0800 +Subject: [PATCH] Fix segfault in zpool iostat when adding VDEVs +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Fix a segfault when running 'zpool iostat -v 1' while adding +a VDEV. + +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Signed-off-by: Tony Hutter +Closes #6748 +Closes #6872 +--- + cmd/zpool/zpool_main.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zpool/zpool_main.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zpool/zpool_main.c ++++ zfs-linux-0.7.5/cmd/zpool/zpool_main.c +@@ -3624,7 +3624,7 @@ print_vdev_stats(zpool_handle_t *zhp, co + nvlist_t *newnv, iostat_cbdata_t *cb, int depth) + { + nvlist_t **oldchild, **newchild; +- uint_t c, children; ++ uint_t c, children, oldchildren; + vdev_stat_t *oldvs, *newvs, *calcvs; + vdev_stat_t zerovs = { 0 }; + char *vname; +@@ -3736,9 +3736,13 @@ children: + &newchild, &children) != 0) + return (ret); + +- if (oldnv && nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_CHILDREN, +- &oldchild, &c) != 0) +- return (ret); ++ if (oldnv) { ++ if (nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_CHILDREN, ++ &oldchild, &oldchildren) != 0) ++ return (ret); ++ ++ children = MIN(oldchildren, children); ++ } + + for (c = 0; c < children; c++) { + uint64_t ishole = B_FALSE, islog = B_FALSE; +@@ -3794,9 +3798,13 @@ children: + &newchild, &children) != 0) + return (ret); + +- if (oldnv && nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_L2CACHE, +- &oldchild, &c) != 0) +- return (ret); ++ if (oldnv) { ++ if (nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_L2CACHE, ++ &oldchild, &oldchildren) != 0) ++ return (ret); ++ ++ children = MIN(oldchildren, children); ++ } + + if (children > 0) { + if ((!(cb->cb_flags & IOS_ANYHISTO_M)) && !cb->cb_scripted && diff -Nru zfs-linux-0.7.5/debian/patches/2324-ZTS-Fix-create-o_ashift-test-case.patch zfs-linux-0.7.5/debian/patches/2324-ZTS-Fix-create-o_ashift-test-case.patch --- zfs-linux-0.7.5/debian/patches/2324-ZTS-Fix-create-o_ashift-test-case.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2324-ZTS-Fix-create-o_ashift-test-case.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,128 @@ +From c30e34faa12e4b6e190edcccd4b2db185a286680 Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Tue, 19 Dec 2017 19:49:33 +0100 +Subject: [PATCH] ZTS: Fix create-o_ashift test case +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +The function that fills the uberblock ring buffer on every device label +has been reworked to avoid occasional failures caused by a race +condition that prevents 'zpool sync' from writing some uberblock +sequentially: this happens when the pool sync ioctl dispatch code calls +txg_wait_synced() while we're already waiting for a TXG to sync. + +Reviewed-by: Brian Behlendorf +Signed-off-by: loli10K +Closes #6924 +Closes #6977 +--- + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -2716,10 +2716,6 @@ dump_label(const char *dev) + exit(1); + } + +- if (ioctl(fd, BLKFLSBUF) != 0) +- (void) printf("failed to invalidate cache '%s' : %s\n", path, +- strerror(errno)); +- + if (fstat64_blk(fd, &statbuf) != 0) { + (void) printf("failed to stat '%s': %s\n", path, + strerror(errno)); +@@ -2727,6 +2723,10 @@ dump_label(const char *dev) + exit(1); + } + ++ if (S_ISBLK(statbuf.st_mode) && ioctl(fd, BLKFLSBUF) != 0) ++ (void) printf("failed to invalidate cache '%s' : %s\n", path, ++ strerror(errno)); ++ + avl_create(&config_tree, cksum_record_compare, + sizeof (cksum_record_t), offsetof(cksum_record_t, link)); + avl_create(&uberblock_tree, cksum_record_compare, +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh +@@ -44,47 +44,45 @@ verify_runnable "global" + + function cleanup + { +- poolexists $TESTPOOL && destroy_pool $TESTPOOL ++ destroy_pool $TESTPOOL + log_must rm -f $disk + } + + # +-# Commit the specified number of TXGs to the provided pool +-# We use 'zpool sync' here because we can't force it via sync(1) like on illumos +-# $1 pool name +-# $2 number of txg syncs ++# Fill the uberblock ring in every label: we do this by committing ++# TXGs to the provided until every slot contains a valid uberblock. ++# NOTE: We use 'zpool sync' here because we can't force it via sync(1) like on ++# illumos + # +-function txg_sync ++function write_device_uberblocks # + { +- typeset pool=$1 +- typeset -i count=$2 +- typeset -i i=0; ++ typeset device=$1 ++ typeset pool=$2 + +- while [ $i -lt $count ] ++ while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ] + do +- log_must sync_pool $pool true +- ((i = i + 1)) ++ sync_pool $pool true + done + } + + # +-# Verify device $1 labels contains $2 valid uberblocks in every label +-# $1 device +-# $2 uberblocks count ++# Verify every label on contains (valid) uberblocks + # +-function verify_device_uberblocks ++function verify_device_uberblocks # + { + typeset device=$1 + typeset ubcount=$2 + + zdb -quuul $device | egrep '^(\s+)?Uberblock' | +- egrep -v 'invalid$' | awk \ +- -v ubcount=$ubcount '{ uberblocks[$0]++; } +- END { for (i in uberblocks) { +- count++; +- if (uberblocks[i] != 4) { exit 1; } +- } +- if (count != ubcount) { exit 1; } }' ++ awk -v ubcount=$ubcount 'BEGIN { count=0 } { uberblocks[$0]++; } ++ END { ++ for (i in uberblocks) { ++ if (i ~ /invalid/) { continue; } ++ if (uberblocks[i] != 4) { exit 1; } ++ count++; ++ } ++ if (count != ubcount) { exit 1; } ++ }' + + return $? + } +@@ -110,8 +108,7 @@ do + log_fail "Pool was created without setting ashift value to "\ + "$ashift (current = $pprop)" + fi +- # force 128 txg sync to fill the uberblock ring +- txg_sync $TESTPOOL 128 ++ write_device_uberblocks $disk $TESTPOOL + verify_device_uberblocks $disk ${ubcount[$i]} + if [[ $? -ne 0 ]] + then diff -Nru zfs-linux-0.7.5/debian/patches/2325-Handle-invalid-options-in-arc_summary.patch zfs-linux-0.7.5/debian/patches/2325-Handle-invalid-options-in-arc_summary.patch --- zfs-linux-0.7.5/debian/patches/2325-Handle-invalid-options-in-arc_summary.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2325-Handle-invalid-options-in-arc_summary.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,130 @@ +From c4ba46deade0a14d089228a56a5d0aa0ffd5fadd Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Tue, 19 Dec 2017 22:02:40 +0100 +Subject: [PATCH] Handle invalid options in arc_summary +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +If an invalid option is provided to arc_summary.py we handle any error +thrown from the getopt Python module and print the usage help message. + +Reviewed-by: George Melikov +Reviewed-by: Giuseppe Di Natale +Reviewed-by: Brian Behlendorf +Signed-off-by: loli10K +Closes #6983 +--- + cmd/arc_summary/arc_summary.py | 16 +++++--- + tests/runfiles/linux.run | 2 +- + .../functional/cli_user/misc/Makefile.am | 1 + + .../cli_user/misc/arc_summary_002_neg.ksh | 38 +++++++++++++++++++ + 4 files changed, 51 insertions(+), 6 deletions(-) + create mode 100755 tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh + +Index: zfs-linux-0.7.5/cmd/arc_summary/arc_summary.py +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/arc_summary/arc_summary.py ++++ zfs-linux-0.7.5/cmd/arc_summary/arc_summary.py +@@ -942,9 +942,15 @@ def main(): + global show_tunable_descriptions + global alternate_tunable_layout + +- opts, args = getopt.getopt( +- sys.argv[1:], "adp:h", ["alternate", "description", "page=", "help"] +- ) ++ try: ++ opts, args = getopt.getopt( ++ sys.argv[1:], ++ "adp:h", ["alternate", "description", "page=", "help"] ++ ) ++ except getopt.error as e: ++ sys.stderr.write("Error: %s\n" % e.msg) ++ usage() ++ sys.exit(1) + + args = {} + for opt, arg in opts: +@@ -956,7 +962,7 @@ def main(): + args['p'] = arg + if opt in ('-h', '--help'): + usage() +- sys.exit() ++ sys.exit(0) + + Kstat = get_Kstat() + +@@ -971,7 +977,7 @@ def main(): + except IndexError: + sys.stderr.write('the argument to -p must be between 1 and ' + + str(len(unSub)) + '\n') +- sys.exit() ++ sys.exit(1) + else: + pages = unSub + +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -366,7 +366,7 @@ tests = ['zdb_001_neg', 'zfs_001_neg', ' + 'zpool_offline_001_neg', 'zpool_online_001_neg', 'zpool_remove_001_neg', + 'zpool_replace_001_neg', 'zpool_scrub_001_neg', 'zpool_set_001_neg', + 'zpool_status_001_neg', 'zpool_upgrade_001_neg', 'arcstat_001_pos', +- 'arc_summary_001_pos', 'dbufstat_001_pos'] ++ 'arc_summary_001_pos', 'arc_summary_002_neg', 'dbufstat_001_pos'] + user = + tags = ['functional', 'cli_user', 'misc'] + +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am +@@ -46,4 +46,5 @@ dist_pkgdata_SCRIPTS = \ + zpool_upgrade_001_neg.ksh \ + arcstat_001_pos.ksh \ + arc_summary_001_pos.ksh \ ++ arc_summary_002_neg.ksh \ + dbufstat_001_pos.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh +@@ -0,0 +1,38 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++# ++# Copyright (c) 2015 by Lawrence Livermore National Security, LLC. ++# All rights reserved. ++# ++ ++. $STF_SUITE/include/libtest.shlib ++ ++typeset args=("-x" "-r" "-5" "-p 7" "--err" "-@") ++ ++log_assert "arc_summary.py generates an error code with invalid options" ++ ++for arg in "${args[@]}"; do ++ log_mustnot eval "arc_summary.py $arg > /dev/null" ++done ++ ++log_pass "arc_summary.py generates an error code with invalid options" diff -Nru zfs-linux-0.7.5/debian/patches/2326-Call-commit-callbacks-from-the-tail-of-the-list.patch zfs-linux-0.7.5/debian/patches/2326-Call-commit-callbacks-from-the-tail-of-the-list.patch --- zfs-linux-0.7.5/debian/patches/2326-Call-commit-callbacks-from-the-tail-of-the-list.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2326-Call-commit-callbacks-from-the-tail-of-the-list.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,80 @@ +From 823d48bfb182137c53b9432498f1f0564eaa8bfc Mon Sep 17 00:00:00 2001 +From: lidongyang +Date: Sat, 23 Dec 2017 05:19:51 +1100 +Subject: [PATCH] Call commit callbacks from the tail of the list +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Our zfs backed Lustre MDT had soft lockups while under heavy metadata +workloads while handling transaction callbacks from osd_zfs. + +The problem is zfs is not taking advantage of the fast path in +Lustre's trans callback handling, where Lustre will skip the calls +to ptlrpc_commit_replies() when it already saw a higher transaction +number. + +This patch corrects this, it also has a positive impact on metadata +performance on Lustre with osd_zfs, plus some cleanup in the headers. + +A similar issue for ext4/ldiskfs is described on: +https://jira.hpdd.intel.com/browse/LU-6527 + +Reviewed-by: Olaf Faaland +Reviewed-by: Brian Behlendorf +Signed-off-by: Li Dongyang +Closes #6986 +--- + include/sys/dmu.h | 5 +++++ + include/sys/dmu_tx.h | 4 ---- + module/zfs/dmu_tx.c | 2 +- + 3 files changed, 6 insertions(+), 5 deletions(-) + +Index: zfs-linux-0.7.5/include/sys/dmu.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/sys/dmu.h ++++ zfs-linux-0.7.5/include/sys/dmu.h +@@ -713,11 +713,16 @@ void dmu_tx_mark_netfree(dmu_tx_t *tx); + * to stable storage and will also be called if the dmu_tx is aborted. + * If there is any error which prevents the transaction from being committed to + * disk, the callback will be called with a value of error != 0. ++ * ++ * When multiple callbacks are registered to the transaction, the callbacks ++ * will be called in reverse order to let Lustre, the only user of commit ++ * callback currently, take the fast path of its commit callback handling. + */ + typedef void dmu_tx_callback_func_t(void *dcb_data, int error); + + void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *dcb_func, + void *dcb_data); ++void dmu_tx_do_callbacks(list_t *cb_list, int error); + + /* + * Free up the data blocks for a defined range of a file. If size is +Index: zfs-linux-0.7.5/include/sys/dmu_tx.h +=================================================================== +--- zfs-linux-0.7.5.orig/include/sys/dmu_tx.h ++++ zfs-linux-0.7.5/include/sys/dmu_tx.h +@@ -145,10 +145,6 @@ uint64_t dmu_tx_get_txg(dmu_tx_t *tx); + struct dsl_pool *dmu_tx_pool(dmu_tx_t *tx); + void dmu_tx_wait(dmu_tx_t *tx); + +-void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *dcb_func, +- void *dcb_data); +-void dmu_tx_do_callbacks(list_t *cb_list, int error); +- + /* + * These routines are defined in dmu_spa.h, and are called by the SPA. + */ +Index: zfs-linux-0.7.5/module/zfs/dmu_tx.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dmu_tx.c ++++ zfs-linux-0.7.5/module/zfs/dmu_tx.c +@@ -1200,7 +1200,7 @@ dmu_tx_do_callbacks(list_t *cb_list, int + { + dmu_tx_callback_t *dcb; + +- while ((dcb = list_head(cb_list)) != NULL) { ++ while ((dcb = list_tail(cb_list)) != NULL) { + list_remove(cb_list, dcb); + dcb->dcb_func(dcb->dcb_data, error); + kmem_free(dcb, sizeof (dmu_tx_callback_t)); diff -Nru zfs-linux-0.7.5/debian/patches/2327-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch zfs-linux-0.7.5/debian/patches/2327-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch --- zfs-linux-0.7.5/debian/patches/2327-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2327-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,198 @@ +From 390d679acdfa6a2498280a4dcd33b7600ace27ce Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Thu, 28 Dec 2017 19:15:32 +0100 +Subject: [PATCH] Fix 'zpool add' handling of nested interior VDEVs +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +When replacing a faulted device which was previously handled by a spare +multiple levels of nested interior VDEVs will be present in the pool +configuration; the following example illustrates one of the possible +situations: + + NAME STATE READ WRITE CKSUM + testpool DEGRADED 0 0 0 + raidz1-0 DEGRADED 0 0 0 + spare-0 DEGRADED 0 0 0 + replacing-0 DEGRADED 0 0 0 + /var/tmp/fault-dev UNAVAIL 0 0 0 cannot open + /var/tmp/replace-dev ONLINE 0 0 0 + /var/tmp/spare-dev1 ONLINE 0 0 0 + /var/tmp/safe-dev ONLINE 0 0 0 + spares + /var/tmp/spare-dev1 INUSE currently in use + +This is safe and allowed, but get_replication() needs to handle this +situation gracefully to let zpool add new devices to the pool. + +Reviewed-by: George Melikov +Reviewed-by: Brian Behlendorf +Signed-off-by: loli10K +Closes #6678 +Closes #6996 +--- + cmd/zpool/zpool_vdev.c | 6 +- + tests/runfiles/linux.run | 2 +- + .../functional/cli_root/zpool_add/Makefile.am | 3 +- + .../zpool_add/add_nested_replacing_spare.ksh | 111 ++++++++++++++++++ + 4 files changed, 118 insertions(+), 4 deletions(-) + create mode 100755 tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh + +Index: zfs-linux-0.7.5/cmd/zpool/zpool_vdev.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zpool/zpool_vdev.c ++++ zfs-linux-0.7.5/cmd/zpool/zpool_vdev.c +@@ -861,9 +861,11 @@ get_replication(nvlist_t *nvroot, boolea + + /* + * If this is a replacing or spare vdev, then +- * get the real first child of the vdev. ++ * get the real first child of the vdev: do this ++ * in a loop because replacing and spare vdevs ++ * can be nested. + */ +- if (strcmp(childtype, ++ while (strcmp(childtype, + VDEV_TYPE_REPLACING) == 0 || + strcmp(childtype, VDEV_TYPE_SPARE) == 0) { + nvlist_t **rchild; +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -228,7 +228,7 @@ tests = ['zpool_add_001_pos', 'zpool_add + 'zpool_add_004_pos', 'zpool_add_005_pos', 'zpool_add_006_pos', + 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg', + 'zpool_add_010_pos', +- 'add-o_ashift', 'add_prop_ashift'] ++ 'add-o_ashift', 'add_prop_ashift', 'add_nested_replacing_spare'] + tags = ['functional', 'cli_root', 'zpool_add'] + + [tests/functional/cli_root/zpool_attach] +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am +@@ -15,4 +15,5 @@ dist_pkgdata_SCRIPTS = \ + zpool_add_009_neg.ksh \ + zpool_add_010_pos.ksh \ + add-o_ashift.ksh \ +- add_prop_ashift.ksh ++ add_prop_ashift.ksh \ ++ add_nested_replacing_spare.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh +@@ -0,0 +1,111 @@ ++#!/bin/ksh -p ++# ++# CDDL HEADER START ++# ++# The contents of this file are subject to the terms of the ++# Common Development and Distribution License (the "License"). ++# You may not use this file except in compliance with the License. ++# ++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE ++# or http://www.opensolaris.org/os/licensing. ++# See the License for the specific language governing permissions ++# and limitations under the License. ++# ++# When distributing Covered Code, include this CDDL HEADER in each ++# file and include the License file at usr/src/OPENSOLARIS.LICENSE. ++# If applicable, add the following below this CDDL HEADER, with the ++# fields enclosed by brackets "[]" replaced with your own identifying ++# information: Portions Copyright [yyyy] [name of copyright owner] ++# ++# CDDL HEADER END ++# ++ ++# ++# Copyright 2017, loli10K . All rights reserved. ++# ++ ++. $STF_SUITE/include/libtest.shlib ++. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib ++ ++# ++# DESCRIPTION: ++# 'zpool add' works with nested replacing/spare vdevs ++# ++# STRATEGY: ++# 1. Create a redundant pool with a spare device ++# 2. Manually fault a device, wait for the hot-spare and then replace it: ++# this creates a situation where replacing and spare vdevs are nested. ++# 3. Verify 'zpool add' is able to add new devices to the pool. ++# ++ ++verify_runnable "global" ++ ++function cleanup ++{ ++ zed_stop ++ zed_cleanup ++ log_must zinject -c all ++ destroy_pool $TESTPOOL ++ log_must rm -f $DATA_DEVS $SPARE_DEVS ++} ++ ++log_assert "'zpool add' works with nested replacing/spare vdevs" ++log_onexit cleanup ++ ++FAULT_DEV="$TEST_BASE_DIR/fault-dev" ++SAFE_DEV1="$TEST_BASE_DIR/safe-dev1" ++SAFE_DEV2="$TEST_BASE_DIR/safe-dev2" ++SAFE_DEV3="$TEST_BASE_DIR/safe-dev3" ++SAFE_DEVS="$SAFE_DEV1 $SAFE_DEV2 $SAFE_DEV3" ++REPLACE_DEV="$TEST_BASE_DIR/replace-dev" ++ADD_DEV="$TEST_BASE_DIR/add-dev" ++DATA_DEVS="$FAULT_DEV $SAFE_DEVS $REPLACE_DEV $ADD_DEV" ++SPARE_DEV1="$TEST_BASE_DIR/spare-dev1" ++SPARE_DEV2="$TEST_BASE_DIR/spare-dev2" ++SPARE_DEVS="$SPARE_DEV1 $SPARE_DEV2" ++ ++# We need ZED running to work with spares ++zed_setup ++zed_start ++# Clear events from previous runs ++zed_events_drain ++ ++for type in "mirror" "raidz1" "raidz2" "raidz3" ++do ++ # 1. Create a redundant pool with a spare device ++ truncate -s $SPA_MINDEVSIZE $DATA_DEVS $SPARE_DEVS ++ log_must zpool create $TESTPOOL $type $FAULT_DEV $SAFE_DEVS ++ log_must zpool add $TESTPOOL spare $SPARE_DEV1 ++ ++ # 2.1 Fault a device, verify the spare is kicked in ++ log_must zinject -d $FAULT_DEV -e nxio -T all -f 100 $TESTPOOL ++ log_must zpool scrub $TESTPOOL ++ log_must wait_vdev_state $TESTPOOL $FAULT_DEV "UNAVAIL" 60 ++ log_must wait_vdev_state $TESTPOOL $SPARE_DEV1 "ONLINE" 60 ++ log_must wait_hotspare_state $TESTPOOL $SPARE_DEV1 "INUSE" ++ log_must check_state $TESTPOOL "" "DEGRADED" ++ ++ # 2.2 Replace the faulted device: this creates a replacing vdev inside a ++ # spare vdev ++ log_must zpool replace $TESTPOOL $FAULT_DEV $REPLACE_DEV ++ log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60 ++ zpool status | awk -v poolname="$TESTPOOL" -v type="$type" 'BEGIN {s=""} ++ $1 ~ poolname {c=4}; (c && c--) { s=s$1":" } ++ END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' ++ if [[ $? -ne 0 ]]; then ++ log_fail "Pool does not contain nested replacing/spare vdevs" ++ fi ++ ++ # 3. Verify 'zpool add' is able to add new devices ++ log_must zpool add $TESTPOOL spare $SPARE_DEV2 ++ log_must wait_hotspare_state $TESTPOOL $SPARE_DEV2 "AVAIL" ++ log_must zpool add -f $TESTPOOL $ADD_DEV ++ log_must wait_vdev_state $TESTPOOL $ADD_DEV "ONLINE" 60 ++ ++ # Cleanup ++ log_must zinject -c all ++ destroy_pool $TESTPOOL ++ log_must rm -f $DATA_DEVS $SPARE_DEVS ++done ++ ++log_pass "'zpool add' works with nested replacing/spare vdevs" diff -Nru zfs-linux-0.7.5/debian/patches/2328-Fix-fsanitize-address-memory-leak.patch zfs-linux-0.7.5/debian/patches/2328-Fix-fsanitize-address-memory-leak.patch --- zfs-linux-0.7.5/debian/patches/2328-Fix-fsanitize-address-memory-leak.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2328-Fix-fsanitize-address-memory-leak.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,40 @@ +From 460f239e6999195dbcf9b8443c029f07765b21e9 Mon Sep 17 00:00:00 2001 +From: DHE +Date: Sat, 18 Nov 2017 18:21:09 -0500 +Subject: [PATCH] Fix -fsanitize=address memory leak +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +kmem_alloc(0, ...) in userspace returns a leakable pointer. + +Reviewed-by: Brian Behlendorf +Signed-off-by: DHE +Issue #6941 +--- + module/zfs/spa.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/spa.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/spa.c ++++ zfs-linux-0.7.5/module/zfs/spa.c +@@ -1561,7 +1561,7 @@ spa_load_spares(spa_t *spa) + static void + spa_load_l2cache(spa_t *spa) + { +- nvlist_t **l2cache; ++ nvlist_t **l2cache = NULL; + uint_t nl2cache; + int i, j, oldnvdevs; + uint64_t guid; +@@ -1645,7 +1645,9 @@ spa_load_l2cache(spa_t *spa) + VERIFY(nvlist_remove(sav->sav_config, ZPOOL_CONFIG_L2CACHE, + DATA_TYPE_NVLIST_ARRAY) == 0); + +- l2cache = kmem_alloc(sav->sav_count * sizeof (void *), KM_SLEEP); ++ if (sav->sav_count > 0) ++ l2cache = kmem_alloc(sav->sav_count * sizeof (void *), ++ KM_SLEEP); + for (i = 0; i < sav->sav_count; i++) + l2cache[i] = vdev_config_generate(spa, + sav->sav_vdevs[i], B_TRUE, VDEV_CONFIG_L2CACHE); diff -Nru zfs-linux-0.7.5/debian/patches/2329-Revert-raidz_map-and-_col-structure-types.patch zfs-linux-0.7.5/debian/patches/2329-Revert-raidz_map-and-_col-structure-types.patch --- zfs-linux-0.7.5/debian/patches/2329-Revert-raidz_map-and-_col-structure-types.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2329-Revert-raidz_map-and-_col-structure-types.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,80 @@ +From cba6fc61a2898395c47380a0c2303f19842a2ff0 Mon Sep 17 00:00:00 2001 +From: Nathaniel Wesley Filardo + +Date: Tue, 9 Jan 2018 17:46:52 -0500 +Subject: [PATCH] Revert raidz_map and _col structure types +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +As part of the refactoring of ab9f4b0b824ab4cc64a4fa382c037f4154de12d6, +several uint64_t-s and uint8_t-s were changed to other types. This +caused ZoL github issue #6981, an overflow of a size_t on a 32-bit ARM +machine. In absense of any strong motivation for the type changes, this +simply puts them back, modulo the changes accumulated for ABD. + +Compile-tested on amd64 and run-tested on armhf. + +Reviewed-by: Brian Behlendorf +Reviewed-by: Gvozden Neskovic +Signed-off-by: Nathaniel Wesley Filardo +Closes #6981 +Closes #7023 +--- + include/sys/vdev_raidz_impl.h | 34 +++++++++++++++++----------------- + 1 file changed, 17 insertions(+), 17 deletions(-) + +diff --git a/include/sys/vdev_raidz_impl.h b/include/sys/vdev_raidz_impl.h +index 4bd15e3d5..0799ed19d 100644 +--- a/include/sys/vdev_raidz_impl.h ++++ b/include/sys/vdev_raidz_impl.h +@@ -102,30 +102,30 @@ typedef struct raidz_impl_ops { + } raidz_impl_ops_t; + + typedef struct raidz_col { +- size_t rc_devidx; /* child device index for I/O */ +- size_t rc_offset; /* device offset */ +- size_t rc_size; /* I/O size */ ++ uint64_t rc_devidx; /* child device index for I/O */ ++ uint64_t rc_offset; /* device offset */ ++ uint64_t rc_size; /* I/O size */ + abd_t *rc_abd; /* I/O data */ + void *rc_gdata; /* used to store the "good" version */ + int rc_error; /* I/O error for this device */ +- unsigned int rc_tried; /* Did we attempt this I/O column? */ +- unsigned int rc_skipped; /* Did we skip this I/O column? */ ++ uint8_t rc_tried; /* Did we attempt this I/O column? */ ++ uint8_t rc_skipped; /* Did we skip this I/O column? */ + } raidz_col_t; + + typedef struct raidz_map { +- size_t rm_cols; /* Regular column count */ +- size_t rm_scols; /* Count including skipped columns */ +- size_t rm_bigcols; /* Number of oversized columns */ +- size_t rm_asize; /* Actual total I/O size */ +- size_t rm_missingdata; /* Count of missing data devices */ +- size_t rm_missingparity; /* Count of missing parity devices */ +- size_t rm_firstdatacol; /* First data column/parity count */ +- size_t rm_nskip; /* Skipped sectors for padding */ +- size_t rm_skipstart; /* Column index of padding start */ ++ uint64_t rm_cols; /* Regular column count */ ++ uint64_t rm_scols; /* Count including skipped columns */ ++ uint64_t rm_bigcols; /* Number of oversized columns */ ++ uint64_t rm_asize; /* Actual total I/O size */ ++ uint64_t rm_missingdata; /* Count of missing data devices */ ++ uint64_t rm_missingparity; /* Count of missing parity devices */ ++ uint64_t rm_firstdatacol; /* First data column/parity count */ ++ uint64_t rm_nskip; /* Skipped sectors for padding */ ++ uint64_t rm_skipstart; /* Column index of padding start */ + abd_t *rm_abd_copy; /* rm_asize-buffer of copied data */ +- size_t rm_reports; /* # of referencing checksum reports */ +- unsigned int rm_freed; /* map no longer has referencing ZIO */ +- unsigned int rm_ecksuminjected; /* checksum error was injected */ ++ uintptr_t rm_reports; /* # of referencing checksum reports */ ++ uint8_t rm_freed; /* map no longer has referencing ZIO */ ++ uint8_t rm_ecksuminjected; /* checksum error was injected */ + raidz_impl_ops_t *rm_ops; /* RAIDZ math operations */ + raidz_col_t rm_col[1]; /* Flexible array of I/O columns */ + } raidz_map_t; +-- +2.17.0 + diff -Nru zfs-linux-0.7.5/debian/patches/2330-Use-zap_count-instead-of-cached-z_size-for-unlink.patch zfs-linux-0.7.5/debian/patches/2330-Use-zap_count-instead-of-cached-z_size-for-unlink.patch --- zfs-linux-0.7.5/debian/patches/2330-Use-zap_count-instead-of-cached-z_size-for-unlink.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2330-Use-zap_count-instead-of-cached-z_size-for-unlink.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,60 @@ +From 3910184d9ecf187f5f229798bab688d754fa1e30 Mon Sep 17 00:00:00 2001 +From: Alex Zhuravlev +Date: Mon, 8 Jan 2018 10:57:47 -0800 +Subject: [PATCH] Use zap_count instead of cached z_size for unlink +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +As a performance optimization Lustre does not strictly update +the SA_ZPL_SIZE when adding/removing from non-directory entries. +This results in entries which cannot be removed through the ZPL +layer even though the ZAP is empty and safe to remove. + +Resolve this issue by checking the zap_count() directly instead +on relying on the cached SA_ZPL_SIZE. Micro-benchmarks show no +significant performance impact due to the additional overhead +of using zap_count(). + +Reviewed-by: Olaf Faaland +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Alex Zhuravlev +Signed-off-by: Brian Behlendorf +Closes #7019 +--- + module/zfs/zfs_dir.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/module/zfs/zfs_dir.c b/module/zfs/zfs_dir.c +index c6ee30291..9a8bbccd9 100644 +--- a/module/zfs/zfs_dir.c ++++ b/module/zfs/zfs_dir.c +@@ -977,11 +977,25 @@ zfs_link_destroy(zfs_dirlock_t *dl, znode_t *zp, dmu_tx_t *tx, int flag, + * Indicate whether the directory is empty. Works with or without z_lock + * held, but can only be consider a hint in the latter case. Returns true + * if only "." and ".." remain and there's no work in progress. ++ * ++ * The internal ZAP size, rather than zp->z_size, needs to be checked since ++ * some consumers (Lustre) do not strictly maintain an accurate SA_ZPL_SIZE. + */ + boolean_t + zfs_dirempty(znode_t *dzp) + { +- return (dzp->z_size == 2 && dzp->z_dirlocks == 0); ++ zfsvfs_t *zfsvfs = ZTOZSB(dzp); ++ uint64_t count; ++ int error; ++ ++ if (dzp->z_dirlocks != NULL) ++ return (B_FALSE); ++ ++ error = zap_count(zfsvfs->z_os, dzp->z_id, &count); ++ if (error != 0 || count != 0) ++ return (B_FALSE); ++ ++ return (B_TRUE); + } + + int +-- +2.17.0 + diff -Nru zfs-linux-0.7.5/debian/patches/2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch zfs-linux-0.7.5/debian/patches/2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch --- zfs-linux-0.7.5/debian/patches/2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch 2018-04-16 10:36:20.000000000 +0000 @@ -0,0 +1,46 @@ +From 8198c57b21d5e503f7e72221aa714aaabb2079cc Mon Sep 17 00:00:00 2001 +From: Yuri Pankov +Date: Mon, 11 Dec 2017 10:11:25 +0300 +Subject: [PATCH] OpenZFS 8897 - zpool online -e fails assertion when run on + non-leaf vdevs +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Yuri Pankov +Reviewed by: Toomas Soome +Reviewed by: Igor Kozhukhov +Reviewed-by: George Melikov +Approved by: Dan McDonald +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8897 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/9a551dd645 +Closes #7030 +--- + lib/libzfs/libzfs_pool.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/lib/libzfs/libzfs_pool.c +=================================================================== +--- zfs-linux-0.7.5.orig/lib/libzfs/libzfs_pool.c ++++ zfs-linux-0.7.5/lib/libzfs/libzfs_pool.c +@@ -2488,6 +2488,7 @@ zpool_vdev_online(zpool_handle_t *zhp, c + { + zfs_cmd_t zc = {"\0"}; + char msg[1024]; ++ char *pathname; + nvlist_t *tgt; + boolean_t avail_spare, l2cache, islog; + libzfs_handle_t *hdl = zhp->zpool_hdl; +@@ -2511,8 +2512,9 @@ zpool_vdev_online(zpool_handle_t *zhp, c + if (avail_spare) + return (zfs_error(hdl, EZFS_ISSPARE, msg)); + +- if (flags & ZFS_ONLINE_EXPAND || +- zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) { ++ if ((flags & ZFS_ONLINE_EXPAND || ++ zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) && ++ nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH, &pathname) == 0) { + uint64_t wholedisk = 0; + + (void) nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_WHOLE_DISK, diff -Nru zfs-linux-0.7.5/debian/patches/2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch zfs-linux-0.7.5/debian/patches/2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch --- zfs-linux-0.7.5/debian/patches/2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch 2018-04-16 10:40:50.000000000 +0000 @@ -0,0 +1,69 @@ +From bcb1a8a25e4ee9a94478378710de53b45a9b1517 Mon Sep 17 00:00:00 2001 +From: Yuri Pankov +Date: Wed, 6 Dec 2017 08:19:31 +0300 +Subject: [PATCH] OpenZFS 8898 - creating fs with checksum=skein on the boot + pools fails ungracefully +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Yuri Pankov +Reviewed by: Toomas Soome +Reviewed by: Andy Stormont +Reviewed-by: George Melikov +Approved by: Dan McDonald +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8898 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/9fa2266d9a +Closes #7031 +--- + +Index: zfs-linux-0.7.5/lib/libzfs/libzfs_dataset.c +=================================================================== +--- zfs-linux-0.7.5.orig/lib/libzfs/libzfs_dataset.c ++++ zfs-linux-0.7.5/lib/libzfs/libzfs_dataset.c +@@ -27,7 +27,7 @@ + * Copyright (c) 2012 Pawel Jakub Dawidek . + * Copyright (c) 2013 Martin Matuska. All rights reserved. + * Copyright (c) 2013 Steven Hartland. All rights reserved. +- * Copyright 2016 Nexenta Systems, Inc. ++ * Copyright 2017 Nexenta Systems, Inc. + * Copyright 2016 Igor Kozhukhov + * Copyright 2017 RackTop Systems. + */ +@@ -3497,6 +3497,11 @@ zfs_create(libzfs_handle_t *hdl, const c + "pool must be upgraded to set this " + "property or value")); + return (zfs_error(hdl, EZFS_BADVERSION, errbuf)); ++ ++ case ERANGE: ++ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, ++ "invalid property value(s) specified")); ++ return (zfs_error(hdl, EZFS_BADPROP, errbuf)); + #ifdef _ILP32 + case EOVERFLOW: + /* +Index: zfs-linux-0.7.5/man/man8/zfs.8 +=================================================================== +--- zfs-linux-0.7.5.orig/man/man8/zfs.8 ++++ zfs-linux-0.7.5/man/man8/zfs.8 +@@ -29,7 +29,7 @@ + .\" Copyright 2016 Nexenta Systems, Inc. + .\" Copyright 2016 Richard Laager. All rights reserved. + .\" +-.Dd June 28, 2017 ++.Dd January 10, 2018 + .Dt ZFS 8 SMM + .Os Linux + .Sh NAME +@@ -1054,6 +1054,10 @@ Please see + for more information on these algorithms. + .Pp + Changing this property affects only newly-written data. +++.Pp +++Salted checksum algorithms +++.Pq Cm edonr , skein +++are currently not supported for any filesystem on the boot pools. + .It Xo + .Sy compression Ns = Ns Sy on Ns | Ns Sy off Ns | Ns Sy gzip Ns | Ns + .Sy gzip- Ns Em N Ns | Ns Sy lz4 Ns | Ns Sy lzjb Ns | Ns Sy zle diff -Nru zfs-linux-0.7.5/debian/patches/2333-Emit-an-error-message-before-MMP-suspends-pool.patch zfs-linux-0.7.5/debian/patches/2333-Emit-an-error-message-before-MMP-suspends-pool.patch --- zfs-linux-0.7.5/debian/patches/2333-Emit-an-error-message-before-MMP-suspends-pool.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2333-Emit-an-error-message-before-MMP-suspends-pool.patch 2018-04-16 10:44:18.000000000 +0000 @@ -0,0 +1,43 @@ +From 51d1b58ef3467c3a9711c65458f93063dd17354f Mon Sep 17 00:00:00 2001 +From: "John L. Hammond" <35266395+jhammond-intel@users.noreply.github.com> +Date: Wed, 17 Jan 2018 14:24:42 -0600 +Subject: [PATCH] Emit an error message before MMP suspends pool +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +In mmp_thread(), emit an MMP specific error message before calling +zio_suspend() so that the administrator will understand why the pool +is being suspended. + +Reviewed-by: Olaf Faaland +Reviewed-by: Giuseppe Di Natale +Reviewed-by: Brian Behlendorf +Signed-off-by: John L. Hammond +Closes #7048 +--- + module/zfs/mmp.c | 5 +++++ + 1 file changed, 5 insertions(+) + +Index: zfs-linux-0.7.5/module/zfs/mmp.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/mmp.c ++++ zfs-linux-0.7.5/module/zfs/mmp.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -428,6 +429,10 @@ mmp_thread(spa_t *spa) + */ + if (!suspended && mmp_fail_intervals && multihost && + (start - mmp->mmp_last_write) > max_fail_ns) { ++ cmn_err(CE_WARN, "MMP writes to pool '%s' have not " ++ "succeeded in over %llus; suspending pool", ++ spa_name(spa), ++ NSEC2SEC(start - mmp->mmp_last_write)); + zio_suspend(spa, NULL); + } + diff -Nru zfs-linux-0.7.5/debian/patches/2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch zfs-linux-0.7.5/debian/patches/2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch --- zfs-linux-0.7.5/debian/patches/2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch 2018-04-16 10:47:30.000000000 +0000 @@ -0,0 +1,65 @@ +From 1574c73bd0680cf3141e26627191120daba3fe8d Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf +Date: Fri, 19 Jan 2018 09:20:58 -0800 +Subject: [PATCH] OpenZFS 8641 - "zpool clear" and "zinject" don't work on + "spare" or "replacing" vdevs +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Add "spare" and "replacing" to the list of interior vdev types in +zpool_vdev_is_interior(), alongside the existing "mirror" and "raidz". +This fixes running "zinject -d" and "zpool clear" on spare and replacing +vdevs. + +Authored by: Alan Somers +Reviewed by: Matthew Ahrens +Reviewed by: George Melikov +Approved by: Gordon Ross +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8641 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/9a36801382 +Closes #7060 +--- + lib/libzfs/libzfs_pool.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +Index: zfs-linux-0.7.5/lib/libzfs/libzfs_pool.c +=================================================================== +--- zfs-linux-0.7.5.orig/lib/libzfs/libzfs_pool.c ++++ zfs-linux-0.7.5/lib/libzfs/libzfs_pool.c +@@ -51,6 +51,7 @@ + #include "zfeature_common.h" + + static int read_efi_label(nvlist_t *config, diskaddr_t *sb); ++static boolean_t zpool_vdev_is_interior(const char *name); + + typedef struct prop_flags { + int create:1; /* Validate property on creation */ +@@ -2103,10 +2104,7 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist + break; + } + +- verify(strncmp(type, VDEV_TYPE_RAIDZ, +- strlen(VDEV_TYPE_RAIDZ)) == 0 || +- strncmp(type, VDEV_TYPE_MIRROR, +- strlen(VDEV_TYPE_MIRROR)) == 0); ++ verify(zpool_vdev_is_interior(type)); + verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID, + &id) == 0); + +@@ -2213,10 +2211,13 @@ zpool_find_vdev_by_physpath(zpool_handle + /* + * Determine if we have an "interior" top-level vdev (i.e mirror/raidz). + */ +-boolean_t ++static boolean_t + zpool_vdev_is_interior(const char *name) + { + if (strncmp(name, VDEV_TYPE_RAIDZ, strlen(VDEV_TYPE_RAIDZ)) == 0 || ++ strncmp(name, VDEV_TYPE_SPARE, strlen(VDEV_TYPE_SPARE)) == 0 || ++ strncmp(name, ++ VDEV_TYPE_REPLACING, strlen(VDEV_TYPE_REPLACING)) == 0 || + strncmp(name, VDEV_TYPE_MIRROR, strlen(VDEV_TYPE_MIRROR)) == 0) + return (B_TRUE); + return (B_FALSE); diff -Nru zfs-linux-0.7.5/debian/patches/2335-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch zfs-linux-0.7.5/debian/patches/2335-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch --- zfs-linux-0.7.5/debian/patches/2335-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2335-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch 2018-04-16 10:49:54.000000000 +0000 @@ -0,0 +1,79 @@ +From 916384729e5d828e578c8f5c3003742360fb89ea Mon Sep 17 00:00:00 2001 +From: Alexander Motin +Date: Mon, 20 Nov 2017 19:56:01 +0200 +Subject: [PATCH] OpenZFS 8835 - Speculative prefetch in ZFS not working for + misaligned reads +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +In case of misaligned I/O sequential requests are not detected as such +due to overlaps in logical block sequence: + + dmu_zfetch(fffff80198dd0ae0, 27347, 9, 1) + dmu_zfetch(fffff80198dd0ae0, 27355, 9, 1) + dmu_zfetch(fffff80198dd0ae0, 27363, 9, 1) + dmu_zfetch(fffff80198dd0ae0, 27371, 9, 1) + dmu_zfetch(fffff80198dd0ae0, 27379, 9, 1) + dmu_zfetch(fffff80198dd0ae0, 27387, 9, 1) + +This patch makes single block overlap to be counted as a stream hit, +improving performance up to several times. + +Authored by: Alexander Motin +Approved by: Gordon Ross +Reviewed by: Matthew Ahrens +Reviewed by: Allan Jude +Reviewed by: Gvozden Neskovic +Reviewed by: George Melikov +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8835 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aab6dd482a +Closes #7062 +--- + module/zfs/dmu_zfetch.c | 24 +++++++++++++++++++----- + 1 file changed, 19 insertions(+), 5 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/dmu_zfetch.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dmu_zfetch.c ++++ zfs-linux-0.7.5/module/zfs/dmu_zfetch.c +@@ -228,19 +228,33 @@ dmu_zfetch(zfetch_t *zf, uint64_t blkid, + + rw_enter(&zf->zf_rwlock, RW_READER); + ++ /* ++ * Find matching prefetch stream. Depending on whether the accesses ++ * are block-aligned, first block of the new access may either follow ++ * the last block of the previous access, or be equal to it. ++ */ + for (zs = list_head(&zf->zf_stream); zs != NULL; + zs = list_next(&zf->zf_stream, zs)) { +- if (blkid == zs->zs_blkid) { ++ if (blkid == zs->zs_blkid || blkid + 1 == zs->zs_blkid) { + mutex_enter(&zs->zs_lock); + /* + * zs_blkid could have changed before we + * acquired zs_lock; re-check them here. + */ +- if (blkid != zs->zs_blkid) { +- mutex_exit(&zs->zs_lock); +- continue; ++ if (blkid == zs->zs_blkid) { ++ break; ++ } else if (blkid + 1 == zs->zs_blkid) { ++ blkid++; ++ nblks--; ++ if (nblks == 0) { ++ /* Already prefetched this before. */ ++ mutex_exit(&zs->zs_lock); ++ rw_exit(&zf->zf_rwlock); ++ return; ++ } ++ break; + } +- break; ++ mutex_exit(&zs->zs_lock); + } + } + diff -Nru zfs-linux-0.7.5/debian/patches/2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch zfs-linux-0.7.5/debian/patches/2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch --- zfs-linux-0.7.5/debian/patches/2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch 2018-04-16 10:52:20.000000000 +0000 @@ -0,0 +1,50 @@ +From 6bc4a2376c694f813d2ee78af3d749aa2684f391 Mon Sep 17 00:00:00 2001 +From: Allan Jude +Date: Tue, 31 Oct 2017 21:41:46 -0400 +Subject: [PATCH] OpenZFS 8972 - zfs holds: In scripted mode, do not pad + columns with spaces +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Allan Jude +Approved by: Dan McDonald +Reviewed by: Matthew Ahrens +Reviewed by: George Melikov +Ported-by: Brian Behlendorf + +OpenZFS-issue: https://www.illumos.org/issues/8972 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3aace5c077 +Closes #7063 +--- + cmd/zfs/zfs_main.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zfs/zfs_main.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zfs/zfs_main.c ++++ zfs-linux-0.7.5/cmd/zfs/zfs_main.c +@@ -5720,8 +5720,6 @@ print_holds(boolean_t scripted, int nwid + uint64_t val = 0; + time_t time; + struct tm t; +- char sep = scripted ? '\t' : ' '; +- int sepnum = scripted ? 1 : 2; + + (void) nvpair_value_uint64(nvp2, &val); + time = (time_t)val; +@@ -5729,8 +5727,13 @@ print_holds(boolean_t scripted, int nwid + (void) strftime(tsbuf, DATETIME_BUF_LEN, + gettext(STRFTIME_FMT_STR), &t); + +- (void) printf("%-*s%*c%-*s%*c%s\n", nwidth, zname, +- sepnum, sep, tagwidth, tagname, sepnum, sep, tsbuf); ++ if (scripted) { ++ (void) printf("%s\t%s\t%s\n", zname, ++ tagname, tsbuf); ++ } else { ++ (void) printf("%-*s %-*s %s\n", nwidth, ++ zname, tagwidth, tagname, tsbuf); ++ } + } + } + } diff -Nru zfs-linux-0.7.5/debian/patches/2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch zfs-linux-0.7.5/debian/patches/2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch --- zfs-linux-0.7.5/debian/patches/2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch 2018-04-16 10:54:09.000000000 +0000 @@ -0,0 +1,40 @@ +From cf232b53d5deb8fba4665ce4fd039b444eb3201a Mon Sep 17 00:00:00 2001 +From: Giuseppe Di Natale +Date: Wed, 24 Jan 2018 16:19:55 -0800 +Subject: [PATCH] Revert "Remove wrong ASSERT in annotate_ecksum" +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +This reverts commit 093911f1945b5c164a45bb077103283dafdcae0c. + +Reviewed-by: Chunwei Chen +Reviewed-by: Brian Behlendorf +Reviewed-by: George Melikov +Signed-off-by: Giuseppe Di Natale +Closes #7079 +--- + module/zfs/zfs_fm.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/zfs_fm.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zfs_fm.c ++++ zfs-linux-0.7.5/module/zfs/zfs_fm.c +@@ -490,8 +490,7 @@ update_histogram(uint64_t value_arg, uin + /* We store the bits in big-endian (largest-first) order */ + for (i = 0; i < 64; i++) { + if (value & (1ull << i)) { +- if (hist[63 - i] < UINT16_MAX) +- hist[63 - i]++; ++ hist[63 - i]++; + ++bits; + } + } +@@ -649,6 +648,7 @@ annotate_ecksum(nvlist_t *ereport, zio_b + if (badabd == NULL || goodabd == NULL) + return (eip); + ++ ASSERT3U(nui64s, <=, UINT16_MAX); + ASSERT3U(size, ==, nui64s * sizeof (uint64_t)); + ASSERT3U(size, <=, SPA_MAXBLOCKSIZE); + ASSERT3U(size, <=, UINT32_MAX); diff -Nru zfs-linux-0.7.5/debian/patches/2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch zfs-linux-0.7.5/debian/patches/2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch --- zfs-linux-0.7.5/debian/patches/2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch 2018-04-16 10:55:40.000000000 +0000 @@ -0,0 +1,69 @@ +From 1b18c6d791d567499daa2c35467897d950a698e6 Mon Sep 17 00:00:00 2001 +From: Andriy Gapon +Date: Thu, 26 Oct 2017 18:55:19 +0300 +Subject: [PATCH] OpenZFS 8731 - ASSERT3U(nui64s, <=, UINT16_MAX) fails for + large blocks +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: Andriy Gapon +Approved by: Dan McDonald +Reviewed by: Matthew Ahrens +Reviewed-by: Chunwei Chen +Reviewed-by: Brian Behlendorf +Reviewed-by: George Melikov +Ported-by: Giuseppe Di Natale + +OpenZFS-issue: https://www.illumos.org/issues/8731 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/4c08500788 +Closes #7079 +--- + module/zfs/zfs_fm.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +Index: zfs-linux-0.7.5/module/zfs/zfs_fm.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/zfs_fm.c ++++ zfs-linux-0.7.5/module/zfs/zfs_fm.c +@@ -455,8 +455,8 @@ zfs_ereport_start(nvlist_t **ereport_out + + typedef struct zfs_ecksum_info { + /* histograms of set and cleared bits by bit number in a 64-bit word */ +- uint16_t zei_histogram_set[sizeof (uint64_t) * NBBY]; +- uint16_t zei_histogram_cleared[sizeof (uint64_t) * NBBY]; ++ uint32_t zei_histogram_set[sizeof (uint64_t) * NBBY]; ++ uint32_t zei_histogram_cleared[sizeof (uint64_t) * NBBY]; + + /* inline arrays of bits set and cleared. */ + uint64_t zei_bits_set[ZFM_MAX_INLINE]; +@@ -481,7 +481,7 @@ typedef struct zfs_ecksum_info { + } zfs_ecksum_info_t; + + static void +-update_histogram(uint64_t value_arg, uint16_t *hist, uint32_t *count) ++update_histogram(uint64_t value_arg, uint32_t *hist, uint32_t *count) + { + size_t i; + size_t bits = 0; +@@ -648,7 +648,7 @@ annotate_ecksum(nvlist_t *ereport, zio_b + if (badabd == NULL || goodabd == NULL) + return (eip); + +- ASSERT3U(nui64s, <=, UINT16_MAX); ++ ASSERT3U(nui64s, <=, UINT32_MAX); + ASSERT3U(size, ==, nui64s * sizeof (uint64_t)); + ASSERT3U(size, <=, SPA_MAXBLOCKSIZE); + ASSERT3U(size, <=, UINT32_MAX); +@@ -759,10 +759,10 @@ annotate_ecksum(nvlist_t *ereport, zio_b + } else { + fm_payload_set(ereport, + FM_EREPORT_PAYLOAD_ZFS_BAD_SET_HISTOGRAM, +- DATA_TYPE_UINT16_ARRAY, ++ DATA_TYPE_UINT32_ARRAY, + NBBY * sizeof (uint64_t), eip->zei_histogram_set, + FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_HISTOGRAM, +- DATA_TYPE_UINT16_ARRAY, ++ DATA_TYPE_UINT32_ARRAY, + NBBY * sizeof (uint64_t), eip->zei_histogram_cleared, + NULL); + } diff -Nru zfs-linux-0.7.5/debian/patches/2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch zfs-linux-0.7.5/debian/patches/2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch --- zfs-linux-0.7.5/debian/patches/2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch 2018-04-16 10:57:44.000000000 +0000 @@ -0,0 +1,53 @@ +From bb253625538824d8acae6ef62f5cdc7b1a525633 Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf +Date: Mon, 8 Jan 2018 16:15:23 -0800 +Subject: [PATCH] Prevent zdb(8) from occasionally hanging on I/O +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +The zdb(8) command may not terminate in the case where the pool +gets suspended and there is a caller in zio_wait() blocking on +an outstanding read I/O that will never complete. This can in +turn cause ztest(1) to block indefinitely despite the deadman. + +Resolve the issue by setting the default failure mode for zdb(8) +to panic. In user space we always want the command to terminate +when forward progress is no longer possible. + +Reviewed-by: Tim Chase +Reviewed by: Thomas Caputi +Reviewed-by: Giuseppe Di Natale +Signed-off-by: Brian Behlendorf +Closes #6999 +--- + cmd/zdb/zdb.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -4447,6 +4447,8 @@ main(int argc, char **argv) + } + } else { + error = open_objset(target, DMU_OST_ANY, FTAG, &os); ++ if (error == 0) ++ spa = dmu_objset_spa(os); + } + } + nvlist_free(policy); +@@ -4454,6 +4456,14 @@ main(int argc, char **argv) + if (error) + fatal("can't open '%s': %s", target, strerror(error)); + ++ /* ++ * Set the pool failure mode to panic in order to prevent the pool ++ * from suspending. A suspended I/O will have no way to resume and ++ * can prevent the zdb(8) command from terminating as expected. ++ */ ++ if (spa != NULL) ++ spa->spa_failmode = ZIO_FAILURE_MODE_PANIC; ++ + argv++; + argc--; + if (!dump_opt['R']) { diff -Nru zfs-linux-0.7.5/debian/patches/2340-Fix-zfs-receive-o-when-used-with-e-d.patch zfs-linux-0.7.5/debian/patches/2340-Fix-zfs-receive-o-when-used-with-e-d.patch --- zfs-linux-0.7.5/debian/patches/2340-Fix-zfs-receive-o-when-used-with-e-d.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2340-Fix-zfs-receive-o-when-used-with-e-d.patch 2018-04-16 14:59:42.000000000 +0000 @@ -0,0 +1,93 @@ +From bee7e4ff12c7170671606bcea33a6eef6cad5d58 Mon Sep 17 00:00:00 2001 +From: LOLi +Date: Wed, 31 Jan 2018 00:54:33 +0100 +Subject: [PATCH] Fix 'zfs receive -o' when used with '-e|-d' +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +When used in conjunction with one of '-e' or '-d' zfs receive options +none of the properties requested to be set (-o) are actually applied: +this is caused by a wrong assumption made about the toplevel dataset +in zfs_receive_one(). + +Fix this by correctly detecting the toplevel dataset. + +Reviewed-by: Tony Hutter +Reviewed-by: Brian Behlendorf +Signed-off-by: loli10K +Closes #7088 +--- + lib/libzfs/libzfs_sendrecv.c | 5 +-- + .../receive-o-x_props_override.ksh | 36 +++++++++++++++++++ + 2 files changed, 39 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/lib/libzfs/libzfs_sendrecv.c +=================================================================== +--- zfs-linux-0.7.5.orig/lib/libzfs/libzfs_sendrecv.c ++++ zfs-linux-0.7.5/lib/libzfs/libzfs_sendrecv.c +@@ -3252,7 +3252,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in + nvlist_t *oxprops = NULL; /* override (-o) and exclude (-x) props */ + nvlist_t *origprops = NULL; /* original props (if destination exists) */ + zfs_type_t type; +- boolean_t toplevel; ++ boolean_t toplevel = B_FALSE; + boolean_t zoned = B_FALSE; + + begin_time = time(NULL); +@@ -3586,7 +3586,8 @@ zfs_receive_one(libzfs_handle_t *hdl, in + goto out; + } + +- toplevel = chopprefix[0] != '/'; ++ if (top_zfs && *top_zfs == NULL) ++ toplevel = B_TRUE; + if (drrb->drr_type == DMU_OST_ZVOL) { + type = ZFS_TYPE_VOLUME; + } else if (drrb->drr_type == DMU_OST_ZFS) { +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh +@@ -371,6 +371,42 @@ log_must eval "check_prop_source $dest t + log_must eval "check_prop_source $dest atime off local" + log_must eval "check_prop_source $destsub type volume -" + log_must eval "check_prop_source $destsub atime - -" ++# Cleanup ++log_must zfs destroy -r -f $orig ++log_must zfs destroy -r -f $dest ++ ++# ++# 3.8 Verify 'zfs recv -x|-o' works correctly when used in conjunction with -d ++# and -e options. ++# ++log_must zfs create -p $orig/1/2/3/4 ++log_must eval "zfs set copies=2 $orig" ++log_must eval "zfs set atime=on $orig" ++log_must eval "zfs set '$userprop:orig'='oldval' $orig" ++log_must zfs snapshot -r $orig@snap1 ++log_must eval "zfs send -R $orig/1/2@snap1 > $streamfile_repl" ++# Verify 'zfs recv -e' ++log_must zfs create $dest ++log_must eval "zfs receive -e -o copies=3 -x atime "\ ++ "-o '$userprop:orig'='newval' $dest < $streamfile_repl" ++log_must datasetexists $dest/2/3/4 ++log_must eval "check_prop_source $dest/2 copies 3 local" ++log_must eval "check_prop_inherit $dest/2/3/4 copies $dest/2" ++log_must eval "check_prop_source $dest/2/3/4 atime on default" ++log_must eval "check_prop_source $dest/2 '$userprop:orig' 'newval' local" ++log_must eval "check_prop_inherit $dest/2/3/4 '$userprop:orig' $dest/2" ++log_must zfs destroy -r -f $dest ++# Verify 'zfs recv -d' ++log_must zfs create $dest ++typeset fs="$(echo $orig | awk -F'/' '{print $NF}')" ++log_must eval "zfs receive -d -o copies=3 -x atime "\ ++ "-o '$userprop:orig'='newval' $dest < $streamfile_repl" ++log_must datasetexists $dest/$fs/1/2/3/4 ++log_must eval "check_prop_source $dest/$fs/1/2 copies 3 local" ++log_must eval "check_prop_inherit $dest/$fs/1/2/3/4 copies $dest/$fs/1/2" ++log_must eval "check_prop_source $dest/$fs/1/2/3/4 atime on default" ++log_must eval "check_prop_source $dest/$fs/1/2 '$userprop:orig' 'newval' local" ++log_must eval "check_prop_inherit $dest/$fs/1/2/3/4 '$userprop:orig' $dest/$fs/1/2" + # We don't need to cleanup here + + log_pass "ZFS receive property override and exclude options passed." diff -Nru zfs-linux-0.7.5/debian/patches/2341-Change-movaps-to-movups-in-AES-NI-code.patch zfs-linux-0.7.5/debian/patches/2341-Change-movaps-to-movups-in-AES-NI-code.patch --- zfs-linux-0.7.5/debian/patches/2341-Change-movaps-to-movups-in-AES-NI-code.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2341-Change-movaps-to-movups-in-AES-NI-code.patch 2018-04-16 15:38:08.000000000 +0000 @@ -0,0 +1,279 @@ +From a73c94934f6176f63c3ec4c216a84066e9b65465 Mon Sep 17 00:00:00 2001 +From: Tom Caputi +Date: Wed, 31 Jan 2018 18:17:56 -0500 +Subject: [PATCH] Change movaps to movups in AES-NI code +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Currently, the ICP contains accelerated assembly code to be +used specifically on CPUs with AES-NI enabled. This code +makes heavy use of the movaps instruction which assumes that +it will be provided aes keys that are 16 byte aligned. This +assumption seems to hold on Illumos, but on Linux some kernel +options such as 'slub_debug=P' will violate it. This patch +changes all instances of this instruction to movups which is +the same except that it can handle unaligned memory. + +This patch also adds a few flags which were accidentally never +given to the assembly compiler, resulting in objtool warnings. + +Reviewed by: Gvozden Neskovic +Reviewed-by: Brian Behlendorf +Reviewed-by: Nathaniel R. Lewis +Signed-off-by: Tom Caputi +Closes #7065 +Closes #7108 +--- + +Index: zfs-linux-0.7.5/module/icp/asm-x86_64/aes/aes_intel.S +=================================================================== +--- zfs-linux-0.7.5.orig/module/icp/asm-x86_64/aes/aes_intel.S ++++ zfs-linux-0.7.5/module/icp/asm-x86_64/aes/aes_intel.S +@@ -207,7 +207,7 @@ _key_expansion_256a_local: + shufps $0b10001100, %xmm0, %xmm4 + pxor %xmm4, %xmm0 + pxor %xmm1, %xmm0 +- movaps %xmm0, (%rcx) ++ movups %xmm0, (%rcx) + add $0x10, %rcx + ret + nop +@@ -224,18 +224,18 @@ _key_expansion_192a_local: + pxor %xmm4, %xmm0 + pxor %xmm1, %xmm0 + +- movaps %xmm2, %xmm5 +- movaps %xmm2, %xmm6 ++ movups %xmm2, %xmm5 ++ movups %xmm2, %xmm6 + pslldq $4, %xmm5 + pshufd $0b11111111, %xmm0, %xmm3 + pxor %xmm3, %xmm2 + pxor %xmm5, %xmm2 + +- movaps %xmm0, %xmm1 ++ movups %xmm0, %xmm1 + shufps $0b01000100, %xmm0, %xmm6 +- movaps %xmm6, (%rcx) ++ movups %xmm6, (%rcx) + shufps $0b01001110, %xmm2, %xmm1 +- movaps %xmm1, 0x10(%rcx) ++ movups %xmm1, 0x10(%rcx) + add $0x20, %rcx + ret + SET_SIZE(_key_expansion_192a) +@@ -250,13 +250,13 @@ _key_expansion_192b_local: + pxor %xmm4, %xmm0 + pxor %xmm1, %xmm0 + +- movaps %xmm2, %xmm5 ++ movups %xmm2, %xmm5 + pslldq $4, %xmm5 + pshufd $0b11111111, %xmm0, %xmm3 + pxor %xmm3, %xmm2 + pxor %xmm5, %xmm2 + +- movaps %xmm0, (%rcx) ++ movups %xmm0, (%rcx) + add $0x10, %rcx + ret + SET_SIZE(_key_expansion_192b) +@@ -270,7 +270,7 @@ _key_expansion_256b_local: + shufps $0b10001100, %xmm2, %xmm4 + pxor %xmm4, %xmm2 + pxor %xmm1, %xmm2 +- movaps %xmm2, (%rcx) ++ movups %xmm2, (%rcx) + add $0x10, %rcx + ret + SET_SIZE(_key_expansion_256b) +@@ -327,7 +327,7 @@ rijndael_key_setup_enc_intel_local: + jz .Lenc_key_invalid_param + + movups (%USERCIPHERKEY), %xmm0 // user key (first 16 bytes) +- movaps %xmm0, (%AESKEY) ++ movups %xmm0, (%AESKEY) + lea 0x10(%AESKEY), %rcx // key addr + pxor %xmm4, %xmm4 // xmm4 is assumed 0 in _key_expansion_x + +@@ -341,7 +341,7 @@ rijndael_key_setup_enc_intel_local: + #endif /* OPENSSL_INTERFACE */ + + movups 0x10(%USERCIPHERKEY), %xmm2 // other user key (2nd 16 bytes) +- movaps %xmm2, (%rcx) ++ movups %xmm2, (%rcx) + add $0x10, %rcx + + aeskeygenassist $0x1, %xmm2, %xmm1 // expand the key +@@ -525,10 +525,10 @@ FRAME_BEGIN + + .align 4 + .Ldec_key_reorder_loop: +- movaps (%AESKEY), %xmm0 +- movaps (%ROUNDS64), %xmm1 +- movaps %xmm0, (%ROUNDS64) +- movaps %xmm1, (%AESKEY) ++ movups (%AESKEY), %xmm0 ++ movups (%ROUNDS64), %xmm1 ++ movups %xmm0, (%ROUNDS64) ++ movups %xmm1, (%AESKEY) + lea 0x10(%AESKEY), %AESKEY + lea -0x10(%ROUNDS64), %ROUNDS64 + cmp %AESKEY, %ROUNDS64 +@@ -536,11 +536,11 @@ FRAME_BEGIN + + .align 4 + .Ldec_key_inv_loop: +- movaps (%rcx), %xmm0 ++ movups (%rcx), %xmm0 + // Convert an encryption round key to a form usable for decryption + // with the "AES Inverse Mix Columns" instruction + aesimc %xmm0, %xmm1 +- movaps %xmm1, (%rcx) ++ movups %xmm1, (%rcx) + lea 0x10(%rcx), %rcx + cmp %ENDAESKEY, %rcx + jnz .Ldec_key_inv_loop +@@ -602,7 +602,7 @@ FRAME_BEGIN + ENTRY_NP(aes_encrypt_intel) + + movups (%INP), %STATE // input +- movaps (%KEYP), %KEY // key ++ movups (%KEYP), %KEY // key + #ifdef OPENSSL_INTERFACE + mov 240(%KEYP), %NROUNDS32 // round count + #else /* OpenSolaris Interface */ +@@ -618,41 +618,41 @@ ENTRY_NP(aes_encrypt_intel) + + // AES 256 + lea 0x20(%KEYP), %KEYP +- movaps -0x60(%KEYP), %KEY ++ movups -0x60(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps -0x50(%KEYP), %KEY ++ movups -0x50(%KEYP), %KEY + aesenc %KEY, %STATE + + .align 4 + .Lenc192: + // AES 192 and 256 +- movaps -0x40(%KEYP), %KEY ++ movups -0x40(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps -0x30(%KEYP), %KEY ++ movups -0x30(%KEYP), %KEY + aesenc %KEY, %STATE + + .align 4 + .Lenc128: + // AES 128, 192, and 256 +- movaps -0x20(%KEYP), %KEY ++ movups -0x20(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps -0x10(%KEYP), %KEY ++ movups -0x10(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps (%KEYP), %KEY ++ movups (%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x10(%KEYP), %KEY ++ movups 0x10(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x20(%KEYP), %KEY ++ movups 0x20(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x30(%KEYP), %KEY ++ movups 0x30(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x40(%KEYP), %KEY ++ movups 0x40(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x50(%KEYP), %KEY ++ movups 0x50(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x60(%KEYP), %KEY ++ movups 0x60(%KEYP), %KEY + aesenc %KEY, %STATE +- movaps 0x70(%KEYP), %KEY ++ movups 0x70(%KEYP), %KEY + aesenclast %KEY, %STATE // last round + movups %STATE, (%OUTP) // output + +@@ -685,7 +685,7 @@ ENTRY_NP(aes_encrypt_intel) + ENTRY_NP(aes_decrypt_intel) + + movups (%INP), %STATE // input +- movaps (%KEYP), %KEY // key ++ movups (%KEYP), %KEY // key + #ifdef OPENSSL_INTERFACE + mov 240(%KEYP), %NROUNDS32 // round count + #else /* OpenSolaris Interface */ +@@ -701,41 +701,41 @@ ENTRY_NP(aes_decrypt_intel) + + // AES 256 + lea 0x20(%KEYP), %KEYP +- movaps -0x60(%KEYP), %KEY ++ movups -0x60(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps -0x50(%KEYP), %KEY ++ movups -0x50(%KEYP), %KEY + aesdec %KEY, %STATE + + .align 4 + .Ldec192: + // AES 192 and 256 +- movaps -0x40(%KEYP), %KEY ++ movups -0x40(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps -0x30(%KEYP), %KEY ++ movups -0x30(%KEYP), %KEY + aesdec %KEY, %STATE + + .align 4 + .Ldec128: + // AES 128, 192, and 256 +- movaps -0x20(%KEYP), %KEY ++ movups -0x20(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps -0x10(%KEYP), %KEY ++ movups -0x10(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps (%KEYP), %KEY ++ movups (%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x10(%KEYP), %KEY ++ movups 0x10(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x20(%KEYP), %KEY ++ movups 0x20(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x30(%KEYP), %KEY ++ movups 0x30(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x40(%KEYP), %KEY ++ movups 0x40(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x50(%KEYP), %KEY ++ movups 0x50(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x60(%KEYP), %KEY ++ movups 0x60(%KEYP), %KEY + aesdec %KEY, %STATE +- movaps 0x70(%KEYP), %KEY ++ movups 0x70(%KEYP), %KEY + aesdeclast %KEY, %STATE // last round + movups %STATE, (%OUTP) // output + +Index: zfs-linux-0.7.5/module/icp/asm-x86_64/modes/gcm_intel.S +=================================================================== +--- zfs-linux-0.7.5.orig/module/icp/asm-x86_64/modes/gcm_intel.S ++++ zfs-linux-0.7.5/module/icp/asm-x86_64/modes/gcm_intel.S +@@ -150,7 +150,7 @@ ENTRY_NP(gcm_mul_pclmulqdq) + // Byte swap 16-byte input + // + lea .Lbyte_swap16_mask(%rip), %rax +- movaps (%rax), %xmm10 ++ movups (%rax), %xmm10 + pshufb %xmm10, %xmm0 + pshufb %xmm10, %xmm1 + diff -Nru zfs-linux-0.7.5/debian/patches/2342-tx_waited-tx_dirty_delayed-in-trace_dmu.h.patch zfs-linux-0.7.5/debian/patches/2342-tx_waited-tx_dirty_delayed-in-trace_dmu.h.patch --- zfs-linux-0.7.5/debian/patches/2342-tx_waited-tx_dirty_delayed-in-trace_dmu.h.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2342-tx_waited-tx_dirty_delayed-in-trace_dmu.h.patch 2018-04-16 15:43:14.000000000 +0000 @@ -0,0 +1,63 @@ +From 4c46b99d24a6e71b3c72462c11cb051d0930ad60 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dr=2E=20Andr=C3=A1s=20Korn?= + +Date: Tue, 30 Jan 2018 11:34:39 +0100 +Subject: [PATCH] tx_waited -> tx_dirty_delayed in trace_dmu.h +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +This change was missed in 0735ecb33485e91a78357a274e47c2782858d8b9. + +Reviewed-by: Fabian Grünbichler +Reviewed-by: Brian Behlendorf +Reviewed-by: Giuseppe Di Natale +Signed-off-by: András Korn +Closes #7096 +--- + include/sys/trace_dmu.h | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/include/sys/trace_dmu.h b/include/sys/trace_dmu.h +index 5ae59e563..24e57f514 100644 +--- a/include/sys/trace_dmu.h ++++ b/include/sys/trace_dmu.h +@@ -50,7 +50,7 @@ DECLARE_EVENT_CLASS(zfs_delay_mintime_class, + __field(uint64_t, tx_lastsnap_txg) + __field(uint64_t, tx_lasttried_txg) + __field(boolean_t, tx_anyobj) +- __field(boolean_t, tx_waited) ++ __field(boolean_t, tx_dirty_delayed) + __field(hrtime_t, tx_start) + __field(boolean_t, tx_wait_dirty) + __field(int, tx_err) +@@ -62,7 +62,7 @@ DECLARE_EVENT_CLASS(zfs_delay_mintime_class, + __entry->tx_lastsnap_txg = tx->tx_lastsnap_txg; + __entry->tx_lasttried_txg = tx->tx_lasttried_txg; + __entry->tx_anyobj = tx->tx_anyobj; +- __entry->tx_waited = tx->tx_waited; ++ __entry->tx_dirty_delayed = tx->tx_dirty_delayed; + __entry->tx_start = tx->tx_start; + __entry->tx_wait_dirty = tx->tx_wait_dirty; + __entry->tx_err = tx->tx_err; +@@ -70,11 +70,12 @@ DECLARE_EVENT_CLASS(zfs_delay_mintime_class, + __entry->min_tx_time = min_tx_time; + ), + TP_printk("tx { txg %llu lastsnap_txg %llu tx_lasttried_txg %llu " +- "anyobj %d waited %d start %llu wait_dirty %d err %i " ++ "anyobj %d dirty_delayed %d start %llu wait_dirty %d err %i " + "} dirty %llu min_tx_time %llu", + __entry->tx_txg, __entry->tx_lastsnap_txg, +- __entry->tx_lasttried_txg, __entry->tx_anyobj, __entry->tx_waited, +- __entry->tx_start, __entry->tx_wait_dirty, __entry->tx_err, ++ __entry->tx_lasttried_txg, __entry->tx_anyobj, ++ __entry->tx_dirty_delayed, __entry->tx_start, ++ __entry->tx_wait_dirty, __entry->tx_err, + __entry->dirty, __entry->min_tx_time) + ); + /* END CSTYLED */ +-- +2.17.0 + diff -Nru zfs-linux-0.7.5/debian/patches/2343-OpenZFS-8966-Source-file-zfs_acl.c-function-zfs_acls.patch zfs-linux-0.7.5/debian/patches/2343-OpenZFS-8966-Source-file-zfs_acl.c-function-zfs_acls.patch --- zfs-linux-0.7.5/debian/patches/2343-OpenZFS-8966-Source-file-zfs_acl.c-function-zfs_acls.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2343-OpenZFS-8966-Source-file-zfs_acl.c-function-zfs_acls.patch 2018-04-16 16:03:35.000000000 +0000 @@ -0,0 +1,47 @@ +From 8824a7f133e4402f7176115cf8efd535c8cbdab2 Mon Sep 17 00:00:00 2001 +From: WHR +Date: Sun, 14 Jan 2018 23:57:54 +0300 +Subject: [PATCH] OpenZFS 8966 - Source file zfs_acl.c, function + zfs_aclset_common contains a use after end of the lifetime of a local + variable +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Authored by: WHR +Reviewed by: Matt Ahrens +Reviewed by: Andriy Gapon +Reviewed by: George Melikov +Reviewed by: Brian Behlendorf +Approved by: Richard Lowe +Ported-by: Giuseppe Di Natale + +OpenZFS-issue: https://www.illumos.org/issues/8966 +OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c95549fcdc +Closes #7141 +--- + module/zfs/zfs_acl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/module/zfs/zfs_acl.c b/module/zfs/zfs_acl.c +index 71a837a35..5ef20f088 100644 +--- a/module/zfs/zfs_acl.c ++++ b/module/zfs/zfs_acl.c +@@ -1323,6 +1323,7 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t *cr, dmu_tx_t *tx) + sa_bulk_attr_t bulk[5]; + uint64_t ctime[2]; + int count = 0; ++ zfs_acl_phys_t acl_phys; + + mode = zp->z_mode; + +@@ -1369,7 +1370,6 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t *cr, dmu_tx_t *tx) + } else { /* Painful legacy way */ + zfs_acl_node_t *aclnode; + uint64_t off = 0; +- zfs_acl_phys_t acl_phys; + uint64_t aoid; + + if ((error = sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zfsvfs), +-- +2.17.0 + diff -Nru zfs-linux-0.7.5/debian/patches/2344-Fix-zdb-c-traverse-stop-on-damaged-objset-root.patch zfs-linux-0.7.5/debian/patches/2344-Fix-zdb-c-traverse-stop-on-damaged-objset-root.patch --- zfs-linux-0.7.5/debian/patches/2344-Fix-zdb-c-traverse-stop-on-damaged-objset-root.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2344-Fix-zdb-c-traverse-stop-on-damaged-objset-root.patch 2018-04-16 16:13:58.000000000 +0000 @@ -0,0 +1,95 @@ +From d3190c5f2914b7265f130dc44b868634877a8d7e Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Tue, 30 Jan 2018 13:39:11 -0800 +Subject: [PATCH] Fix zdb -c traverse stop on damaged objset root +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +If a corruption happens to be on a root block of an objset, zdb -c will +not correctly report the error, and it will not traverse the datasets +that come after. This is because traverse_visitbp, which does the +callback and reset error for TRAVERSE_HARD, is skipped when traversing +zil is failed in traverse_impl. + +Here's example of what 'zdb -eLcc' command looks like on a pool with +damaged objset root: + +== before patch: + +Traversing all blocks to verify checksums ... + +Error counts: + + errno count +block traversal size 379392 != alloc 33987072 (unreachable 33607680) + + bp count: 172 + ganged count: 0 + bp logical: 1678336 avg: 9757 + bp physical: 130560 avg: 759 compression: 12.85 + bp allocated: 379392 avg: 2205 compression: 4.42 + bp deduped: 0 ref>1: 0 deduplication: 1.00 + SPA allocated: 33987072 used: 0.80% + + additional, non-pointer bps of type 0: 71 + Dittoed blocks on same vdev: 101 + +== after patch: + +Traversing all blocks to verify checksums ... + +zdb_blkptr_cb: Got error 52 reading <54, 0, -1, 0> -- skipping + +Error counts: + + errno count + 52 1 +block traversal size 33963520 != alloc 33987072 (unreachable 23552) + + bp count: 447 + ganged count: 0 + bp logical: 36093440 avg: 80745 + bp physical: 33699840 avg: 75391 compression: 1.07 + bp allocated: 33963520 avg: 75981 compression: 1.06 + bp deduped: 0 ref>1: 0 deduplication: 1.00 + SPA allocated: 33987072 used: 0.80% + + additional, non-pointer bps of type 0: 76 + Dittoed blocks on same vdev: 115 + +== + +Reviewed-by: Brian Behlendorf +Reviewed-by: loli10K +Signed-off-by: Chunwei Chen +Closes #7099 +--- + +Index: zfs-linux-0.7.5/module/zfs/dmu_traverse.c +=================================================================== +--- zfs-linux-0.7.5.orig/module/zfs/dmu_traverse.c ++++ zfs-linux-0.7.5/module/zfs/dmu_traverse.c +@@ -609,9 +609,20 @@ traverse_impl(spa_t *spa, dsl_dataset_t + if (err != 0) + return (err); + +- osp = buf->b_data; +- traverse_zil(td, &osp->os_zil_header); +- arc_buf_destroy(buf, &buf); ++ if (err != 0) { ++ /* ++ * If both TRAVERSE_HARD and TRAVERSE_PRE are set, ++ * continue to visitbp so that td_func can be called ++ * in pre stage, and err will reset to zero. ++ */ ++ if (!(td->td_flags & TRAVERSE_HARD) || ++ !(td->td_flags & TRAVERSE_PRE)) ++ return (err); ++ } else { ++ osp = buf->b_data; ++ traverse_zil(td, &osp->os_zil_header); ++ arc_buf_destroy(buf, &buf); ++ } + } + + if (!(flags & TRAVERSE_PREFETCH_DATA) || diff -Nru zfs-linux-0.7.5/debian/patches/2345-Fix-zle_decompress-out-of-bound-access.patch zfs-linux-0.7.5/debian/patches/2345-Fix-zle_decompress-out-of-bound-access.patch --- zfs-linux-0.7.5/debian/patches/2345-Fix-zle_decompress-out-of-bound-access.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2345-Fix-zle_decompress-out-of-bound-access.patch 2018-04-16 16:22:28.000000000 +0000 @@ -0,0 +1,37 @@ +From f108a49236ee21bab807c0c6750409b6912ef05e Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Thu, 1 Feb 2018 15:41:05 -0800 +Subject: [PATCH] Fix zle_decompress out of bound access +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Reviewed-by: Brian Behlendorf +Reviewed-by: loli10K +Signed-off-by: Chunwei Chen +Closes #7099 +--- + module/zfs/zle.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/module/zfs/zle.c b/module/zfs/zle.c +index 13c5673fb..613607faa 100644 +--- a/module/zfs/zle.c ++++ b/module/zfs/zle.c +@@ -74,10 +74,14 @@ zle_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) + while (src < s_end && dst < d_end) { + int len = 1 + *src++; + if (len <= n) { ++ if (src + len > s_end || dst + len > d_end) ++ return (-1); + while (len-- != 0) + *dst++ = *src++; + } else { + len -= n; ++ if (dst + len > d_end) ++ return (-1); + while (len-- != 0) + *dst++ = 0; + } +-- +2.17.0 + diff -Nru zfs-linux-0.7.5/debian/patches/2346-Fix-racy-assignment-of-zcb.zcb_haderrors.patch zfs-linux-0.7.5/debian/patches/2346-Fix-racy-assignment-of-zcb.zcb_haderrors.patch --- zfs-linux-0.7.5/debian/patches/2346-Fix-racy-assignment-of-zcb.zcb_haderrors.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2346-Fix-racy-assignment-of-zcb.zcb_haderrors.patch 2018-04-16 16:25:39.000000000 +0000 @@ -0,0 +1,53 @@ +From 0c0b0ad48addf342fcff29253a40282c00d5ce65 Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Thu, 1 Feb 2018 15:42:41 -0800 +Subject: [PATCH] Fix racy assignment of zcb.zcb_haderrors +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +zcb_haderrors will be modified in zdb_blkptr_done, which is +asynchronous. So we must move this assignment after zio_wait. + +Reviewed-by: Brian Behlendorf +Reviewed-by: loli10K +Signed-off-by: Chunwei Chen +Closes #7099 +--- + cmd/zdb/zdb.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -3313,7 +3313,7 @@ dump_block_stats(spa_t *spa) + uint64_t norm_alloc, norm_space, total_alloc, total_found; + int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD; + boolean_t leaks = B_FALSE; +- int e, c; ++ int e, c, err; + bp_embedded_type_t i; + + (void) printf("\nTraversing all blocks %s%s%s%s%s...\n\n", +@@ -3354,7 +3354,7 @@ dump_block_stats(spa_t *spa) + + zcb.zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa)); + zcb.zcb_start = zcb.zcb_lastprint = gethrtime(); +- zcb.zcb_haderrors |= traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb); ++ err = traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb); + + /* + * If we've traversed the data blocks then we need to wait for those +@@ -3370,6 +3370,12 @@ dump_block_stats(spa_t *spa) + } + } + ++ /* ++ * Done after zio_wait() since zcb_haderrors is modified in ++ * zdb_blkptr_done() ++ */ ++ zcb.zcb_haderrors |= err; ++ + if (zcb.zcb_haderrors) { + (void) printf("\nError counts:\n\n"); + (void) printf("\t%5s %s\n", "errno", "count"); diff -Nru zfs-linux-0.7.5/debian/patches/2347-Fix-zdb-R-decompression.patch zfs-linux-0.7.5/debian/patches/2347-Fix-zdb-R-decompression.patch --- zfs-linux-0.7.5/debian/patches/2347-Fix-zdb-R-decompression.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2347-Fix-zdb-R-decompression.patch 2018-04-16 16:28:46.000000000 +0000 @@ -0,0 +1,124 @@ +From 950e17c215be4e6da72a61b0431337643a82b509 Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Thu, 1 Feb 2018 16:19:36 -0800 +Subject: [PATCH] Fix zdb -R decompression +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +There are some issues in the zdb -R decompression implementation. + +The first is that ZLE can easily decompress non-ZLE streams. So we add +ZDB_NO_ZLE env to make zdb skip ZLE. + +The second is the random bytes appended to pabd, pbuf2 stuff. This serve +no purpose at all, those bytes shouldn't be read during decompression +anyway. Instead, we randomize lbuf2, so that we can make sure +decompression fill exactly to lsize by bcmp lbuf and lbuf2. + +The last one is the condition to detect fail is wrong. + +Reviewed-by: Brian Behlendorf +Reviewed-by: loli10K +Signed-off-by: Chunwei Chen +Closes #7099 +Closes #4984 +--- + cmd/zdb/zdb.c | 38 ++++++++++++++++++-------------------- + man/man8/zdb.8 | 4 +++- + 2 files changed, 21 insertions(+), 21 deletions(-) + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -3895,13 +3895,6 @@ name: + return (NULL); + } + +-/* ARGSUSED */ +-static int +-random_get_pseudo_bytes_cb(void *buf, size_t len, void *unused) +-{ +- return (random_get_pseudo_bytes(buf, len)); +-} +- + /* + * Read a block from a pool and print it out. The syntax of the + * block descriptor is: +@@ -4064,17 +4057,8 @@ zdb_read_block(char *thing, spa_t *spa) + * every decompress function at every inflated blocksize. + */ + enum zio_compress c; +- void *pbuf2 = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL); + void *lbuf2 = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL); + +- abd_copy_to_buf(pbuf2, pabd, psize); +- +- VERIFY0(abd_iterate_func(pabd, psize, SPA_MAXBLOCKSIZE - psize, +- random_get_pseudo_bytes_cb, NULL)); +- +- VERIFY0(random_get_pseudo_bytes((uint8_t *)pbuf2 + psize, +- SPA_MAXBLOCKSIZE - psize)); +- + /* + * XXX - On the one hand, with SPA_MAXBLOCKSIZE at 16MB, + * this could take a while and we should let the user know +@@ -4084,13 +4068,29 @@ zdb_read_block(char *thing, spa_t *spa) + for (lsize = psize + SPA_MINBLOCKSIZE; + lsize <= SPA_MAXBLOCKSIZE; lsize += SPA_MINBLOCKSIZE) { + for (c = 0; c < ZIO_COMPRESS_FUNCTIONS; c++) { ++ /* ++ * ZLE can easily decompress non zle stream. ++ * So have an option to disable it. ++ */ ++ if (c == ZIO_COMPRESS_ZLE && ++ getenv("ZDB_NO_ZLE")) ++ continue; ++ + (void) fprintf(stderr, + "Trying %05llx -> %05llx (%s)\n", + (u_longlong_t)psize, (u_longlong_t)lsize, + zio_compress_table[c].ci_name); ++ ++ /* ++ * We randomize lbuf2, and decompress to both ++ * lbuf and lbuf2. This way, we will know if ++ * decompression fill exactly to lsize. ++ */ ++ VERIFY0(random_get_pseudo_bytes(lbuf2, lsize)); ++ + if (zio_decompress_data(c, pabd, + lbuf, psize, lsize) == 0 && +- zio_decompress_data_buf(c, pbuf2, ++ zio_decompress_data(c, pabd, + lbuf2, psize, lsize) == 0 && + bcmp(lbuf, lbuf2, lsize) == 0) + break; +@@ -4098,11 +4098,9 @@ zdb_read_block(char *thing, spa_t *spa) + if (c != ZIO_COMPRESS_FUNCTIONS) + break; + } +- +- umem_free(pbuf2, SPA_MAXBLOCKSIZE); + umem_free(lbuf2, SPA_MAXBLOCKSIZE); + +- if (lsize <= psize) { ++ if (lsize > SPA_MAXBLOCKSIZE) { + (void) printf("Decompress of %s failed\n", thing); + goto out; + } +Index: zfs-linux-0.7.5/man/man8/zdb.8 +=================================================================== +--- zfs-linux-0.7.5.orig/man/man8/zdb.8 ++++ zfs-linux-0.7.5/man/man8/zdb.8 +@@ -246,7 +246,9 @@ and, optionally, + .It Sy b Ar offset + Print block pointer + .It Sy d +-Decompress the block ++Decompress the block. Set environment variable ++.Nm ZBD_NO_ZLE ++to skip zle when guessing. + .It Sy e + Byte swap the block + .It Sy g diff -Nru zfs-linux-0.7.5/debian/patches/2348-Fix-zdb-E-segfault.patch zfs-linux-0.7.5/debian/patches/2348-Fix-zdb-E-segfault.patch --- zfs-linux-0.7.5/debian/patches/2348-Fix-zdb-E-segfault.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2348-Fix-zdb-E-segfault.patch 2018-04-16 16:32:29.000000000 +0000 @@ -0,0 +1,40 @@ +From 5e3bd0e684a3c32bd22647938247ac3699c5372a Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Thu, 1 Feb 2018 16:28:11 -0800 +Subject: [PATCH] Fix zdb -E segfault +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +SPA_MAXBLOCKSIZE is too large for stack. + +Reviewed-by: Brian Behlendorf +Reviewed-by: loli10K +Signed-off-by: Chunwei Chen +Closes #7099 +--- + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -4139,9 +4139,11 @@ zdb_embedded_block(char *thing) + { + blkptr_t bp; + unsigned long long *words = (void *)&bp; +- char buf[SPA_MAXBLOCKSIZE]; ++ char buf; + int err; + ++ buf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL); ++ + memset(&bp, 0, sizeof (blkptr_t)); + + err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:" +@@ -4161,6 +4163,7 @@ zdb_embedded_block(char *thing) + exit(1); + } + zdb_dump_block_raw(buf, BPE_GET_LSIZE(&bp), 0); ++ umem_free(buf, SPA_MAXBLOCKSIZE); + } + + int diff -Nru zfs-linux-0.7.5/debian/patches/2349-Fix-zdb-ed-on-objset-for-exported-pool.patch zfs-linux-0.7.5/debian/patches/2349-Fix-zdb-ed-on-objset-for-exported-pool.patch --- zfs-linux-0.7.5/debian/patches/2349-Fix-zdb-ed-on-objset-for-exported-pool.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/2349-Fix-zdb-ed-on-objset-for-exported-pool.patch 2018-04-16 17:24:19.000000000 +0000 @@ -0,0 +1,210 @@ +From eb9c4532dda34bcf0612c2c797cb3fcab9a21b4f Mon Sep 17 00:00:00 2001 +From: Chunwei Chen +Date: Thu, 1 Feb 2018 16:36:40 -0800 +Subject: [PATCH] Fix zdb -ed on objset for exported pool +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +zdb -ed on objset for exported pool would failed with: + failed to own dataset 'qq/fs0': No such file or directory + +The reason is that zdb pass objset name to spa_import, it uses that +name to create a spa. Later, when dmu_objset_own tries to lookup the spa +using real pool name, it can't find one. + +We fix this by make sure we pass pool name rather than objset name to +spa_import. + +Reviewed-by: Brian Behlendorf +Reviewed-by: loli10K +Signed-off-by: Chunwei Chen +Closes #7099 +Closes #6464 +--- + cmd/zdb/zdb.c | 32 ++++++---- + tests/runfiles/linux.run | 2 +- + .../tests/functional/clean_mirror/cleanup.ksh | 4 +- + .../tests/functional/cli_root/zdb/Makefile.am | 3 +- + .../functional/cli_root/zdb/zdb_006_pos.ksh | 64 +++++++++++++++++++ + 5 files changed, 90 insertions(+), 15 deletions(-) + create mode 100755 tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh + +Index: zfs-linux-0.7.5/cmd/zdb/zdb.c +=================================================================== +--- zfs-linux-0.7.5.orig/cmd/zdb/zdb.c ++++ zfs-linux-0.7.5/cmd/zdb/zdb.c +@@ -4178,7 +4178,7 @@ main(int argc, char **argv) + int error = 0; + char **searchdirs = NULL; + int nsearch = 0; +- char *target; ++ char *target, *target_pool; + nvlist_t *policy = NULL; + uint64_t max_txg = UINT64_MAX; + int flags = ZFS_IMPORT_MISSING_LOG; +@@ -4381,6 +4381,20 @@ main(int argc, char **argv) + error = 0; + target = argv[0]; + ++ if (strpbrk(target, "/@") != NULL) { ++ size_t targetlen; ++ ++ target_pool = strdup(target); ++ *strpbrk(target_pool, "/@") = '\0'; ++ ++ target_is_spa = B_FALSE; ++ targetlen = strlen(target); ++ if (targetlen && target[targetlen - 1] == '/') ++ target[targetlen - 1] = '\0'; ++ } else { ++ target_pool = target; ++ } ++ + if (dump_opt['e']) { + importargs_t args = { 0 }; + nvlist_t *cfg = NULL; +@@ -4389,8 +4403,10 @@ main(int argc, char **argv) + args.path = searchdirs; + args.can_be_active = B_TRUE; + +- error = zpool_tryimport(g_zfs, target, &cfg, &args); ++ error = zpool_tryimport(g_zfs, target_pool, &cfg, &args); ++ + if (error == 0) { ++ + if (nvlist_add_nvlist(cfg, + ZPOOL_REWIND_POLICY, policy) != 0) { + fatal("can't open '%s': %s", +@@ -4405,19 +4421,13 @@ main(int argc, char **argv) + (void) printf("\nConfiguration for import:\n"); + dump_nvlist(cfg, 8); + } +- error = spa_import(target, cfg, NULL, ++ error = spa_import(target_pool, cfg, NULL, + flags | ZFS_IMPORT_SKIP_MMP); + } + } + +- if (strpbrk(target, "/@") != NULL) { +- size_t targetlen; +- +- target_is_spa = B_FALSE; +- targetlen = strlen(target); +- if (targetlen && target[targetlen - 1] == '/') +- target[targetlen - 1] = '\0'; +- } ++ if (target_pool != target) ++ free(target_pool); + + if (error == 0) { + if (target_is_spa || dump_opt['R']) { +Index: zfs-linux-0.7.5/tests/runfiles/linux.run +=================================================================== +--- zfs-linux-0.7.5.orig/tests/runfiles/linux.run ++++ zfs-linux-0.7.5/tests/runfiles/linux.run +@@ -73,7 +73,7 @@ tags = ['functional', 'clean_mirror'] + + [tests/functional/cli_root/zdb] + tests = ['zdb_001_neg', 'zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', +- 'zdb_005_pos'] ++ 'zdb_005_pos', 'zdb_006_pos'] + pre = + post = + tags = ['functional', 'cli_root', 'zdb'] +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/clean_mirror/cleanup.ksh +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/clean_mirror/cleanup.ksh ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/clean_mirror/cleanup.ksh +@@ -38,10 +38,10 @@ df -F zfs -h | grep "$TESTFS " >/dev/nul + [[ $? == 0 ]] && log_must zfs umount -f $TESTDIR + destroy_pool $TESTPOOL + +-if is_mpath_device $MIRROR_PRIMARY; then ++if ( is_mpath_device $MIRROR_PRIMARY || is_loop_device $MIRROR_SECONDARY); then + parted $DEV_DSKDIR/$MIRROR_PRIMARY -s rm 1 + fi +-if is_mpath_device $MIRROR_SECONDARY; then ++if ( is_mpath_device $MIRROR_SECONDARY || is_loop_device $MIRROR_SECONDARY); then + parted $DEV_DSKDIR/$MIRROR_SECONDARY -s rm 1 + fi + # recreate and destroy a zpool over the disks to restore the partitions to +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am +=================================================================== +--- zfs-linux-0.7.5.orig/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am +@@ -4,4 +4,5 @@ dist_pkgdata_SCRIPTS = \ + zdb_002_pos.ksh \ + zdb_003_pos.ksh \ + zdb_004_pos.ksh \ +- zdb_005_pos.ksh ++ zdb_005_pos.ksh \ ++ zdb_006_pos.ksh +Index: zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh +=================================================================== +--- /dev/null ++++ zfs-linux-0.7.5/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_006_pos.ksh +@@ -0,0 +1,64 @@ ++#!/bin/ksh ++ ++# ++# This file and its contents are supplied under the terms of the ++# Common Development and Distribution License ("CDDL"), version 1.0. ++# You may only use this file in accordance with the terms of version ++# 1.0 of the CDDL. ++# ++# A full copy of the text of the CDDL should have accompanied this ++# source. A copy of the CDDL is also available via the Internet at ++# http://www.illumos.org/license/CDDL. ++# ++ ++# ++# Copyright (c) 2018 by Nutanix. All rights reserved. ++# ++ ++. $STF_SUITE/include/libtest.shlib ++ ++# ++# Description: ++# zdb -d will work on imported/exported pool with pool/dataset argument ++# ++# Strategy: ++# 1. Create a pool ++# 2. Run zdb -d with pool and dataset arguments. ++# 3. Export the pool ++# 4. Run zdb -ed with pool and dataset arguments. ++# ++ ++function cleanup ++{ ++ datasetexists $TESTPOOL && destroy_pool $TESTPOOL ++ for DISK in $DISKS; do ++ zpool labelclear -f $DEV_RDSKDIR/$DISK ++ done ++} ++ ++log_assert "Verify zdb -d works on imported/exported pool with pool/dataset argument" ++log_onexit cleanup ++ ++verify_runnable "global" ++verify_disk_count "$DISKS" 2 ++ ++default_mirror_setup_noexit $DISKS ++log_must zfs snap $TESTPOOL/$TESTFS@snap ++ ++log_must zdb -d $TESTPOOL ++log_must zdb -d $TESTPOOL/ ++log_must zdb -d $TESTPOOL/$TESTFS ++log_must zdb -d $TESTPOOL/$TESTFS@snap ++ ++log_must zpool export $TESTPOOL ++ ++log_must zdb -ed $TESTPOOL ++log_must zdb -ed $TESTPOOL/ ++log_must zdb -ed $TESTPOOL/$TESTFS ++log_must zdb -ed $TESTPOOL/$TESTFS@snap ++ ++log_must zpool import $TESTPOOL ++ ++cleanup ++ ++log_pass "zdb -d works on imported/exported pool with pool/dataset argument" diff -Nru zfs-linux-0.7.5/debian/patches/series zfs-linux-0.7.5/debian/patches/series --- zfs-linux-0.7.5/debian/patches/series 2017-12-18 14:46:40.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/series 2018-04-16 17:24:07.000000000 +0000 @@ -9,3 +9,59 @@ 0010-fix-install-path-of-zpool.d-scripts.patch 0001-Fix-bug-in-distclean-which-removes-needed-files.patch 2000-increase-default-zcmd-allocation-to-256K.patch +2100-zfs-load-module.patch +2101-Take-user-namespaces-into-account-in-policy-checks.patch +2102-Fix-ARC-hit-rate.patch +2200-add-zfs-0.6.x-ioctl-compat-shim.patch +2201-Fix-mmap-libaio-deadlock.patch +2202-Allow-mounting-datasets-more-than-once.patch +2300-OpenZFS-8373-TXG_WAIT-in-ZIL-commit-path.patch +2301-zfs-promote-rename-.-recv-should-be-an-error.patch +2302-Fix-parsable-zfs-get-for-compressratios.patch +2303-Fix-zpool-events-scripted-mode-tab-separator.patch +2304-zv_suspend_lock-in-zvol_open-zvol_release.patch +2305-Allow-longer-SPA-names-in-stats.patch +2306-vdev_mirror-load-balancing-fixes.patch +2307-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch +2308-OpenZFS-8375-Kernel-memory-leak-in-nvpair-code.patch +2309-OpenZFS-7261-nvlist-code-should-enforce-name-length-.patch +2310-OpenZFS-5778-nvpair_type_is_array-does-not-recognize.patch +2311-dmu_objset-release-bonus-buffer-in-failure-path.patch +2312-Fix-false-config_cache_write-events.patch +2313-Fix-printk-calls-missing-log-level.patch +2314-Fix-abdstats-kstat-on-32-bit-systems.patch +2315-Relax-ASSERT-for-6526.patch +2316-Fix-coverity-defects-147480-147584.patch +2317-Fix-coverity-defects-CID-161388.patch +2318-Use-ashift-12-by-default-on-SSDSC2BW48-disks.patch +2319-OpenZFS-8558-8602-lwp_create-returns-EAGAIN.patch +2320-ZFS-send-fails-to-dump-objects-larger-than-128PiB.patch +2321-Sort-output-of-tunables-in-arc_summary.py.patch +2322-Fix-data-on-evict_skips-in-arc_summary.py.patch +2323-Fix-segfault-in-zpool-iostat-when-adding-VDEVs.patch +2324-ZTS-Fix-create-o_ashift-test-case.patch +2325-Handle-invalid-options-in-arc_summary.patch +2326-Call-commit-callbacks-from-the-tail-of-the-list.patch +2327-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch +2328-Fix-fsanitize-address-memory-leak.patch +2329-Revert-raidz_map-and-_col-structure-types.patch +2330-Use-zap_count-instead-of-cached-z_size-for-unlink.patch +2331-OpenZFS-8897-zpool-online-e-fails-assertion-when-run.patch +2332-OpenZFS-8898-creating-fs-with-checksum-skein-on-the-.patch +2333-Emit-an-error-message-before-MMP-suspends-pool.patch +2334-OpenZFS-8641-zpool-clear-and-zinject-don-t-work-on-s.patch +2335-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch +2336-OpenZFS-8972-zfs-holds-In-scripted-mode-do-not-pad-c.patch +2337-Revert-Remove-wrong-ASSERT-in-annotate_ecksum.patch +2338-OpenZFS-8731-ASSERT3U-nui64s-UINT16_MAX-fails-for-la.patch +2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch +2340-Fix-zfs-receive-o-when-used-with-e-d.patch +2341-Change-movaps-to-movups-in-AES-NI-code.patch +2342-tx_waited-tx_dirty_delayed-in-trace_dmu.h.patch +2343-OpenZFS-8966-Source-file-zfs_acl.c-function-zfs_acls.patch +2344-Fix-zdb-c-traverse-stop-on-damaged-objset-root.patch +2345-Fix-zle_decompress-out-of-bound-access.patch +2346-Fix-racy-assignment-of-zcb.zcb_haderrors.patch +2347-Fix-zdb-R-decompression.patch +2348-Fix-zdb-E-segfault.patch +2349-Fix-zdb-ed-on-objset-for-exported-pool.patch diff -Nru zfs-linux-0.7.5/debian/zfs-zed.preinst zfs-linux-0.7.5/debian/zfs-zed.preinst --- zfs-linux-0.7.5/debian/zfs-zed.preinst 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/zfs-zed.preinst 2018-04-09 12:20:37.000000000 +0000 @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +case "$1" in + install|upgrade) + SRC=/etc/zfs/zed.d/zed-functions.sh + # + # If an existing zed-functions is a symlink then this + # needs removing as the script in newer ZFS releases + # is no longer symlink'd and we want to upgrade to + # the newer script. Silently purge this. + # + if [ -L $SRC ]; then + rm $SRC + fi + ;; +esac + +#DEBHELPER# + +exit 0 + diff -Nru zfs-linux-0.7.5/debian/zfsutils-linux.install zfs-linux-0.7.5/debian/zfsutils-linux.install --- zfs-linux-0.7.5/debian/zfsutils-linux.install 2017-12-18 14:56:01.000000000 +0000 +++ zfs-linux-0.7.5/debian/zfsutils-linux.install 2018-03-02 12:38:11.000000000 +0000 @@ -1,4 +1,5 @@ ../tree/zfsutils-linux/* / +lib/systemd/system/zfs-load-module.service lib/systemd/system/zfs-mount.service lib/systemd/system/zfs-share.service lib/systemd/system/zfs-import-scan.service