Date: Mon, 26 Aug 2013 20:03:44 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> 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 Message-ID: <201308262003.r7QK3i27093651@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <machine/atomic.h> 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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308262003.r7QK3i27093651>