From owner-svn-src-projects@FreeBSD.ORG Mon Aug 26 20:03:45 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 80167489; Mon, 26 Aug 2013 20:03:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5E8E72C66; Mon, 26 Aug 2013 20:03:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7QK3j7E093656; Mon, 26 Aug 2013 20:03:45 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7QK3i27093651; Mon, 26 Aug 2013 20:03:44 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201308262003.r7QK3i27093651@svn.freebsd.org> From: Alexander Motin Date: Mon, 26 Aug 2013 20:03:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r254935 - in projects/camlock/sys: cddl/contrib/opensolaris/uts/common/fs/zfs geom X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2013 20:03:45 -0000 Author: mav Date: Mon Aug 26 20:03:44 2013 New Revision: 254935 URL: http://svnweb.freebsd.org/changeset/base/254935 Log: - Introduce new GEOM utility function g_is_geom_thread(), returning true if specified thread is one of GEOM threads (g_up/g_down/g_event). - Use this function instead of `td->td_no_sleeping != 0` (that was not supposed to be public KPI) to detect whether we can sleep in this context. From this moment assume that G_CF_DIRECT_SEND consumer flag means not only reenterability, but also that caller context is sleepable (if we are not already in one of GEOM threads where sleep artificially denied by design). Modified: projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c projects/camlock/sys/geom/geom.h projects/camlock/sys/geom/geom_io.c projects/camlock/sys/geom/geom_kern.c Modified: projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Mon Aug 26 19:07:03 2013 (r254934) +++ projects/camlock/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Mon Aug 26 20:03:44 2013 (r254935) @@ -2176,14 +2176,14 @@ zvol_geom_start(struct bio *bp) ASSERT(zv != NULL); switch (bp->bio_cmd) { case BIO_FLUSH: - if (curthread->td_no_sleeping != 0) + if (g_is_geom_thread(curthread)) goto enqueue; zil_commit(zv->zv_zilog, ZVOL_OBJ); g_io_deliver(bp, 0); break; case BIO_READ: case BIO_WRITE: - if (curthread->td_no_sleeping != 0) + if (g_is_geom_thread(curthread)) goto enqueue; zvol_strategy(bp); break; Modified: projects/camlock/sys/geom/geom.h ============================================================================== --- projects/camlock/sys/geom/geom.h Mon Aug 26 19:07:03 2013 (r254934) +++ projects/camlock/sys/geom/geom.h Mon Aug 26 20:03:44 2013 (r254935) @@ -397,6 +397,8 @@ g_free(void *ptr) }; \ DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +int g_is_geom_thread(struct thread *td); + #endif /* _KERNEL */ /* geom_ctl.c */ Modified: projects/camlock/sys/geom/geom_io.c ============================================================================== --- projects/camlock/sys/geom/geom_io.c Mon Aug 26 19:07:03 2013 (r254934) +++ projects/camlock/sys/geom/geom_io.c Mon Aug 26 20:03:44 2013 (r254935) @@ -83,10 +83,6 @@ static uma_zone_t biozone; static TAILQ_HEAD(g_classifier_tailq, g_classifier_hook) g_classifier_tailq = TAILQ_HEAD_INITIALIZER(g_classifier_tailq); -extern struct thread *g_up_td; -extern struct thread *g_down_td; -extern struct thread *g_event_td; - #include static void @@ -464,7 +460,6 @@ void g_io_request(struct bio *bp, struct g_consumer *cp) { struct g_provider *pp; - struct thread *td; struct mtx *mtxp; int direct, error, first; @@ -522,12 +517,9 @@ g_io_request(struct bio *bp, struct g_co getbinuptime(&bp->bio_t0); #ifdef GET_STACK_USAGE - td = curthread; direct = (cp->flags & G_CF_DIRECT_SEND) && (pp->flags & G_PF_DIRECT_RECEIVE) && - ((bp->bio_flags & BIO_UNMAPPED) == 0 || - td->td_no_sleeping == 0) && - td != g_up_td && td != g_down_td && td != g_event_td; + !g_is_geom_thread(curthread); if (direct) { /* Block direct execution if less then half of stack left. */ size_t st, su; @@ -589,7 +581,6 @@ g_io_deliver(struct bio *bp, int error) struct bintime now; struct g_consumer *cp; struct g_provider *pp; - struct thread *td; struct mtx *mtxp; int direct, first; @@ -638,10 +629,9 @@ g_io_deliver(struct bio *bp, int error) bp->bio_resid = bp->bio_bcount - bp->bio_completed; #ifdef GET_STACK_USAGE - td = curthread; direct = (pp->flags & G_PF_DIRECT_SEND) && (cp->flags & G_CF_DIRECT_RECEIVE) && - td != g_up_td && td != g_down_td && td != g_event_td; + !g_is_geom_thread(curthread); if (direct) { /* Block direct execution if less then half of stack left. */ size_t st, su; Modified: projects/camlock/sys/geom/geom_kern.c ============================================================================== --- projects/camlock/sys/geom/geom_kern.c Mon Aug 26 19:07:03 2013 (r254934) +++ projects/camlock/sys/geom/geom_kern.c Mon Aug 26 20:03:44 2013 (r254935) @@ -59,9 +59,9 @@ MALLOC_DEFINE(M_GEOM, "GEOM", "Geom data struct sx topology_lock; static struct proc *g_proc; -struct thread *g_up_td; -struct thread *g_down_td; -struct thread *g_event_td; +static struct thread *g_up_td; +static struct thread *g_down_td; +static struct thread *g_event_td; int g_debugflags; int g_collectstats = 1; @@ -123,6 +123,13 @@ g_event_procbody(void *arg) /* NOTREACHED */ } +int +g_is_geom_thread(struct thread *td) +{ + + return (td == g_up_td || td == g_down_td || td == g_event_td); +} + static void geom_shutdown(void *foo __unused) {