]> git.proxmox.com Git - zfsonlinux.git/commitdiff
add remaining zfs-0.7.6 changes as patches
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 21 Feb 2018 08:36:59 +0000 (09:36 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 21 Feb 2018 08:52:27 +0000 (09:52 +0100)
since Debian unstable has not been updated yet.

32 files changed:
zfs-patches/0006-Use-sbin-openrc-run-for-openrc-init-scripts.patch [new file with mode: 0644]
zfs-patches/0007-vdev_mirror-load-balancing-fixes.patch [new file with mode: 0644]
zfs-patches/0008-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch [new file with mode: 0644]
zfs-patches/0009-dmu_objset-release-bonus-buffer-in-failure-path.patch [new file with mode: 0644]
zfs-patches/0010-Fix-bug-in-distclean-which-removes-needed-files.patch [new file with mode: 0644]
zfs-patches/0011-Rewrite-of-function-fBytes-in-arc_summary.py.patch [new file with mode: 0644]
zfs-patches/0012-Minor-code-cleanup-in-arc_summary.py.patch [new file with mode: 0644]
zfs-patches/0013-Rewrite-fHits-in-arc_summary.py-with-SI-units.patch [new file with mode: 0644]
zfs-patches/0014-Add-documentation-strings-to-arc_summary.py.patch [new file with mode: 0644]
zfs-patches/0015-Sort-output-of-tunables-in-arc_summary.py.patch [new file with mode: 0644]
zfs-patches/0016-Fix-arc_summary.py-d-crash-with-Python3.patch [new file with mode: 0644]
zfs-patches/0017-Minor-code-cleanups-in-arc_python.py.patch [new file with mode: 0644]
zfs-patches/0018-Fix-data-on-evict_skips-in-arc_summary.py.patch [new file with mode: 0644]
zfs-patches/0019-Update-for-cppcheck-v1.80.patch [new file with mode: 0644]
zfs-patches/0020-OpenZFS-8794-cstyle-generates-warnings-with-recent-p.patch [new file with mode: 0644]
zfs-patches/0021-Handle-invalid-options-in-arc_summary.patch [new file with mode: 0644]
zfs-patches/0022-Handle-broken-pipes-in-arc_summary.patch [new file with mode: 0644]
zfs-patches/0023-Call-commit-callbacks-from-the-tail-of-the-list.patch [new file with mode: 0644]
zfs-patches/0024-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch [new file with mode: 0644]
zfs-patches/0025-zhack-fix-getopt-return-type.patch [new file with mode: 0644]
zfs-patches/0026-Revert-raidz_map-and-_col-structure-types.patch [new file with mode: 0644]
zfs-patches/0027-Use-zap_count-instead-of-cached-z_size-for-unlink.patch [new file with mode: 0644]
zfs-patches/0028-Fix-incompatibility-with-Reiser4-patched-kernels.patch [new file with mode: 0644]
zfs-patches/0029-Remove-l2arc_nocompress-from-zfs-module-parameters-5.patch [new file with mode: 0644]
zfs-patches/0030-Fix-shellcheck-v0.4.6-warnings.patch [new file with mode: 0644]
zfs-patches/0031-Fix-Debian-packaging-on-ARMv7-ARM64.patch [new file with mode: 0644]
zfs-patches/0032-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch [new file with mode: 0644]
zfs-patches/0033-Cleanup-zloop-working-directory-after-each-pass.patch [new file with mode: 0644]
zfs-patches/0034-Extend-zloop.sh-for-automated-testing.patch [new file with mode: 0644]
zfs-patches/0035-Fix-zfs-receive-o-when-used-with-e-d.patch [new file with mode: 0644]
zfs-patches/0036-Tag-zfs-0.7.6.patch [new file with mode: 0644]
zfs-patches/series

diff --git a/zfs-patches/0006-Use-sbin-openrc-run-for-openrc-init-scripts.patch b/zfs-patches/0006-Use-sbin-openrc-run-for-openrc-init-scripts.patch
new file mode 100644 (file)
index 0000000..4f37a7a
--- /dev/null
@@ -0,0 +1,36 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: BtbN <btbn@btbn.de>
+Date: Thu, 17 Aug 2017 00:51:51 +0200
+Subject: [PATCH] Use /sbin/openrc-run for openrc init scripts
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Using /sbin/runscript is deprecated and throws a QA warning
+when still used in init scripts.
+
+Reviewed-by: bunder2015 <omfgbunder@gmail.com>
+Signed-off-by: BtbN <btbn@btbn.de>
+Closes #6519
+(cherry picked from commit 6116bbd7446f06d913415bdecb208a78b31db0af)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ etc/init.d/Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/etc/init.d/Makefile.am b/etc/init.d/Makefile.am
+index 247db0aba..93432386a 100644
+--- a/etc/init.d/Makefile.am
++++ b/etc/init.d/Makefile.am
+@@ -22,7 +22,7 @@ $(init_SCRIPTS) $(initconf_SCRIPTS) $(initcommon_SCRIPTS):%:%.in
+               NFS_SRV=nfs; \
+         fi; \
+         if [ -e /sbin/openrc-run ]; then \
+-              SHELL=/sbin/runscript; \
++              SHELL=/sbin/openrc-run; \
+         else \
+               SHELL=/bin/sh; \
+         fi; \
+-- 
+2.14.2
+
diff --git a/zfs-patches/0007-vdev_mirror-load-balancing-fixes.patch b/zfs-patches/0007-vdev_mirror-load-balancing-fixes.patch
new file mode 100644 (file)
index 0000000..57dd6c4
--- /dev/null
@@ -0,0 +1,209 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Gvozden Neskovic <neskovic@gmail.com>
+Date: Fri, 4 Aug 2017 11:29:56 +0200
+Subject: [PATCH] vdev_mirror: load balancing fixes
+MIME-Version: 1.0
+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 <behlendorf1@llnl.gov>
+Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
+Closes #6461
+(cherry picked from commit 06acbbc429bfe7197e5fc3a49acfeef5c37b64c8)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ 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 0439e4b46..d230b4db4 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.14.2
+
diff --git a/zfs-patches/0008-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch b/zfs-patches/0008-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch
new file mode 100644 (file)
index 0000000..0bd8036
--- /dev/null
@@ -0,0 +1,58 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Chunwei Chen <tuxoko@gmail.com>
+Date: Mon, 21 Aug 2017 13:11:11 -0700
+Subject: [PATCH] Fix zfs_ioc_pool_sync should not use fnvlist
+MIME-Version: 1.0
+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 <behlendorf1@llnl.gov>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Reviewed-by: Alek Pinchuk <apinchuk@datto.com>
+Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
+Closes #6529
+(cherry picked from commit 7192ec7942f233e267bf631b433eb2414dc5f332)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ module/zfs/zfs_ioctl.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
+index d195eded7..f4f509a7e 100644
+--- a/module/zfs/zfs_ioctl.c
++++ b/module/zfs/zfs_ioctl.c
+@@ -5901,20 +5901,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);
+-- 
+2.14.2
+
diff --git a/zfs-patches/0009-dmu_objset-release-bonus-buffer-in-failure-path.patch b/zfs-patches/0009-dmu_objset-release-bonus-buffer-in-failure-path.patch
new file mode 100644 (file)
index 0000000..dabada3
--- /dev/null
@@ -0,0 +1,55 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Gvozden Neskovic <neskovic@gmail.com>
+Date: Wed, 30 Aug 2017 21:09:18 +0200
+Subject: [PATCH] dmu_objset: release bonus buffer in failure path
+MIME-Version: 1.0
+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 <mail@gmelikov.ru>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
+Closes #6575
+(cherry picked from commit a94447ddf3e8632e1e0476a3b1c985f41a0ae899)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ module/zfs/dmu_objset.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c
+index 9a7a6968d..3425d542f 100644
+--- a/module/zfs/dmu_objset.c
++++ b/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;
+               }
+-- 
+2.14.2
+
diff --git a/zfs-patches/0010-Fix-bug-in-distclean-which-removes-needed-files.patch b/zfs-patches/0010-Fix-bug-in-distclean-which-removes-needed-files.patch
new file mode 100644 (file)
index 0000000..77ff67c
--- /dev/null
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: David Quigley <dpquigl@users.noreply.github.com>
+Date: Wed, 13 Sep 2017 12:45:04 -0600
+Subject: [PATCH] Fix bug in distclean which removes needed files
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Running distclean removes the following files because of an error
+in Makefile.am
+
+deleted:    tests/zfs-tests/include/commands.cfg
+deleted:    tests/zfs-tests/include/libtest.shlib
+deleted:    tests/zfs-tests/include/math.shlib
+deleted:    tests/zfs-tests/include/properties.shlib
+deleted:    tests/zfs-tests/include/zpool_script.shlib
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: David Quigley <david.quigley@intel.com>
+Closes #6636
+(cherry picked from commit 53e5890cff8b7c21d34e1142ae717ae79af54da6)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ tests/zfs-tests/include/Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/zfs-tests/include/Makefile.am b/tests/zfs-tests/include/Makefile.am
+index 579e1356e..24633ccc3 100644
+--- a/tests/zfs-tests/include/Makefile.am
++++ b/tests/zfs-tests/include/Makefile.am
+@@ -10,4 +10,4 @@ dist_pkgdata_SCRIPTS = \
+ EXTRA_DIST=default.cfg.in
+ distclean-local::
+-      -$(RM) $(dist_pkgdata_SCRIPTS)
++      -$(RM) default.cfg
+-- 
+2.14.2
+
diff --git a/zfs-patches/0011-Rewrite-of-function-fBytes-in-arc_summary.py.patch b/zfs-patches/0011-Rewrite-of-function-fBytes-in-arc_summary.py.patch
new file mode 100644 (file)
index 0000000..c0fb96f
--- /dev/null
@@ -0,0 +1,98 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Wed, 25 Oct 2017 08:29:02 +0200
+Subject: [PATCH] Rewrite of function fBytes() in arc_summary.py
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Replace if-elif-else construction with shorter loop;
+remove unused parameter "Decimal"; centralize format
+string; add function documentation string; conform to
+PEP8.
+
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6784
+(cherry picked from commit 5dc25de668ce8c4e43ebd8c589202392297699b9)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 60 ++++++++++++++++++++++--------------------
+ 1 file changed, 31 insertions(+), 29 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index 93918a08f..e19278cef 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -88,36 +88,38 @@ def div2():
+     sys.stdout.write("\n")
+-def fBytes(Bytes=0, Decimal=2):
+-    kbytes = (2 ** 10)
+-    mbytes = (2 ** 20)
+-    gbytes = (2 ** 30)
+-    tbytes = (2 ** 40)
+-    pbytes = (2 ** 50)
+-    ebytes = (2 ** 60)
+-    zbytes = (2 ** 70)
+-    ybytes = (2 ** 80)
+-
+-    if Bytes >= ybytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / ybytes) + "\tYiB"
+-    elif Bytes >= zbytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / zbytes) + "\tZiB"
+-    elif Bytes >= ebytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / ebytes) + "\tEiB"
+-    elif Bytes >= pbytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / pbytes) + "\tPiB"
+-    elif Bytes >= tbytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / tbytes) + "\tTiB"
+-    elif Bytes >= gbytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / gbytes) + "\tGiB"
+-    elif Bytes >= mbytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / mbytes) + "\tMiB"
+-    elif Bytes >= kbytes:
+-        return str("%0." + str(Decimal) + "f") % (Bytes / kbytes) + "\tKiB"
+-    elif Bytes == 0:
+-        return str("%d" % 0) + "\tBytes"
++def fBytes(b=0):
++    """Return human-readable representation of a byte value in
++    powers of 2 (eg "KiB" for "kibibytes", etc) to two decimal
++    points. Values smaller than one KiB are returned without
++    decimal points.
++    """
++
++    prefixes = [
++        [2**80, "YiB"],   # yobibytes (yotta)
++        [2**70, "ZiB"],   # zebibytes (zetta)
++        [2**60, "EiB"],   # exbibytes (exa)
++        [2**50, "PiB"],   # pebibytes (peta)
++        [2**40, "TiB"],   # tebibytes (tera)
++        [2**30, "GiB"],   # gibibytes (giga)
++        [2**20, "MiB"],   # mebibytes (mega)
++        [2**10, "KiB"]]   # kibibytes (kilo)
++
++    if b >= 2**10:
++
++        for limit, unit in prefixes:
++
++            if b >= limit:
++                value = b / limit
++                break
++
++        result = "%0.2f\t%s" % (value, unit)
++
+     else:
+-        return str("%d" % Bytes) + "\tBytes"
++
++        result = "%d\tBytes" % b
++
++    return result
+ def fHits(Hits=0, Decimal=2):
+-- 
+2.14.2
+
diff --git a/zfs-patches/0012-Minor-code-cleanup-in-arc_summary.py.patch b/zfs-patches/0012-Minor-code-cleanup-in-arc_summary.py.patch
new file mode 100644 (file)
index 0000000..1ad2b55
--- /dev/null
@@ -0,0 +1,84 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Fri, 3 Nov 2017 23:43:53 +0100
+Subject: [PATCH] Minor code cleanup in arc_summary.py
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Simplify and inline single-use function div1(); inline twice-used
+function div2(); add function comment to zfs_header(); replace
+variable "unused" in get_Kstat() with "_" following convention.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6802
+(cherry picked from commit 03f638a8efe4f8e5901fc0e07fad5604e2550f22)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 25 ++++++++-----------------
+ 1 file changed, 8 insertions(+), 17 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index e19278cef..6b818edc7 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -63,7 +63,7 @@ def get_Kstat():
+         del kstats[0:2]
+         for kstat in kstats:
+             kstat = kstat.strip()
+-            name, unused, value = kstat.split()
++            name, _, value = kstat.split()
+             Kstat[namespace + name] = D(value)
+     Kstat = {}
+@@ -77,17 +77,6 @@ def get_Kstat():
+     return Kstat
+-def div1():
+-    sys.stdout.write("\n")
+-    for i in range(18):
+-        sys.stdout.write("%s" % "----")
+-    sys.stdout.write("\n")
+-
+-
+-def div2():
+-    sys.stdout.write("\n")
+-
+-
+ def fBytes(b=0):
+     """Return human-readable representation of a byte value in
+     powers of 2 (eg "KiB" for "kibibytes", etc) to two decimal
+@@ -908,11 +897,13 @@ unSub = [
+ def zfs_header():
+-    daydate = time.strftime("%a %b %d %H:%M:%S %Y")
++    """Print title string with date
++    """
++    daydate = time.strftime('%a %b %d %H:%M:%S %Y')
+-    div1()
+-    sys.stdout.write("ZFS Subsystem Report\t\t\t\t%s" % daydate)
+-    div2()
++    sys.stdout.write('\n'+'-'*72+'\n')
++    sys.stdout.write('ZFS Subsystem Report\t\t\t\t%s' % daydate)
++    sys.stdout.write('\n')
+ def usage():
+@@ -975,7 +966,7 @@ def main():
+     zfs_header()
+     for page in pages:
+         page(Kstat)
+-        div2()
++        sys.stdout.write("\n")
+ if __name__ == '__main__':
+-- 
+2.14.2
+
diff --git a/zfs-patches/0013-Rewrite-fHits-in-arc_summary.py-with-SI-units.patch b/zfs-patches/0013-Rewrite-fHits-in-arc_summary.py-with-SI-units.patch
new file mode 100644 (file)
index 0000000..3064b16
--- /dev/null
@@ -0,0 +1,101 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Sat, 4 Nov 2017 21:33:28 +0100
+Subject: [PATCH] Rewrite fHits() in arc_summary.py with SI units
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Complete rewrite of fHits(). Move units from non-standard English
+abbreviations to SI units, thereby avoiding confusion because of
+"long scale" and "short scale" numbers. Remove unused parameter
+"Decimal". Add function string. Aim to confirm to PEP8.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6815
+(cherry picked from commit 88e4e0d5dd1800add5191633d65797ce1c2eb4cf)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 62 ++++++++++++++++++++++--------------------
+ 1 file changed, 33 insertions(+), 29 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index 6b818edc7..cbb7d20bc 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -111,36 +111,40 @@ def fBytes(b=0):
+     return result
+-def fHits(Hits=0, Decimal=2):
+-    khits = (10 ** 3)
+-    mhits = (10 ** 6)
+-    bhits = (10 ** 9)
+-    thits = (10 ** 12)
+-    qhits = (10 ** 15)
+-    Qhits = (10 ** 18)
+-    shits = (10 ** 21)
+-    Shits = (10 ** 24)
+-
+-    if Hits >= Shits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / Shits) + "S"
+-    elif Hits >= shits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / shits) + "s"
+-    elif Hits >= Qhits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / Qhits) + "Q"
+-    elif Hits >= qhits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / qhits) + "q"
+-    elif Hits >= thits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / thits) + "t"
+-    elif Hits >= bhits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / bhits) + "b"
+-    elif Hits >= mhits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / mhits) + "m"
+-    elif Hits >= khits:
+-        return str("%0." + str(Decimal) + "f") % (Hits / khits) + "k"
+-    elif Hits == 0:
+-        return str("%d" % 0)
++def fHits(hits=0):
++    """Create a human-readable representation of the number of hits.
++    The single-letter symbols used are SI to avoid the confusion caused
++    by the different "short scale" and "long scale" representations in
++    English, which use the same words for different values. See
++    https://en.wikipedia.org/wiki/Names_of_large_numbers and
++    https://physics.nist.gov/cuu/Units/prefixes.html
++    """
++
++    numbers = [
++            [10**24, 'Y'],  # yotta (septillion)
++            [10**21, 'Z'],  # zetta (sextillion)
++            [10**18, 'E'],  # exa   (quintrillion)
++            [10**15, 'P'],  # peta  (quadrillion)
++            [10**12, 'T'],  # tera  (trillion)
++            [10**9, 'G'],   # giga  (billion)
++            [10**6, 'M'],   # mega  (million)
++            [10**3, 'k']]   # kilo  (thousand)
++
++    if hits >= 1000:
++
++        for limit, symbol in numbers:
++
++            if hits >= limit:
++                value = hits/limit
++                break
++
++        result = "%0.2f%s" % (value, symbol)
++
+     else:
+-        return str("%d" % Hits)
++
++        result = "%d" % hits
++
++    return result
+ def fPerc(lVal=0, rVal=0, Decimal=2):
+-- 
+2.14.2
+
diff --git a/zfs-patches/0014-Add-documentation-strings-to-arc_summary.py.patch b/zfs-patches/0014-Add-documentation-strings-to-arc_summary.py.patch
new file mode 100644 (file)
index 0000000..119ea60
--- /dev/null
@@ -0,0 +1,213 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Sun, 5 Nov 2017 22:11:37 +0100
+Subject: [PATCH] Add documentation strings to arc_summary.py
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Include docstrings (PEP8, PEP257) for module and all functions.
+Separately, remove outdated section in comment at start of
+module. Separately, remove unused global constant "usetunable".
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6818
+(cherry picked from commit 03955e348803a942048db8b32827f7ff6715c02e)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 56 +++++++++++++++++++++++++++++++-----------
+ 1 file changed, 42 insertions(+), 14 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index cbb7d20bc..f4968fb6a 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -31,34 +31,37 @@
+ #
+ # If you are having troubles when using this script from cron(8) please try
+ # adjusting your PATH before reporting problems.
+-#
+-# /usr/bin & /sbin
+-#
+-# Binaries used are:
+-#
+-# dc(1), kldstat(8), sed(1), sysctl(8) & vmstat(8)
+-#
+-# Binaries that I am working on phasing out are:
+-#
+-# dc(1) & sed(1)
++"""Print statistics on the ZFS Adjustable Replacement Cache (ARC)
++
++Provides basic information on the ARC, its efficiency, the L2ARC (if present),
++the Data Management Unit (DMU), Virtual Devices (VDEVs), and tunables. See the
++in-source documentation and code at
++https://github.com/zfsonlinux/zfs/blob/master/module/zfs/arc.c for details.
++"""
+ import sys
+ import time
+ import getopt
+ import re
++
+ from os import listdir
+ from subprocess import Popen, PIPE
+ from decimal import Decimal as D
+-
+-usetunable = True
+ show_tunable_descriptions = False
+ alternate_tunable_layout = False
+ kstat_pobj = re.compile("^([^:]+):\s+(.+)\s*$", flags=re.M)
+ def get_Kstat():
++    """Collect information on the ZFS subsystem from the /proc virtual
++    file system. The name "kstat" is a holdover from the Solaris utility
++    of the same name.
++    """
++
+     def load_proc_kstats(fn, namespace):
++        """Collect information on a specific subsystem of the ARC"""
++
+         kstats = [line.strip() for line in open(fn)]
+         del kstats[0:2]
+         for kstat in kstats:
+@@ -148,6 +151,8 @@ def fHits(hits=0):
+ def fPerc(lVal=0, rVal=0, Decimal=2):
++    """Calculate percentage value and return in human-readable format"""
++
+     if rVal > 0:
+         return str("%0." + str(Decimal) + "f") % (100 * (lVal / rVal)) + "%"
+     else:
+@@ -155,6 +160,7 @@ def fPerc(lVal=0, rVal=0, Decimal=2):
+ def get_arc_summary(Kstat):
++    """Collect general data on the ARC"""
+     output = {}
+     memory_throttle_count = Kstat[
+@@ -256,6 +262,8 @@ def get_arc_summary(Kstat):
+ def _arc_summary(Kstat):
++    """Print information on the ARC"""
++
+     # ARC Sizing
+     arc = get_arc_summary(Kstat)
+@@ -330,6 +338,8 @@ def _arc_summary(Kstat):
+ def get_arc_efficiency(Kstat):
++    """Collect information on the efficiency of the ARC"""
++
+     output = {}
+     arc_hits = Kstat["kstat.zfs.misc.arcstats.hits"]
+@@ -453,6 +463,8 @@ def get_arc_efficiency(Kstat):
+ def _arc_efficiency(Kstat):
++    """Print information on the efficiency of the ARC"""
++
+     arc = get_arc_efficiency(Kstat)
+     sys.stdout.write("ARC Total accesses:\t\t\t\t\t%s\n" %
+@@ -563,6 +575,8 @@ def _arc_efficiency(Kstat):
+ def get_l2arc_summary(Kstat):
++    """Collection information on the L2ARC"""
++
+     output = {}
+     l2_abort_lowmem = Kstat["kstat.zfs.misc.arcstats.l2_abort_lowmem"]
+@@ -657,6 +671,7 @@ def get_l2arc_summary(Kstat):
+ def _l2arc_summary(Kstat):
++    """Print information on the L2ARC"""
+     arc = get_l2arc_summary(Kstat)
+@@ -741,6 +756,8 @@ def _l2arc_summary(Kstat):
+ def get_dmu_summary(Kstat):
++    """Collect information on the DMU"""
++
+     output = {}
+     zfetch_hits = Kstat["kstat.zfs.misc.zfetchstats.hits"]
+@@ -766,6 +783,7 @@ def get_dmu_summary(Kstat):
+ def _dmu_summary(Kstat):
++    """Print information on the DMU"""
+     arc = get_dmu_summary(Kstat)
+@@ -787,6 +805,8 @@ def _dmu_summary(Kstat):
+ def get_vdev_summary(Kstat):
++    """Collect information on the VDEVs"""
++
+     output = {}
+     vdev_cache_delegations = \
+@@ -817,6 +837,8 @@ def get_vdev_summary(Kstat):
+ def _vdev_summary(Kstat):
++    """Print information on the VDEVs"""
++
+     arc = get_vdev_summary(Kstat)
+     if arc['vdev_cache_total'] > 0:
+@@ -836,6 +858,8 @@ def _vdev_summary(Kstat):
+ def _tunable_summary(Kstat):
++    """Print information on tunables"""
++
+     global show_tunable_descriptions
+     global alternate_tunable_layout
+@@ -901,8 +925,8 @@ unSub = [
+ def zfs_header():
+-    """Print title string with date
+-    """
++    """Print title string with date"""
++
+     daydate = time.strftime('%a %b %d %H:%M:%S %Y')
+     sys.stdout.write('\n'+'-'*72+'\n')
+@@ -911,6 +935,8 @@ def zfs_header():
+ def usage():
++    """Print usage information"""
++
+     sys.stdout.write("Usage: arc_summary.py [-h] [-a] [-d] [-p PAGE]\n\n")
+     sys.stdout.write("\t -h, --help           : "
+                      "Print this help message and exit\n")
+@@ -931,6 +957,8 @@ def usage():
+ def main():
++    """Main function"""
++
+     global show_tunable_descriptions
+     global alternate_tunable_layout
+-- 
+2.14.2
+
diff --git a/zfs-patches/0015-Sort-output-of-tunables-in-arc_summary.py.patch b/zfs-patches/0015-Sort-output-of-tunables-in-arc_summary.py.patch
new file mode 100644 (file)
index 0000000..c9c3481
--- /dev/null
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Tue, 7 Nov 2017 23:50:15 +0100
+Subject: [PATCH] Sort output of tunables in arc_summary.py
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Sort list of tunables printed by _tunable_summary()
+alphabetically
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6828
+(cherry picked from commit 904c03672beeadf4c74b919f55b5f78be882b7f8)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index f4968fb6a..4c513d63d 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -900,14 +900,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])
+-- 
+2.14.2
+
diff --git a/zfs-patches/0016-Fix-arc_summary.py-d-crash-with-Python3.patch b/zfs-patches/0016-Fix-arc_summary.py-d-crash-with-Python3.patch
new file mode 100644 (file)
index 0000000..fdab618
--- /dev/null
@@ -0,0 +1,93 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Sun, 12 Nov 2017 05:27:43 +0100
+Subject: [PATCH] Fix arc_summary.py -d crash with Python3
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Prevents arc_summary.py crashing when called with parameter -d or
+long form --description with Python3.
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6849
+Closes #6850
+(cherry picked from commit 7de8fb33a206fabb06261c0a5b79656d66efb32f)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index 4c513d63d..ec0468ecc 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -39,12 +39,12 @@ in-source documentation and code at
+ https://github.com/zfsonlinux/zfs/blob/master/module/zfs/arc.c for details.
+ """
+-import sys
+-import time
+ import getopt
++import os
+ import re
++import sys
++import time
+-from os import listdir
+ from subprocess import Popen, PIPE
+ from decimal import Decimal as D
+@@ -858,12 +858,12 @@ def _vdev_summary(Kstat):
+ def _tunable_summary(Kstat):
+-    """Print information on tunables"""
++    """Print information on tunables, including descriptions if requested"""
+     global show_tunable_descriptions
+     global alternate_tunable_layout
+-    names = listdir("/sys/module/zfs/parameters/")
++    names = os.listdir("/sys/module/zfs/parameters/")
+     values = {}
+     for name in names:
+@@ -874,13 +874,21 @@ def _tunable_summary(Kstat):
+     descriptions = {}
+     if show_tunable_descriptions:
++
++        command = ["/sbin/modinfo", "zfs", "-0"]
++
+         try:
+-            command = ["/sbin/modinfo", "zfs", "-0"]
+             p = Popen(command, stdin=PIPE, stdout=PIPE,
+                       stderr=PIPE, shell=False, close_fds=True)
+             p.wait()
+-            description_list = p.communicate()[0].strip().split('\0')
++            # By default, Python 2 returns a string as the first element of the
++            # tuple from p.communicate(), while Python 3 returns bytes which
++            # must be decoded first. The better way to do this would be with
++            # subprocess.run() or at least .check_output(), but this fails on
++            # CentOS 6 because of its old version of Python 2
++            desc = bytes.decode(p.communicate()[0])
++            description_list = desc.strip().split('\0')
+             if p.returncode == 0:
+                 for tunable in description_list:
+@@ -899,7 +907,7 @@ def _tunable_summary(Kstat):
+                              (sys.argv[0], command[0], e.strerror))
+             sys.stderr.write("Tunable descriptions will be disabled.\n")
+-    sys.stdout.write("ZFS Tunable:\n")
++    sys.stdout.write("ZFS Tunables:\n")
+     names.sort()
+     if alternate_tunable_layout:
+-- 
+2.14.2
+
diff --git a/zfs-patches/0017-Minor-code-cleanups-in-arc_python.py.patch b/zfs-patches/0017-Minor-code-cleanups-in-arc_python.py.patch
new file mode 100644 (file)
index 0000000..e85f7e7
--- /dev/null
@@ -0,0 +1,78 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Wed, 15 Nov 2017 19:28:11 +0100
+Subject: [PATCH] Minor code cleanups in arc_python.py
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Remove unused library re and associated variable kstat_pobj. Add note
+to documentation at start of program about required support for old
+versions of Python. Change variable "format" (which is a built-in
+function) to "fmt".
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6869
+(cherry picked from commit d486dee89e54560536a759f3c5fb1eb8b07efc3f)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index ec0468ecc..c9a2c5d03 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -31,6 +31,10 @@
+ #
+ # If you are having troubles when using this script from cron(8) please try
+ # adjusting your PATH before reporting problems.
++#
++# Note some of this code uses older code (eg getopt instead of argparse,
++# subprocess.Popen() instead of subprocess.run()) because we need to support
++# some very old versions of Python.
+ """Print statistics on the ZFS Adjustable Replacement Cache (ARC)
+ Provides basic information on the ARC, its efficiency, the L2ARC (if present),
+@@ -41,7 +45,6 @@ https://github.com/zfsonlinux/zfs/blob/master/module/zfs/arc.c for details.
+ import getopt
+ import os
+-import re
+ import sys
+ import time
+@@ -50,7 +53,6 @@ from decimal import Decimal as D
+ show_tunable_descriptions = False
+ alternate_tunable_layout = False
+-kstat_pobj = re.compile("^([^:]+):\s+(.+)\s*$", flags=re.M)
+ def get_Kstat():
+@@ -911,9 +913,9 @@ def _tunable_summary(Kstat):
+     names.sort()
+     if alternate_tunable_layout:
+-        format = "\t%s=%s\n"
++        fmt = "\t%s=%s\n"
+     else:
+-        format = "\t%-50s%s\n"
++        fmt = "\t%-50s%s\n"
+     for name in names:
+@@ -923,7 +925,7 @@ def _tunable_summary(Kstat):
+         if show_tunable_descriptions and name in descriptions:
+             sys.stdout.write("\t# %s\n" % descriptions[name])
+-        sys.stdout.write(format % (name, values[name]))
++        sys.stdout.write(fmt % (name, values[name]))
+ unSub = [
+-- 
+2.14.2
+
diff --git a/zfs-patches/0018-Fix-data-on-evict_skips-in-arc_summary.py.patch b/zfs-patches/0018-Fix-data-on-evict_skips-in-arc_summary.py.patch
new file mode 100644 (file)
index 0000000..1538bb5
--- /dev/null
@@ -0,0 +1,55 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "Scot W. Stevenson" <scot.stevenson@gmail.com>
+Date: Sat, 18 Nov 2017 23:07:04 +0100
+Subject: [PATCH] Fix data on evict_skips in arc_summary.py
+MIME-Version: 1.0
+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 <behlendorf1@llnl.gov>
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Scot W. Stevenson <scot.stevenson@gmail.com>
+Closes #6882
+Closes #6883
+(cherry picked from commit 7a8bef39838cdb9f996bf400add5a8583fe10e87)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index c9a2c5d03..5da81347c 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -179,12 +179,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"]
+@@ -281,7 +282,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
+-- 
+2.14.2
+
diff --git a/zfs-patches/0019-Update-for-cppcheck-v1.80.patch b/zfs-patches/0019-Update-for-cppcheck-v1.80.patch
new file mode 100644 (file)
index 0000000..ad332dd
--- /dev/null
@@ -0,0 +1,280 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Sat, 18 Nov 2017 14:08:00 -0800
+Subject: [PATCH] Update for cppcheck v1.80
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Resolve new warnings and errors from cppcheck v1.80.
+
+* [lib/libshare/libshare.c:543]: (warning)
+  Possible null pointer dereference: protocol
+* [lib/libzfs/libzfs_dataset.c:2323]: (warning)
+  Possible null pointer dereference: srctype
+* [lib/libzfs/libzfs_import.c:318]: (error)
+  Uninitialized variable: link
+* [module/zfs/abd.c:353]: (error) Uninitialized variable: sg
+* [module/zfs/abd.c:353]: (error) Uninitialized variable: i
+* [module/zfs/abd.c:385]: (error) Uninitialized variable: sg
+* [module/zfs/abd.c:385]: (error) Uninitialized variable: i
+* [module/zfs/abd.c:553]: (error) Uninitialized variable: i
+* [module/zfs/abd.c:553]: (error) Uninitialized variable: sg
+* [module/zfs/abd.c:763]: (error) Uninitialized variable: i
+* [module/zfs/abd.c:763]: (error) Uninitialized variable: sg
+* [module/zfs/abd.c:305]: (error) Uninitialized variable: tmp_page
+* [module/zfs/zpl_xattr.c:342]: (warning)
+   Possible null pointer dereference: value
+* [module/zfs/zvol.c:208]: (error) Uninitialized variable: p
+
+Convert the following suppression to inline.
+
+* [module/zfs/zfs_vnops.c:840]: (error)
+  Possible null pointer dereference: aiov
+
+Exclude HAVE_UIO_ZEROCOPY and HAVE_DNLC from analysis since
+these macro's will never be defined until this functionality
+is implemented.
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #6879
+(cherry picked from commit aebc5df418cb52cc2ec9fa6c9c147ca3b048bc49)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ Makefile.am                 |  6 +++---
+ lib/libshare/libshare.c     | 37 ++++---------------------------------
+ lib/libzfs/libzfs_dataset.c |  4 +++-
+ lib/libzfs/libzfs_import.c  |  2 +-
+ module/zfs/abd.c            | 18 +++++++++---------
+ module/zfs/zfs_vnops.c      |  1 +
+ module/zfs/zpl_xattr.c      |  2 +-
+ module/zfs/zvol.c           |  2 +-
+ 8 files changed, 23 insertions(+), 49 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index e46ac2dbe..508d3f40e 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -65,10 +65,10 @@ lint: cppcheck paxcheck
+ cppcheck:
+       @if type cppcheck > /dev/null 2>&1; then \
+-              cppcheck --quiet --force --error-exitcode=2 \
++              cppcheck --quiet --force --error-exitcode=2 --inline-suppr \
+                       --suppressions-list=.github/suppressions.txt \
+-                      -UHAVE_SSE2 -UHAVE_AVX512F \
+-                      ${top_srcdir}; \
++                      -UHAVE_SSE2 -UHAVE_AVX512F -UHAVE_UIO_ZEROCOPY \
++                      -UHAVE_DNLC ${top_srcdir}; \
+       fi
+ paxcheck:
+diff --git a/lib/libshare/libshare.c b/lib/libshare/libshare.c
+index aa565ca82..022df016f 100644
+--- a/lib/libshare/libshare.c
++++ b/lib/libshare/libshare.c
+@@ -493,20 +493,10 @@ int
+ sa_enable_share(sa_share_t share, char *protocol)
+ {
+       sa_share_impl_t impl_share = (sa_share_impl_t)share;
+-      int rc, ret;
+-      boolean_t found_protocol;
++      int rc, ret = SA_OK;
++      boolean_t found_protocol = B_FALSE;
+       sa_fstype_t *fstype;
+-#ifdef DEBUG
+-      fprintf(stderr, "sa_enable_share: share->sharepath=%s, protocol=%s\n",
+-          impl_share->sharepath, protocol);
+-#endif
+-
+-      assert(impl_share->handle != NULL);
+-
+-      ret = SA_OK;
+-      found_protocol = B_FALSE;
+-
+       fstype = fstypes;
+       while (fstype != NULL) {
+               if (protocol == NULL || strcmp(fstype->name, protocol) == 0) {
+@@ -534,18 +524,10 @@ int
+ sa_disable_share(sa_share_t share, char *protocol)
+ {
+       sa_share_impl_t impl_share = (sa_share_impl_t)share;
+-      int rc, ret;
+-      boolean_t found_protocol;
++      int rc, ret = SA_OK;
++      boolean_t found_protocol = B_FALSE;
+       sa_fstype_t *fstype;
+-#ifdef DEBUG
+-      fprintf(stderr, "sa_disable_share: share->sharepath=%s, protocol=%s\n",
+-          impl_share->sharepath, protocol);
+-#endif
+-
+-      ret = SA_OK;
+-      found_protocol = B_FALSE;
+-
+       fstype = fstypes;
+       while (fstype != NULL) {
+               if (protocol == NULL || strcmp(fstype->name, protocol) == 0) {
+@@ -696,11 +678,6 @@ sa_parse_legacy_options(sa_group_t group, char *options, char *proto)
+ {
+       sa_fstype_t *fstype;
+-#ifdef DEBUG
+-      fprintf(stderr, "sa_parse_legacy_options: options=%s, proto=%s\n",
+-          options, proto);
+-#endif
+-
+       fstype = fstypes;
+       while (fstype != NULL) {
+               if (strcmp(fstype->name, proto) != 0) {
+@@ -787,12 +764,6 @@ sa_zfs_process_share(sa_handle_t handle, sa_group_t group, sa_share_t share,
+       sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
+       sa_share_impl_t impl_share = (sa_share_impl_t)share;
+-#ifdef DEBUG
+-      fprintf(stderr, "sa_zfs_process_share: mountpoint=%s, proto=%s, "
+-          "shareopts=%s, sourcestr=%s, dataset=%s\n", mountpoint, proto,
+-          shareopts, sourcestr, dataset);
+-#endif
+-
+       return (process_share(impl_handle, impl_share, mountpoint, NULL,
+           proto, shareopts, NULL, dataset, B_FALSE));
+ }
+diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c
+index d6e85024d..b65dbc826 100644
+--- a/lib/libzfs/libzfs_dataset.c
++++ b/lib/libzfs/libzfs_dataset.c
+@@ -2244,8 +2244,10 @@ static void
+ get_source(zfs_handle_t *zhp, zprop_source_t *srctype, char *source,
+     char *statbuf, size_t statlen)
+ {
+-      if (statbuf == NULL || *srctype == ZPROP_SRC_TEMPORARY)
++      if (statbuf == NULL ||
++          srctype == NULL || *srctype == ZPROP_SRC_TEMPORARY) {
+               return;
++      }
+       if (source == NULL) {
+               *srctype = ZPROP_SRC_NONE;
+diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
+index 8b5222475..39c067293 100644
+--- a/lib/libzfs/libzfs_import.c
++++ b/lib/libzfs/libzfs_import.c
+@@ -309,7 +309,7 @@ zpool_label_disk_wait(char *path, int timeout_ms)
+               dev = udev_device_new_from_subsystem_sysname(udev,
+                   "block", sysname);
+               if ((dev != NULL) && udev_device_is_ready(dev)) {
+-                      struct udev_list_entry *links, *link;
++                      struct udev_list_entry *links, *link = NULL;
+                       ret = 0;
+                       links = udev_device_get_devlinks_list_entry(dev);
+diff --git a/module/zfs/abd.c b/module/zfs/abd.c
+index 765ac7fb7..138b041c8 100644
+--- a/module/zfs/abd.c
++++ b/module/zfs/abd.c
+@@ -250,7 +250,7 @@ abd_alloc_pages(abd_t *abd, size_t size)
+       struct list_head pages;
+       struct sg_table table;
+       struct scatterlist *sg;
+-      struct page *page, *tmp_page;
++      struct page *page, *tmp_page = NULL;
+       gfp_t gfp = __GFP_NOWARN | GFP_NOIO;
+       gfp_t gfp_comp = (gfp | __GFP_NORETRY | __GFP_COMP) & ~__GFP_RECLAIM;
+       int max_order = MIN(zfs_abd_scatter_max_order, MAX_ORDER - 1);
+@@ -334,12 +334,12 @@ abd_alloc_pages(abd_t *abd, size_t size)
+ static void
+ abd_alloc_pages(abd_t *abd, size_t size)
+ {
+-      struct scatterlist *sg;
++      struct scatterlist *sg = NULL;
+       struct sg_table table;
+       struct page *page;
+       gfp_t gfp = __GFP_NOWARN | GFP_NOIO;
+       int nr_pages = abd_chunkcnt_for_bytes(size);
+-      int i;
++      int i = 0;
+       while (sg_alloc_table(&table, nr_pages, gfp)) {
+               ABDSTAT_BUMP(abdstat_scatter_sg_table_retry);
+@@ -370,11 +370,11 @@ abd_alloc_pages(abd_t *abd, size_t size)
+ static void
+ abd_free_pages(abd_t *abd)
+ {
+-      struct scatterlist *sg;
++      struct scatterlist *sg = NULL;
+       struct sg_table table;
+       struct page *page;
+       int nr_pages = ABD_SCATTER(abd).abd_nents;
+-      int order, i;
++      int order, i = 0;
+       if (abd->abd_flags & ABD_FLAG_MULTI_ZONE)
+               ABDSTAT_BUMPDOWN(abdstat_scatter_page_multi_zone);
+@@ -543,8 +543,8 @@ abd_verify(abd_t *abd)
+               ASSERT3P(abd->abd_u.abd_linear.abd_buf, !=, NULL);
+       } else {
+               size_t n;
+-              int i;
+-              struct scatterlist *sg;
++              int i = 0;
++              struct scatterlist *sg = NULL;
+               ASSERT3U(ABD_SCATTER(abd).abd_nents, >, 0);
+               ASSERT3U(ABD_SCATTER(abd).abd_offset, <,
+@@ -749,8 +749,8 @@ abd_get_offset_impl(abd_t *sabd, size_t off, size_t size)
+               abd->abd_u.abd_linear.abd_buf =
+                   (char *)sabd->abd_u.abd_linear.abd_buf + off;
+       } else {
+-              int i;
+-              struct scatterlist *sg;
++              int i = 0;
++              struct scatterlist *sg = NULL;
+               size_t new_offset = sabd->abd_u.abd_scatter.abd_offset + off;
+               abd = abd_alloc_struct();
+diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
+index 6a1dab5c9..6f6ce79db 100644
+--- a/module/zfs/zfs_vnops.c
++++ b/module/zfs/zfs_vnops.c
+@@ -836,6 +836,7 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
+                           aiov->iov_base != abuf->b_data)) {
+                               ASSERT(xuio);
+                               dmu_write(zfsvfs->z_os, zp->z_id, woff,
++                                  /* cppcheck-suppress nullPointer */
+                                   aiov->iov_len, aiov->iov_base, tx);
+                               dmu_return_arcbuf(abuf);
+                               xuio_stat_wbuf_copied();
+diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c
+index 0c626b122..ebb6e7be2 100644
+--- a/module/zfs/zpl_xattr.c
++++ b/module/zfs/zpl_xattr.c
+@@ -333,7 +333,7 @@ zpl_xattr_get_sa(struct inode *ip, const char *name, void *value, size_t size)
+       if (error)
+               return (error);
+-      if (!size)
++      if (size == 0 || value == NULL)
+               return (nv_size);
+       if (size < nv_size)
+diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
+index 5293f95fb..aac494209 100644
+--- a/module/zfs/zvol.c
++++ b/module/zfs/zvol.c
+@@ -202,7 +202,7 @@ static zvol_state_t *
+ zvol_find_by_name_hash(const char *name, uint64_t hash, int mode)
+ {
+       zvol_state_t *zv;
+-      struct hlist_node *p;
++      struct hlist_node *p = NULL;
+       mutex_enter(&zvol_state_lock);
+       hlist_for_each(p, ZVOL_HT_HEAD(hash)) {
+-- 
+2.14.2
+
diff --git a/zfs-patches/0020-OpenZFS-8794-cstyle-generates-warnings-with-recent-p.patch b/zfs-patches/0020-OpenZFS-8794-cstyle-generates-warnings-with-recent-p.patch
new file mode 100644 (file)
index 0000000..cc04e9a
--- /dev/null
@@ -0,0 +1,157 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Dominik Hassler <hadfl@omniosce.org>
+Date: Thu, 9 Nov 2017 15:22:07 +0100
+Subject: [PATCH] OpenZFS 8794 - cstyle generates warnings with recent perl
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Authored by: Dominik Hassler <hadfl@omniosce.org>
+Reviewed by: Andy Fiddaman <andy@omniosce.org>
+Reviewed by: Igor Kozhukhov <igor@dilos.org>
+Reviewed by: Toomas Soome <tsoome@me.com>
+Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
+Approved by: Dan McDonald <danmcd@joyent.com>
+Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+
+OpenZFS-issue: https://www.illumos.org/issues/8794
+OpenZFS-commit: https://github.com/openzfs/openzfs/commit/578f67364c
+Closes #6973
+
+(cherry picked from commit d27a40d28f96cfd9f7b32337306f64935ee749bc)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ scripts/cstyle.pl | 36 ++++++++++++++++++------------------
+ 1 file changed, 18 insertions(+), 18 deletions(-)
+
+diff --git a/scripts/cstyle.pl b/scripts/cstyle.pl
+index 73c708c0b..00b33dddf 100755
+--- a/scripts/cstyle.pl
++++ b/scripts/cstyle.pl
+@@ -383,7 +383,7 @@ line: while (<$filehandle>) {
+       # is this the beginning or ending of a function?
+       # (not if "struct foo\n{\n")
+-      if (/^{$/ && $prev =~ /\)\s*(const\s*)?(\/\*.*\*\/\s*)?\\?$/) {
++      if (/^\{$/ && $prev =~ /\)\s*(const\s*)?(\/\*.*\*\/\s*)?\\?$/) {
+               $in_function = 1;
+               $in_declaration = 1;
+               $in_function_header = 0;
+@@ -391,7 +391,7 @@ line: while (<$filehandle>) {
+               $prev = $line;
+               next line;
+       }
+-      if (/^}\s*(\/\*.*\*\/\s*)*$/) {
++      if (/^\}\s*(\/\*.*\*\/\s*)*$/) {
+               if ($prev =~ /^\s*return\s*;/) {
+                       err_prev("unneeded return at end of function");
+               }
+@@ -401,7 +401,7 @@ line: while (<$filehandle>) {
+               next line;
+       }
+       if ($in_function_header && ! /^    (\w|\.)/ ) {
+-              if (/^{}$/ # empty functions
++              if (/^\{\}$/ # empty functions
+               || /;/ #run function with multiline arguments
+               || /#/ #preprocessor commands
+               || /^[^\s\\]*\(.*\)$/ #functions without ; at the end
+@@ -431,7 +431,7 @@ line: while (<$filehandle>) {
+                       $function_header_full_indent = 1;
+               }
+       }
+-      if ($in_function_header && /^{$/) {
++      if ($in_function_header && /^\{$/) {
+               $in_function_header = 0;
+               $function_header_full_indent = 0;
+               $in_function = 1;
+@@ -440,7 +440,7 @@ line: while (<$filehandle>) {
+               $in_function_header = 0;
+               $function_header_full_indent = 0;
+       }
+-      if ($in_function_header && /{$/ ) {
++      if ($in_function_header && /\{$/ ) {
+               if ($picky) {
+                       err("opening brace on same line as function header");
+               }
+@@ -670,14 +670,14 @@ line: while (<$filehandle>) {
+       if (/\S\{/ && !/\{\{/) {
+               err("missing space before left brace");
+       }
+-      if ($in_function && /^\s+{/ &&
++      if ($in_function && /^\s+\{/ &&
+           ($prev =~ /\)\s*$/ || $prev =~ /\bstruct\s+\w+$/)) {
+               err("left brace starting a line");
+       }
+-      if (/}(else|while)/) {
++      if (/\}(else|while)/) {
+               err("missing space after right brace");
+       }
+-      if (/}\s\s+(else|while)/) {
++      if (/\}\s\s+(else|while)/) {
+               err("extra space after right brace");
+       }
+       if (/\b_VOID\b|\bVOID\b|\bSTATIC\b/) {
+@@ -730,18 +730,18 @@ line: while (<$filehandle>) {
+       if ($heuristic) {
+               # cannot check this everywhere due to "struct {\n...\n} foo;"
+               if ($in_function && !$in_declaration &&
+-                  /}./ && !/}\s+=/ && !/{.*}[;,]$/ && !/}(\s|\ 1)*$/ &&
+-                  !/} (else|while)/ && !/}}/) {
++                  /\}./ && !/\}\s+=/ && !/\{.*\}[;,]$/ && !/\}(\s|\ 1)*$/ &&
++                  !/\} (else|while)/ && !/\}\}/) {
+                       err("possible bad text following right brace");
+               }
+               # cannot check this because sub-blocks in
+               # the middle of code are ok
+-              if ($in_function && /^\s+{/) {
++              if ($in_function && /^\s+\{/) {
+                       err("possible left brace starting a line");
+               }
+       }
+       if (/^\s*else\W/) {
+-              if ($prev =~ /^\s*}$/) {
++              if ($prev =~ /^\s*\}$/) {
+                       err_prefix($prev,
+                           "else and right brace should be on same line");
+               }
+@@ -827,8 +827,8 @@ process_indent($)
+       # skip over enumerations, array definitions, initializers, etc.
+       if ($cont_off <= 0 && !/^\s*$special/ &&
+-          (/(?:(?:\b(?:enum|struct|union)\s*[^\{]*)|(?:\s+=\s*)){/ ||
+-          (/^\s*{/ && $prev =~ /=\s*(?:\/\*.*\*\/\s*)*$/))) {
++          (/(?:(?:\b(?:enum|struct|union)\s*[^\{]*)|(?:\s+=\s*))\{/ ||
++          (/^\s*\{/ && $prev =~ /=\s*(?:\/\*.*\*\/\s*)*$/))) {
+               $cont_in = 0;
+               $cont_off = tr/{/{/ - tr/}/}/;
+               return;
+@@ -851,14 +851,14 @@ process_indent($)
+               return          if (/^\s*\}?$/);
+               return          if (/^\s*\}?\s*else\s*\{?$/);
+               return          if (/^\s*do\s*\{?$/);
+-              return          if (/{$/);
+-              return          if (/}[,;]?$/);
++              return          if (/\{$/);
++              return          if (/\}[,;]?$/);
+               # Allow macros on their own lines
+               return          if (/^\s*[A-Z_][A-Z_0-9]*$/);
+               # cases we don't deal with, generally non-kosher
+-              if (/{/) {
++              if (/\{/) {
+                       err("stuff after {");
+                       return;
+               }
+@@ -927,7 +927,7 @@ process_indent($)
+                       #
+                       next            if (@cont_paren != 0);
+                       if ($cont_special) {
+-                              if ($rest =~ /^\s*{?$/) {
++                              if ($rest =~ /^\s*\{?$/) {
+                                       $cont_in = 0;
+                                       last;
+                               }
+-- 
+2.14.2
+
diff --git a/zfs-patches/0021-Handle-invalid-options-in-arc_summary.patch b/zfs-patches/0021-Handle-invalid-options-in-arc_summary.patch
new file mode 100644 (file)
index 0000000..e353de6
--- /dev/null
@@ -0,0 +1,137 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: LOLi <loli10K@users.noreply.github.com>
+Date: Tue, 19 Dec 2017 22:02:40 +0100
+Subject: [PATCH] Handle invalid options in arc_summary
+MIME-Version: 1.0
+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 <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
+Closes #6983
+(cherry picked from commit 9a6c57845a431f55fd617c38e180b26215f0ca6f)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ .../tests/functional/cli_user/misc/Makefile.am     |  1 +
+ cmd/arc_summary/arc_summary.py                     | 16 ++++++---
+ tests/runfiles/linux.run                           |  2 +-
+ .../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
+
+diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am
+index cf7502c27..75a3d0886 100644
+--- a/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am
++++ b/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
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index 5da81347c..2472f87ea 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -977,9 +977,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:
+@@ -991,7 +997,7 @@ def main():
+             args['p'] = arg
+         if opt in ('-h', '--help'):
+             usage()
+-            sys.exit()
++            sys.exit(0)
+     Kstat = get_Kstat()
+@@ -1006,7 +1012,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
+diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
+index 10bd110a6..f872c0cbf 100644
+--- a/tests/runfiles/linux.run
++++ b/tests/runfiles/linux.run
+@@ -366,7 +366,7 @@ tests = ['zdb_001_neg', 'zfs_001_neg', 'zfs_allow_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']
+diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh
+new file mode 100755
+index 000000000..e63552feb
+--- /dev/null
++++ b/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"
+-- 
+2.14.2
+
diff --git a/zfs-patches/0022-Handle-broken-pipes-in-arc_summary.patch b/zfs-patches/0022-Handle-broken-pipes-in-arc_summary.patch
new file mode 100644 (file)
index 0000000..dcd0412
--- /dev/null
@@ -0,0 +1,70 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Giuseppe Di Natale <dinatale2@users.noreply.github.com>
+Date: Tue, 19 Dec 2017 13:19:24 -0800
+Subject: [PATCH] Handle broken pipes in arc_summary
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Using a command similar to 'arc_summary.py | head' causes
+a broken pipe exception. Gracefully exit in the case of a
+broken pipe in arc_summary.py.
+
+Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
+Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
+Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Closes #6965
+Closes #6969
+(cherry picked from commit c2aacf20872856559972a27f7c3f9b4a6fe10cd2)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/arc_summary/arc_summary.py                              | 13 +++++++++++++
+ .../tests/functional/cli_user/misc/arc_summary_001_pos.ksh  |  3 +++
+ 2 files changed, 16 insertions(+)
+
+diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py
+index 2472f87ea..f6dbb9bfb 100755
+--- a/cmd/arc_summary/arc_summary.py
++++ b/cmd/arc_summary/arc_summary.py
+@@ -47,6 +47,7 @@ import getopt
+ import os
+ import sys
+ import time
++import errno
+ from subprocess import Popen, PIPE
+ from decimal import Decimal as D
+@@ -55,6 +56,18 @@ show_tunable_descriptions = False
+ alternate_tunable_layout = False
++def handle_Exception(ex_cls, ex, tb):
++    if ex is IOError:
++        if ex.errno == errno.EPIPE:
++            sys.exit()
++
++    if ex is KeyboardInterrupt:
++        sys.exit()
++
++
++sys.excepthook = handle_Exception
++
++
+ def get_Kstat():
+     """Collect information on the ZFS subsystem from the /proc virtual
+     file system. The name "kstat" is a holdover from the Solaris utility
+diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh
+index 67c11c8ab..6653b9c1a 100755
+--- a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh
++++ b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh
+@@ -37,4 +37,7 @@ while [[ $i -lt ${#args[*]} ]]; do
+         ((i = i + 1))
+ done
++log_must eval "arc_summary.py | head > /dev/null"
++log_must eval "arc_summary.py | head -1 > /dev/null"
++
+ log_pass "arc_summary.py generates output and doesn't return an error code"
+-- 
+2.14.2
+
diff --git a/zfs-patches/0023-Call-commit-callbacks-from-the-tail-of-the-list.patch b/zfs-patches/0023-Call-commit-callbacks-from-the-tail-of-the-list.patch
new file mode 100644 (file)
index 0000000..47d246e
--- /dev/null
@@ -0,0 +1,86 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: lidongyang <gnaygnodil@gmail.com>
+Date: Sat, 23 Dec 2017 05:19:51 +1100
+Subject: [PATCH] Call commit callbacks from the tail of the list
+MIME-Version: 1.0
+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 <faaland1@llnl.gov>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
+Closes #6986
+(cherry picked from commit 8d82a19def540bba43c8c7597142ff53f7a0b7e5)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ include/sys/dmu.h    | 5 +++++
+ include/sys/dmu_tx.h | 4 ----
+ module/zfs/dmu_tx.c  | 2 +-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/include/sys/dmu.h b/include/sys/dmu.h
+index d24615262..bcdf7d646 100644
+--- a/include/sys/dmu.h
++++ b/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
+diff --git a/include/sys/dmu_tx.h b/include/sys/dmu_tx.h
+index f16e1e858..d82a79310 100644
+--- a/include/sys/dmu_tx.h
++++ b/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.
+  */
+diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c
+index 097fa774a..c3cc03a69 100644
+--- a/module/zfs/dmu_tx.c
++++ b/module/zfs/dmu_tx.c
+@@ -1200,7 +1200,7 @@ dmu_tx_do_callbacks(list_t *cb_list, int error)
+ {
+       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));
+-- 
+2.14.2
+
diff --git a/zfs-patches/0024-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch b/zfs-patches/0024-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch
new file mode 100644 (file)
index 0000000..a3347d5
--- /dev/null
@@ -0,0 +1,302 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: LOLi <loli10K@users.noreply.github.com>
+Date: Thu, 28 Dec 2017 19:15:32 +0100
+Subject: [PATCH] Fix 'zpool add' handling of nested interior VDEVs
+MIME-Version: 1.0
+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 <mail@gmelikov.ru>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
+Closes #6678
+Closes #6996
+(cherry picked from commit a8fa31b50b958306cd39c21e8518f776ee59f1b6)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ .../functional/cli_root/zpool_add/Makefile.am      |   3 +-
+ cmd/zpool/zpool_vdev.c                             |   6 +-
+ tests/runfiles/linux.run                           |   2 +-
+ tests/zfs-tests/include/libtest.shlib              |  66 +++++++++++-
+ .../zpool_add/add_nested_replacing_spare.ksh       | 111 +++++++++++++++++++++
+ 5 files changed, 182 insertions(+), 6 deletions(-)
+ create mode 100755 tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh
+
+diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am
+index 4b6b533fe..062028299 100644
+--- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am
++++ b/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
+diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c
+index 97faa5f9b..fd6bd9e76 100644
+--- a/cmd/zpool/zpool_vdev.c
++++ b/cmd/zpool/zpool_vdev.c
+@@ -860,9 +860,11 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
+                               /*
+                                * 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;
+diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
+index f872c0cbf..303c27529 100644
+--- a/tests/runfiles/linux.run
++++ b/tests/runfiles/linux.run
+@@ -228,7 +228,7 @@ tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos',
+     '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]
+diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
+index 345d1903d..86f172a6d 100644
+--- a/tests/zfs-tests/include/libtest.shlib
++++ b/tests/zfs-tests/include/libtest.shlib
+@@ -1988,6 +1988,31 @@ function check_hotspare_state # pool disk state{inuse,avail}
+       return 0
+ }
++#
++# Wait until a hotspare transitions to a given state or times out.
++#
++# Return 0 when  pool/disk matches expected state, 1 on timeout.
++#
++function wait_hotspare_state # pool disk state timeout
++{
++      typeset pool=$1
++      typeset disk=${2#$/DEV_DSKDIR/}
++      typeset state=$3
++      typeset timeout=${4:-60}
++      typeset -i i=0
++
++      while [[ $i -lt $timeout ]]; do
++              if check_hotspare_state $pool $disk $state; then
++                      return 0
++              fi
++
++              i=$((i+1))
++              sleep 1
++      done
++
++      return 1
++}
++
+ #
+ # Verify a given slog disk is inuse or avail
+ #
+@@ -2026,6 +2051,31 @@ function check_vdev_state # pool disk state{online,offline,unavail}
+       return 0
+ }
++#
++# Wait until a vdev transitions to a given state or times out.
++#
++# Return 0 when  pool/disk matches expected state, 1 on timeout.
++#
++function wait_vdev_state # pool disk state timeout
++{
++      typeset pool=$1
++      typeset disk=${2#$/DEV_DSKDIR/}
++      typeset state=$3
++      typeset timeout=${4:-60}
++      typeset -i i=0
++
++      while [[ $i -lt $timeout ]]; do
++              if check_vdev_state $pool $disk $state; then
++                      return 0
++              fi
++
++              i=$((i+1))
++              sleep 1
++      done
++
++      return 1
++}
++
+ #
+ # Check the output of 'zpool status -v <pool>',
+ # and to see if the content of <token> contain the <keyword> specified.
+@@ -3394,13 +3444,25 @@ function zed_stop
+       if [[ -f ${ZEDLET_DIR}/zed.pid ]]; then
+               zedpid=$(cat ${ZEDLET_DIR}/zed.pid)
+               kill $zedpid
+-              wait $zedpid
++              while ps -p $zedpid > /dev/null; do
++                      sleep 1
++              done
+               rm -f ${ZEDLET_DIR}/zed.pid
+       fi
+-
+       return 0
+ }
++#
++# Drain all zevents
++#
++function zed_events_drain
++{
++       while [ $(zpool events -H | wc -l) -ne 0 ]; do
++             sleep 1
++             zpool events -c >/dev/null
++       done
++}
++
+ #
+ # Check is provided device is being active used as a swap device.
+ #
+diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh
+new file mode 100755
+index 000000000..b38079852
+--- /dev/null
++++ b/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 <ezomori.nozomu@gmail.com>. 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"
+-- 
+2.14.2
+
diff --git a/zfs-patches/0025-zhack-fix-getopt-return-type.patch b/zfs-patches/0025-zhack-fix-getopt-return-type.patch
new file mode 100644 (file)
index 0000000..6016c30
--- /dev/null
@@ -0,0 +1,56 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Nathaniel Wesley Filardo
+ <VP331RHQ115POU58JFRLKB7OPA0L18E3@cmx.ietfng.org>
+Date: Tue, 9 Jan 2018 14:14:45 -0500
+Subject: [PATCH] zhack: fix getopt return type
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This fixes zhack's command processing on ARM.  On ARM char
+is unsigned, and so, in promotion to an int, it will never
+compare equal to -1.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Nathaniel Wesley Filardo <nwf@cs.jhu.edu>
+Closes #7016
+(cherry picked from commit a2ee6568c604fb455d6ee7fa51728fb2bc700dac)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/zhack/zhack.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cmd/zhack/zhack.c b/cmd/zhack/zhack.c
+index 70f88fc69..e15af8f4e 100644
+--- a/cmd/zhack/zhack.c
++++ b/cmd/zhack/zhack.c
+@@ -268,7 +268,7 @@ zhack_feature_enable_sync(void *arg, dmu_tx_t *tx)
+ static void
+ zhack_do_feature_enable(int argc, char **argv)
+ {
+-      char c;
++      int c;
+       char *desc, *target;
+       spa_t *spa;
+       objset_t *mos;
+@@ -363,7 +363,7 @@ feature_decr_sync(void *arg, dmu_tx_t *tx)
+ static void
+ zhack_do_feature_ref(int argc, char **argv)
+ {
+-      char c;
++      int c;
+       char *target;
+       boolean_t decr = B_FALSE;
+       spa_t *spa;
+@@ -483,7 +483,7 @@ main(int argc, char **argv)
+       char *path[MAX_NUM_PATHS];
+       const char *subcommand;
+       int rv = 0;
+-      char c;
++      int c;
+       g_importargs.path = path;
+-- 
+2.14.2
+
diff --git a/zfs-patches/0026-Revert-raidz_map-and-_col-structure-types.patch b/zfs-patches/0026-Revert-raidz_map-and-_col-structure-types.patch
new file mode 100644 (file)
index 0000000..165e23b
--- /dev/null
@@ -0,0 +1,83 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Nathaniel Wesley Filardo
+ <VP331RHQ115POU58JFRLKB7OPA0L18E3@cmx.ietfng.org>
+Date: Tue, 9 Jan 2018 17:46:52 -0500
+Subject: [PATCH] Revert raidz_map and _col structure types
+MIME-Version: 1.0
+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 <behlendorf1@llnl.gov>
+Reviewed-by: Gvozden Neskovic <neskovic@gmail.com>
+Signed-off-by: Nathaniel Wesley Filardo <nwf@cs.jhu.edu>
+Closes #6981
+Closes #7023
+(cherry picked from commit 9fb09f79e573d377b2b041f620eac703be3acc3f)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ 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.14.2
+
diff --git a/zfs-patches/0027-Use-zap_count-instead-of-cached-z_size-for-unlink.patch b/zfs-patches/0027-Use-zap_count-instead-of-cached-z_size-for-unlink.patch
new file mode 100644 (file)
index 0000000..ef96dcc
--- /dev/null
@@ -0,0 +1,63 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alex Zhuravlev <alexey.zhuravlev@intel.com>
+Date: Mon, 8 Jan 2018 10:57:47 -0800
+Subject: [PATCH] Use zap_count instead of cached z_size for unlink
+MIME-Version: 1.0
+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 <faaland1@llnl.gov>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #7019
+(cherry picked from commit 129e3e8dc32673809d1d3523a0e773567e281a4a)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ 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.14.2
+
diff --git a/zfs-patches/0028-Fix-incompatibility-with-Reiser4-patched-kernels.patch b/zfs-patches/0028-Fix-incompatibility-with-Reiser4-patched-kernels.patch
new file mode 100644 (file)
index 0000000..d4e7cd6
--- /dev/null
@@ -0,0 +1,70 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Richard Yao <ryao@gentoo.org>
+Date: Tue, 9 Jan 2018 19:18:19 -0500
+Subject: [PATCH] Fix incompatibility with Reiser4 patched kernels
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+In ZFSOnLinux, our sources and build system are self contained such that
+we do not need to make changes to the Linux kernel sources. Reiser4 on
+the other hand exists solely as a kernel tree patch and opts to make
+changes to the kernel rather than adapt to it. After Linux 4.1 made a
+VFS change that replaced new_sync_read with do_sync_read, Reiser4's
+maintainer decided to modify the kernel VFS to export the old function.
+This caused our autotools check to misidentify the kernel API as
+predating Linux 4.1 on kernels that have been patched with Reiser4
+support, which breaks our build.
+
+Reiser4 really should be patched to stop doing this, but lets modify our
+check to be more strict to help the affected users of both filesystems.
+
+Also, we were not checking the types of arguments and return value of
+new_sync_read() and new_sync_write() . Lets fix that too.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Signed-off-by: Richard Yao <ryao@gentoo.org>
+Closes #6241
+Closes #7021
+(cherry picked from commit ecc8af18125728bf03841ceb48b057e15d96362c)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ config/kernel-vfs-rw-iterate.m4 | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/config/kernel-vfs-rw-iterate.m4 b/config/kernel-vfs-rw-iterate.m4
+index 9f8fe6559..ace54f707 100644
+--- a/config/kernel-vfs-rw-iterate.m4
++++ b/config/kernel-vfs-rw-iterate.m4
+@@ -32,15 +32,23 @@ dnl #
+ dnl # Linux 4.1 API
+ dnl #
+ AC_DEFUN([ZFS_AC_KERNEL_NEW_SYNC_READ],
+-      [AC_MSG_CHECKING([whether new_sync_read() is available])
++      [AC_MSG_CHECKING([whether new_sync_read/write() are available])
+       ZFS_LINUX_TRY_COMPILE([
+               #include <linux/fs.h>
+       ],[
+-              new_sync_read(NULL, NULL, 0, NULL);
++                      ssize_t ret __attribute__ ((unused));
++                      struct file *filp = NULL;
++                      char __user *rbuf = NULL;
++                      const char __user *wbuf = NULL;
++                      size_t len = 0;
++                      loff_t ppos;
++
++                      ret = new_sync_read(filp, rbuf, len, &ppos);
++                      ret = new_sync_write(filp, wbuf, len, &ppos);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_NEW_SYNC_READ, 1,
+-                      [new_sync_read() is available])
++                      [new_sync_read()/new_sync_write() are available])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+-- 
+2.14.2
+
diff --git a/zfs-patches/0029-Remove-l2arc_nocompress-from-zfs-module-parameters-5.patch b/zfs-patches/0029-Remove-l2arc_nocompress-from-zfs-module-parameters-5.patch
new file mode 100644 (file)
index 0000000..164a222
--- /dev/null
@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: DeHackEd <DeHackEd@users.noreply.github.com>
+Date: Tue, 16 Jan 2018 13:18:08 -0500
+Subject: [PATCH] Remove l2arc_nocompress from zfs-module-parameters(5)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Parameter was removed in d3c2ae1c0806
+(OpenZFS 6950 - ARC should cache compressed data)
+
+Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: DHE <git@dehacked.net>
+Closes #7043
+(cherry picked from commit 2a7b736dcea1abad62cceb36947e757b98c0e330)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ man/man5/zfs-module-parameters.5 | 11 -----------
+ 1 file changed, 11 deletions(-)
+
+diff --git a/man/man5/zfs-module-parameters.5 b/man/man5/zfs-module-parameters.5
+index 4c957029d..19e6becfd 100644
+--- a/man/man5/zfs-module-parameters.5
++++ b/man/man5/zfs-module-parameters.5
+@@ -96,17 +96,6 @@ successfully compressed before writing. A value of 100 disables this feature.
+ Default value: \fB200\fR.
+ .RE
+-.sp
+-.ne 2
+-.na
+-\fBl2arc_nocompress\fR (int)
+-.ad
+-.RS 12n
+-Skip compressing L2ARC buffers
+-.sp
+-Use \fB1\fR for yes and \fB0\fR for no (default).
+-.RE
+-
+ .sp
+ .ne 2
+ .na
+-- 
+2.14.2
+
diff --git a/zfs-patches/0030-Fix-shellcheck-v0.4.6-warnings.patch b/zfs-patches/0030-Fix-shellcheck-v0.4.6-warnings.patch
new file mode 100644 (file)
index 0000000..3c4ed07
--- /dev/null
@@ -0,0 +1,93 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Wed, 17 Jan 2018 10:17:16 -0800
+Subject: [PATCH] Fix shellcheck v0.4.6 warnings
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Resolve new warnings reported after upgrading to shellcheck
+version 0.4.6.  This patch contains no functional changes.
+
+* egrep is non-standard and deprecated. Use grep -E instead. [SC2196]
+* Check exit code directly with e.g. 'if mycmd;', not indirectly
+  with $?.  [SC2181]  Suppressed.
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #7040
+(cherry picked from commit 9d1a39cec6ba98c33cf0e358d2bac35dc1552d01)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ cmd/zed/zed.d/zed-functions.sh                         | 4 ++--
+ scripts/zloop.sh                                       | 6 +++---
+ tests/zfs-tests/tests/functional/acl/acl_common.kshlib | 2 +-
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh
+index b7de5104f..ed6a95914 100644
+--- a/cmd/zed/zed.d/zed-functions.sh
++++ b/cmd/zed/zed.d/zed-functions.sh
+@@ -397,7 +397,7 @@ zed_rate_limit()
+     zed_lock "${lockfile}" "${lockfile_fd}"
+     time_now="$(date +%s)"
+-    time_prev="$(egrep "^[0-9]+;${tag}\$" "${statefile}" 2>/dev/null \
++    time_prev="$(grep -E "^[0-9]+;${tag}\$" "${statefile}" 2>/dev/null \
+         | tail -1 | cut -d\; -f1)"
+     if [ -n "${time_prev}" ] \
+@@ -406,7 +406,7 @@ zed_rate_limit()
+     else
+         umask_bak="$(umask)"
+         umask 077
+-        egrep -v "^[0-9]+;${tag}\$" "${statefile}" 2>/dev/null \
++        grep -E -v "^[0-9]+;${tag}\$" "${statefile}" 2>/dev/null \
+             > "${statefile}.$$"
+         echo "${time_now};${tag}" >> "${statefile}.$$"
+         mv -f "${statefile}.$$" "${statefile}"
+diff --git a/scripts/zloop.sh b/scripts/zloop.sh
+index 854c2048a..03e825059 100755
+--- a/scripts/zloop.sh
++++ b/scripts/zloop.sh
+@@ -70,12 +70,12 @@ function or_die
+ # core file helpers
+ origcorepattern="$(cat /proc/sys/kernel/core_pattern)"
+-coreglob="$(egrep -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
++coreglob="$(grep -E -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
+ if [[ $coreglob = "*" ]]; then
+         echo "Setting core file pattern..."
+         echo "core" > /proc/sys/kernel/core_pattern
+-        coreglob="$(egrep -o '^([^|%[:space:]]*)' \
++        coreglob="$(grep -E -o '^([^|%[:space:]]*)' \
+             /proc/sys/kernel/core_pattern)*"
+ fi
+@@ -235,7 +235,7 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
+       echo "$desc" >>ztest.out
+       $cmd >>ztest.out 2>&1
+       ztrc=$?
+-      egrep '===|WARNING' ztest.out >>ztest.history
++      grep -E '===|WARNING' ztest.out >>ztest.history
+       $ZDB -U "$workdir/zpool.cache" -DD ztest >>ztest.ddt
+       store_core
+diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
+index def25d390..75bb82455 100644
+--- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
++++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
+@@ -410,7 +410,7 @@ function get_xattr #<obj>
+       fi
+       for xattr in `runat $obj ls | \
+-              /usr/xpg4/bin/egrep -v -e SUNWattr_ro -e SUNWattr_rw` ; do
++              grep -E -v -e SUNWattr_ro -e SUNWattr_rw` ; do
+               runat $obj sum $xattr
+       done
+ }
+-- 
+2.14.2
+
diff --git a/zfs-patches/0031-Fix-Debian-packaging-on-ARMv7-ARM64.patch b/zfs-patches/0031-Fix-Debian-packaging-on-ARMv7-ARM64.patch
new file mode 100644 (file)
index 0000000..c6729f4
--- /dev/null
@@ -0,0 +1,72 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: LOLi <loli10K@users.noreply.github.com>
+Date: Thu, 18 Jan 2018 19:15:41 +0100
+Subject: [PATCH] Fix Debian packaging on ARMv7/ARM64
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When building packages on Debian-based systems specify the target
+architecture used by 'alien' to convert .rpm packages into .deb: this
+avoids detecting an incorrect value which results in the following
+errors:
+
+<package>.aarch64.rpm is for architecture aarch64 ; the package cannot be built on this system
+<package>.armv7l.rpm is for architecture armel ; the package cannot be built on this system
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
+Closes #7046
+Closes #7058
+(cherry picked from commit 5b8ec2cf391f2b7fb2b3a254b4ec9cf9664a2502)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ config/deb.am | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/config/deb.am b/config/deb.am
+index 98e98e45f..1b51f9316 100644
+--- a/config/deb.am
++++ b/config/deb.am
+@@ -18,8 +18,9 @@ deb-kmod: deb-local rpm-kmod
+       name=${PACKAGE}; \
+       version=${VERSION}-${RELEASE}; \
+       arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \
++      debarch=`$(DPKG) --print-architecture`; \
+       pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \
+-      fakeroot $(ALIEN) --bump=0 --scripts --to-deb $$pkg1; \
++      fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \
+       $(RM) $$pkg1
+@@ -27,14 +28,16 @@ deb-dkms: deb-local rpm-dkms
+       name=${PACKAGE}; \
+       version=${VERSION}-${RELEASE}; \
+       arch=`$(RPM) -qp $${name}-dkms-$${version}.src.rpm --qf %{arch} | tail -1`; \
++      debarch=`$(DPKG) --print-architecture`; \
+       pkg1=$${name}-dkms-$${version}.$${arch}.rpm; \
+-      fakeroot $(ALIEN) --bump=0 --scripts --to-deb $$pkg1; \
++      fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \
+       $(RM) $$pkg1
+ deb-utils: deb-local rpm-utils
+       name=${PACKAGE}; \
+       version=${VERSION}-${RELEASE}; \
+       arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
++      debarch=`$(DPKG) --print-architecture`; \
+       pkg1=$${name}-$${version}.$${arch}.rpm; \
+       pkg2=libnvpair1-$${version}.$${arch}.rpm; \
+       pkg3=libuutil1-$${version}.$${arch}.rpm; \
+@@ -57,7 +60,7 @@ deb-utils: deb-local rpm-utils
+ ## which should NOT be mixed with the alien-generated debs created here
+       chmod +x $${path_prepend}/dh_shlibdeps; \
+       env PATH=$${path_prepend}:$${PATH} \
+-      fakeroot $(ALIEN) --bump=0 --scripts --to-deb \
++      fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch \
+           $$pkg1 $$pkg2 $$pkg3 $$pkg4 $$pkg5 $$pkg6 $$pkg7 \
+           $$pkg8 $$pkg9; \
+       $(RM) $${path_prepend}/dh_shlibdeps; \
+-- 
+2.14.2
+
diff --git a/zfs-patches/0032-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch b/zfs-patches/0032-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch
new file mode 100644 (file)
index 0000000..f441536
--- /dev/null
@@ -0,0 +1,86 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alexander Motin <mav@FreeBSD.org>
+Date: Mon, 20 Nov 2017 19:56:01 +0200
+Subject: [PATCH] OpenZFS 8835 - Speculative prefetch in ZFS not working for
+ misaligned reads
+MIME-Version: 1.0
+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 <mav@FreeBSD.org>
+Approved by: Gordon Ross <gwr@nexenta.com>
+Reviewed by: Matthew Ahrens <mahrens@delphix.com>
+Reviewed by: Allan Jude <allanjude@freebsd.org>
+Reviewed by: Gvozden Neskovic <neskovic@gmail.com>
+Reviewed by: George Melikov <mail@gmelikov.ru>
+Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
+
+OpenZFS-issue: https://www.illumos.org/issues/8835
+OpenZFS-commit: https://github.com/openzfs/openzfs/commit/aab6dd482a
+Closes #7062
+
+(cherry picked from commit 701ebd014af3a0c7485056d8c96ecfb379867fd8)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ module/zfs/dmu_zfetch.c | 24 +++++++++++++++++++-----
+ 1 file changed, 19 insertions(+), 5 deletions(-)
+
+diff --git a/module/zfs/dmu_zfetch.c b/module/zfs/dmu_zfetch.c
+index 1bf5c4e34..e72e9ef9c 100644
+--- a/module/zfs/dmu_zfetch.c
++++ b/module/zfs/dmu_zfetch.c
+@@ -228,19 +228,33 @@ dmu_zfetch(zfetch_t *zf, uint64_t blkid, uint64_t nblks, boolean_t fetch_data)
+       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);
+               }
+       }
+-- 
+2.14.2
+
diff --git a/zfs-patches/0033-Cleanup-zloop-working-directory-after-each-pass.patch b/zfs-patches/0033-Cleanup-zloop-working-directory-after-each-pass.patch
new file mode 100644 (file)
index 0000000..700e98a
--- /dev/null
@@ -0,0 +1,67 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Don Brady <dev.fs.zfs@gmail.com>
+Date: Thu, 21 Sep 2017 11:17:56 -0600
+Subject: [PATCH] Cleanup zloop working directory after each pass
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Reviewed-by: George Melikov <mail@gmelikov.ru>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Reviewed by: John Kennedy <jwk404@gmail.com>
+Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
+Signed-off-by: Don Brady <don.brady@delphix.com>
+Issue #6595
+Closes #6663
+(cherry picked from commit d1630dda5857175bad0ac7f6e142ae299606d88a)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ scripts/zloop.sh | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/scripts/zloop.sh b/scripts/zloop.sh
+index 03e825059..f0af87553 100755
+--- a/scripts/zloop.sh
++++ b/scripts/zloop.sh
+@@ -101,6 +101,7 @@ function store_core
+ {
+       core="$(core_file)"
+       if [[ $ztrc -ne 0 ]] || [[ -f "$core" ]]; then
++              df -h "$workdir" >>ztest.out
+               coreid=$(date "+zloop-%y%m%d-%H%M%S")
+               foundcrashes=$((foundcrashes + 1))
+@@ -150,7 +151,8 @@ function store_core
+ # parse arguments
+ # expected format: zloop [-t timeout] [-c coredir] [-- extra ztest args]
+ coredir=$DEFAULTCOREDIR
+-workdir=$DEFAULTWORKDIR
++basedir=$DEFAULTWORKDIR
++rundir="zloop-run"
+ timeout=0
+ size="512m"
+ while getopts ":ht:s:c:f:" opt; do
+@@ -158,7 +160,7 @@ while getopts ":ht:s:c:f:" opt; do
+               t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
+               s ) [[ $OPTARG ]] && size=$OPTARG ;;
+               c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
+-              f ) [[ $OPTARG ]] && workdir=$(readlink -f "$OPTARG") ;;
++              f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
+               h ) usage
+                   exit 2
+                   ;;
+@@ -202,6 +204,11 @@ curtime=$starttime
+ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
+       zopt="-VVVVV"
++      # start each run with an empty directory
++      workdir="$basedir/$rundir"
++      or_die rm -rf "$workdir"
++      or_die mkdir "$workdir"
++
+       # switch between common arrangements & fully randomized
+       if [[ $((RANDOM % 2)) -eq 0 ]]; then
+               mirrors=2
+-- 
+2.14.2
+
diff --git a/zfs-patches/0034-Extend-zloop.sh-for-automated-testing.patch b/zfs-patches/0034-Extend-zloop.sh-for-automated-testing.patch
new file mode 100644 (file)
index 0000000..a65f83d
--- /dev/null
@@ -0,0 +1,165 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Mon, 22 Jan 2018 12:48:39 -0800
+Subject: [PATCH] Extend zloop.sh for automated testing
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+In order to debug issues encountered by ztest during automated
+testing it's important that as much debugging information as
+possible by dumped at the time of the failure.  The following
+changes extend the zloop.sh script in order to make it easier
+to integrate with buildbot.
+
+* Add the `-m <maximum cores>` option to zloop.sh to place a
+  limit of the number of core dumps generated.  By default, the
+  existing behavior is maintained and no limit is set.
+
+* Add the `-l` option to create a 'ztest.core.N' symlink in the
+  current directory to the core directory. This functionality
+  is provided primarily for buildbot which expects log files to
+  have well known names.
+
+* Rename 'ztest.ddt' to 'ztest.zdb' and extend it to dump
+  additional basic information on failure for latter analysis.
+
+Reviewed-by: Tim Chase <tim@chase2k.com>
+Reviewed by: Thomas Caputi <tcaputi@datto.com>
+Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #6999
+
+Conflicts:
+       scripts/zloop.sh
+(cherry picked from commit 137b3e6cff5552c5b0e137008fd274ad9a6f7a0d)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ scripts/zloop.sh | 42 ++++++++++++++++++++++++++++++++----------
+ 1 file changed, 32 insertions(+), 10 deletions(-)
+
+diff --git a/scripts/zloop.sh b/scripts/zloop.sh
+index f0af87553..f39e91ef9 100755
+--- a/scripts/zloop.sh
++++ b/scripts/zloop.sh
+@@ -52,6 +52,8 @@ function usage
+           "    -s  Size of vdev devices.\n" \
+           "    -f  Specify working directory for ztest vdev files.\n" \
+           "    -c  Specify a core dump directory to use.\n" \
++          "    -m  Max number of core dumps to allow before exiting.\n" \
++          "    -l  Create 'ztest.core.N' symlink to core directory.\n" \
+           "    -h  Print this help message.\n" \
+           "" >&2
+ }
+@@ -105,14 +107,24 @@ function store_core
+               coreid=$(date "+zloop-%y%m%d-%H%M%S")
+               foundcrashes=$((foundcrashes + 1))
++              # zdb debugging
++              zdbcmd="$ZDB -U "$workdir/zpool.cache" -dddMmDDG ztest"
++              zdbdebug=$($zdbcmd 2>&1)
++              echo -e "$zdbcmd\n" >>ztest.zdb
++              echo "$zdbdebug" >>ztest.zdb
++
+               dest=$coredir/$coreid
+               or_die mkdir -p "$dest"
+               or_die mkdir -p "$dest/vdev"
++              if [[ $symlink -ne 0 ]]; then
++                      or_die ln -sf "$dest" ztest.core.$foundcrashes
++              fi
++
+               echo "*** ztest crash found - moving logs to $dest"
+               or_die mv ztest.history "$dest/"
+-              or_die mv ztest.ddt "$dest/"
++              or_die mv ztest.zdb "$dest/"
+               or_die mv ztest.out "$dest/"
+               or_die mv "$workdir/ztest*" "$dest/vdev/"
+               or_die mv "$workdir/zpool.cache" "$dest/vdev/"
+@@ -120,7 +132,7 @@ function store_core
+               # check for core
+               if [[ -f "$core" ]]; then
+                       coreprog=$(core_prog "$core")
+-                      corestatus=$($GDB --batch --quiet \
++                      coredebug=$($GDB --batch --quiet \
+                           -ex "set print thread-events off" \
+                           -ex "printf \"*\n* Backtrace \n*\n\"" \
+                           -ex "bt" \
+@@ -132,19 +144,25 @@ function store_core
+                           -ex "thread apply all bt" \
+                           -ex "printf \"*\n* Backtraces (full) \n*\n\"" \
+                           -ex "thread apply all bt full" \
+-                          -ex "quit" "$coreprog" "$core" | grep -v "New LWP")
++                          -ex "quit" "$coreprog" "$core" 2>&1 | \
++                          grep -v "New LWP")
+                       # Dump core + logs to stored directory
+-                      echo "$corestatus" >>"$dest/status"
++                      echo "$coredebug" >>"$dest/ztest.gdb"
+                       or_die mv "$core" "$dest/"
+                       # Record info in cores logfile
+                       echo "*** core @ $coredir/$coreid/$core:" | \
+                           tee -a ztest.cores
+-                      echo "$corestatus" | tee -a ztest.cores
+-                      echo "" | tee -a ztest.cores
+               fi
+-              echo "continuing..."
++
++              if [[ $coremax -gt 0 ]] &&
++                 [[ $foundcrashes -ge $coremax ]]; then
++                      echo "exiting... max $coremax allowed cores"
++                      exit 1
++              else
++                      echo "continuing..."
++              fi
+       fi
+ }
+@@ -155,12 +173,16 @@ basedir=$DEFAULTWORKDIR
+ rundir="zloop-run"
+ timeout=0
+ size="512m"
+-while getopts ":ht:s:c:f:" opt; do
++coremax=0
++symlink=0
++while getopts ":ht:m:s:c:f:l" opt; do
+       case $opt in
+               t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
++              m ) [[ $OPTARG -gt 0 ]] && coremax=$OPTARG ;;
+               s ) [[ $OPTARG ]] && size=$OPTARG ;;
+               c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
+               f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
++              l ) symlink=1 ;;
+               h ) usage
+                   exit 2
+                   ;;
+@@ -178,6 +200,7 @@ ulimit -c unlimited
+ if [[ -f "$(core_file)" ]]; then
+       echo -n "There's a core dump here you might want to look at first... "
+       core_file
++      echo
+       exit 1
+ fi
+@@ -192,7 +215,7 @@ if [[ ! -w $coredir ]]; then
+ fi
+ or_die rm -f ztest.history
+-or_die rm -f ztest.ddt
++or_die rm -f ztest.zdb
+ or_die rm -f ztest.cores
+ ztrc=0                # ztest return value
+@@ -243,7 +266,6 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
+       $cmd >>ztest.out 2>&1
+       ztrc=$?
+       grep -E '===|WARNING' ztest.out >>ztest.history
+-      $ZDB -U "$workdir/zpool.cache" -DD ztest >>ztest.ddt
+       store_core
+-- 
+2.14.2
+
diff --git a/zfs-patches/0035-Fix-zfs-receive-o-when-used-with-e-d.patch b/zfs-patches/0035-Fix-zfs-receive-o-when-used-with-e-d.patch
new file mode 100644 (file)
index 0000000..ae9dae4
--- /dev/null
@@ -0,0 +1,101 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: LOLi <loli10K@users.noreply.github.com>
+Date: Wed, 31 Jan 2018 00:54:33 +0100
+Subject: [PATCH] Fix 'zfs receive -o' when used with '-e|-d'
+MIME-Version: 1.0
+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 <hutter2@llnl.gov>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
+Closes #7088
+
+Requires-spl: refs/pull/679/head
+(cherry picked from commit 2f62fdd6447b1a765dfea3cc5bf9e35dc0901aff)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ lib/libzfs/libzfs_sendrecv.c                       |  5 +--
+ .../zfs_receive/receive-o-x_props_override.ksh     | 36 ++++++++++++++++++++++
+ 2 files changed, 39 insertions(+), 2 deletions(-)
+
+diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
+index db8079fb3..ec190022f 100644
+--- a/lib/libzfs/libzfs_sendrecv.c
++++ b/lib/libzfs/libzfs_sendrecv.c
+@@ -3252,7 +3252,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
+       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, int infd, const char *tosnap,
+               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) {
+diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh
+index 7137fe278..e4e69851f 100755
+--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/receive-o-x_props_override.ksh
++++ b/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 type filesystem -"
+ 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."
+-- 
+2.14.2
+
diff --git a/zfs-patches/0036-Tag-zfs-0.7.6.patch b/zfs-patches/0036-Tag-zfs-0.7.6.patch
new file mode 100644 (file)
index 0000000..7c48216
--- /dev/null
@@ -0,0 +1,63 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2@llnl.gov>
+Date: Thu, 1 Feb 2018 10:02:58 -0800
+Subject: [PATCH] Tag zfs-0.7.6
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+META file and changelog updated.
+
+Signed-off-by: Tony Hutter <hutter2@llnl.gov>
+(cherry picked from commit e3b28e16ceaf59d7f550a149f863b2cfe67cf4ad)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ rpm/generic/zfs-kmod.spec.in | 3 +++
+ rpm/generic/zfs.spec.in      | 3 +++
+ META                         | 2 +-
+ 3 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/rpm/generic/zfs-kmod.spec.in b/rpm/generic/zfs-kmod.spec.in
+index f4c92b998..cb23b0a8f 100644
+--- a/rpm/generic/zfs-kmod.spec.in
++++ b/rpm/generic/zfs-kmod.spec.in
+@@ -191,6 +191,9 @@ chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/*
+ rm -rf $RPM_BUILD_ROOT
+ %changelog
++* Thu Feb 01 2018 Tony Hutter <hutter2@llnl.gov> - 0.7.6-1
++- Released 0.7.6-1, detailed release notes are available at:
++- https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.6
+ * Mon Dec 18 2017 Tony Hutter <hutter2@llnl.gov> - 0.7.5-1
+ - Released 0.7.5-1, detailed release notes are available at:
+ - https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.5
+diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in
+index afa45268a..8df57fa46 100644
+--- a/rpm/generic/zfs.spec.in
++++ b/rpm/generic/zfs.spec.in
+@@ -333,6 +333,9 @@ exit 0
+ %endif
+ %changelog
++* Thu Feb 01 2018 Tony Hutter <hutter2@llnl.gov> - 0.7.6-1
++- Released 0.7.6-1, detailed release notes are available at:
++- https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.6
+ * Mon Dec 18 2017 Tony Hutter <hutter2@llnl.gov> - 0.7.5-1
+ - Released 0.7.5-1, detailed release notes are available at:
+ - https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.5
+diff --git a/META b/META
+index 8bcb520b6..1f4686df7 100644
+--- a/META
++++ b/META
+@@ -1,7 +1,7 @@
+ Meta:         1
+ Name:         zfs
+ Branch:       1.0
+-Version:      0.7.5
++Version:      0.7.6
+ Release:      1
+ Release-Tags: relext
+ License:      CDDL
+-- 
+2.14.2
+
index 2a1a557d73129c6f064bb64c0d46686998a4bcf9..65ad06a60805674cf6eb869cbf8492893218b232 100644 (file)
@@ -3,3 +3,34 @@
 0003-Use-user-namespaces-for-FSETID-policy-check.patch
 0004-Fix-ARC-hit-rate.patch
 0005-always-load-ZFS-module-on-boot.patch
+0006-Use-sbin-openrc-run-for-openrc-init-scripts.patch
+0007-vdev_mirror-load-balancing-fixes.patch
+0008-Fix-zfs_ioc_pool_sync-should-not-use-fnvlist.patch
+0009-dmu_objset-release-bonus-buffer-in-failure-path.patch
+0010-Fix-bug-in-distclean-which-removes-needed-files.patch
+0011-Rewrite-of-function-fBytes-in-arc_summary.py.patch
+0012-Minor-code-cleanup-in-arc_summary.py.patch
+0013-Rewrite-fHits-in-arc_summary.py-with-SI-units.patch
+0014-Add-documentation-strings-to-arc_summary.py.patch
+0015-Sort-output-of-tunables-in-arc_summary.py.patch
+0016-Fix-arc_summary.py-d-crash-with-Python3.patch
+0017-Minor-code-cleanups-in-arc_python.py.patch
+0018-Fix-data-on-evict_skips-in-arc_summary.py.patch
+0019-Update-for-cppcheck-v1.80.patch
+0020-OpenZFS-8794-cstyle-generates-warnings-with-recent-p.patch
+0021-Handle-invalid-options-in-arc_summary.patch
+0022-Handle-broken-pipes-in-arc_summary.patch
+0023-Call-commit-callbacks-from-the-tail-of-the-list.patch
+0024-Fix-zpool-add-handling-of-nested-interior-VDEVs.patch
+0025-zhack-fix-getopt-return-type.patch
+0026-Revert-raidz_map-and-_col-structure-types.patch
+0027-Use-zap_count-instead-of-cached-z_size-for-unlink.patch
+0028-Fix-incompatibility-with-Reiser4-patched-kernels.patch
+0029-Remove-l2arc_nocompress-from-zfs-module-parameters-5.patch
+0030-Fix-shellcheck-v0.4.6-warnings.patch
+0031-Fix-Debian-packaging-on-ARMv7-ARM64.patch
+0032-OpenZFS-8835-Speculative-prefetch-in-ZFS-not-working.patch
+0033-Cleanup-zloop-working-directory-after-each-pass.patch
+0034-Extend-zloop.sh-for-automated-testing.patch
+0035-Fix-zfs-receive-o-when-used-with-e-d.patch
+0036-Tag-zfs-0.7.6.patch