--- /dev/null
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Olaf Faaland <faaland1@llnl.gov>
+Date: Tue, 20 Feb 2018 17:33:51 -0800
+Subject: [PATCH] Detect long config lock acquisition in mmp
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+If something holds the config lock as a writer for too long, MMP will
+fail to issue MMP writes in a timely manner. This will result either in
+the pool being suspended, or in an extreme case, in the pool not being
+protected.
+
+If the time to acquire the config lock exceeds 1/10 of the minimum
+zfs_multihost_interval, report it in the zfs debug log.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
+Closes #7212
+(cherry picked from commit c17922b8a9db00ad7e7d59a5ff975b2a1edcf887)
+Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+---
+ module/zfs/mmp.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/module/zfs/mmp.c b/module/zfs/mmp.c
+index ee8e9201b..634e48287 100644
+--- a/module/zfs/mmp.c
++++ b/module/zfs/mmp.c
+@@ -323,7 +323,13 @@ mmp_write_uberblock(spa_t *spa)
+ int label;
+ uint64_t offset;
+
++ hrtime_t lock_acquire_time = gethrtime();
+ spa_config_enter(spa, SCL_STATE, mmp_tag, RW_READER);
++ lock_acquire_time = gethrtime() - lock_acquire_time;
++ if (lock_acquire_time > (MSEC2NSEC(MMP_MIN_INTERVAL) / 10))
++ zfs_dbgmsg("SCL_STATE acquisition took %llu ns\n",
++ (u_longlong_t)lock_acquire_time);
++
+ vd = mmp_random_leaf(spa->spa_root_vdev);
+ if (vd == NULL) {
+ spa_config_exit(spa, SCL_STATE, FTAG);
+--
+2.14.2
+