summaryrefslogtreecommitdiffstats
path: root/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2017-03-04 12:42:52 +0000
committeravg <avg@FreeBSD.org>2017-03-04 12:42:52 +0000
commitb7b0b7a9cd9d27de46f7b2307c0ced4ccb9cb369 (patch)
tree32ab5916f1434f5365f0e787a47f530fd87327a5 /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
parent156edbbe0e73ee666688d44f09d30f198ac4bff2 (diff)
downloadFreeBSD-src-b7b0b7a9cd9d27de46f7b2307c0ced4ccb9cb369.zip
FreeBSD-src-b7b0b7a9cd9d27de46f7b2307c0ced4ccb9cb369.tar.gz
MFC r314273: zfs: call spa_deadman on a taskqueue thread
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
index c247388..f543138 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
@@ -597,8 +597,8 @@ spa_lookup(const char *name)
* If the zfs_deadman_enabled flag is set then it inspects all vdev queues
* looking for potentially hung I/Os.
*/
-void
-spa_deadman(void *arg)
+static void
+spa_deadman(void *arg, int pending)
{
spa_t *spa = arg;
@@ -627,6 +627,16 @@ spa_deadman(void *arg)
#endif
}
+#if defined(__FreeBSD__) && defined(_KERNEL)
+static void
+spa_deadman_timeout(void *arg)
+{
+ spa_t *spa = arg;
+
+ taskqueue_enqueue(taskqueue_thread, &spa->spa_deadman_task);
+}
+#endif
+
/*
* Create an uninitialized spa_t with the given name. Requires
* spa_namespace_lock. The caller must ensure that the spa_t doesn't already
@@ -698,7 +708,23 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
mutex_exit(&cpu_lock);
#else /* !illumos */
#ifdef _KERNEL
+ /*
+ * callout(9) does not provide a way to initialize a callout with
+ * a function and an argument, so we use callout_reset() to schedule
+ * the callout in the very distant future. Even if that event ever
+ * fires, it should be okayas we won't have any active zio-s.
+ * But normally spa_sync() will reschedule the callout with a proper
+ * timeout.
+ * callout(9) does not allow the callback function to sleep but
+ * vdev_deadman() needs to acquire vq_lock and illumos mutexes are
+ * emulated using sx(9). For this reason spa_deadman_timeout()
+ * will schedule spa_deadman() as task on a taskqueue that allows
+ * sleeping.
+ */
+ TASK_INIT(&spa->spa_deadman_task, 0, spa_deadman, spa);
callout_init(&spa->spa_deadman_cycid, 1);
+ callout_reset_sbt(&spa->spa_deadman_cycid, SBT_MAX, 0,
+ spa_deadman_timeout, spa, 0);
#endif
#endif
refcount_create(&spa->spa_refcount);
@@ -811,6 +837,7 @@ spa_remove(spa_t *spa)
#else /* !illumos */
#ifdef _KERNEL
callout_drain(&spa->spa_deadman_cycid);
+ taskqueue_drain(taskqueue_thread, &spa->spa_deadman_task);
#endif
#endif
OpenPOWER on IntegriCloud