From owner-svn-src-stable-11@freebsd.org Sat Mar 4 12:42:53 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EAD79CF8F2A; Sat, 4 Mar 2017 12:42:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2C4B1016; Sat, 4 Mar 2017 12:42:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24Cgqk3064357; Sat, 4 Mar 2017 12:42:52 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24CgqOj064354; Sat, 4 Mar 2017 12:42:52 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703041242.v24CgqOj064354@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sat, 4 Mar 2017 12:42:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r314665 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 12:42:54 -0000 Author: avg Date: Sat Mar 4 12:42:52 2017 New Revision: 314665 URL: https://svnweb.freebsd.org/changeset/base/314665 Log: MFC r314273: zfs: call spa_deadman on a taskqueue thread Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Sat Mar 4 12:05:50 2017 (r314664) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Sat Mar 4 12:42:52 2017 (r314665) @@ -173,10 +173,6 @@ uint_t zio_taskq_basedc = 80; /* base boolean_t spa_create_process = B_TRUE; /* no process ==> no sysdc */ extern int zfs_sync_pass_deferred_free; -#ifndef illumos -extern void spa_deadman(void *arg); -#endif - /* * This (illegal) pool name is used when temporarily importing a spa_t in order * to get the vdev stats associated with the imported devices. @@ -6880,8 +6876,8 @@ spa_sync(spa_t *spa, uint64_t txg) spa->spa_sync_starttime + spa->spa_deadman_synctime)); #else /* !illumos */ #ifdef _KERNEL - callout_reset(&spa->spa_deadman_cycid, - hz * spa->spa_deadman_synctime / NANOSEC, spa_deadman, spa); + callout_schedule(&spa->spa_deadman_cycid, + hz * spa->spa_deadman_synctime / NANOSEC); #endif #endif /* illumos */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sat Mar 4 12:05:50 2017 (r314664) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sat Mar 4 12:42:52 2017 (r314665) @@ -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 *conf 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 Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Sat Mar 4 12:05:50 2017 (r314664) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Sat Mar 4 12:42:52 2017 (r314665) @@ -267,6 +267,7 @@ struct spa { #else /* !illumos */ #ifdef _KERNEL struct callout spa_deadman_cycid; /* callout id */ + struct task spa_deadman_task; #endif #endif /* illumos */ uint64_t spa_deadman_calls; /* number of deadman calls */