[Midnightbsd-cvs] src [9976] trunk/sys/geom/gate/g_gate.c: sync
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat May 26 11:29:10 EDT 2018
Revision: 9976
http://svnweb.midnightbsd.org/src/?rev=9976
Author: laffer1
Date: 2018-05-26 11:29:09 -0400 (Sat, 26 May 2018)
Log Message:
-----------
sync
Modified Paths:
--------------
trunk/sys/geom/gate/g_gate.c
Modified: trunk/sys/geom/gate/g_gate.c
===================================================================
--- trunk/sys/geom/gate/g_gate.c 2018-05-26 15:28:37 UTC (rev 9975)
+++ trunk/sys/geom/gate/g_gate.c 2018-05-26 15:29:09 UTC (rev 9976)
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/gate/g_gate.c,v 1.26 2006/09/08 10:20:44 pjd Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/gate/g_gate.c 314667 2017-03-04 13:03:31Z avg $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -92,6 +92,7 @@
static int
g_gate_destroy(struct g_gate_softc *sc, boolean_t force)
{
+ struct bio_queue_head queue;
struct g_provider *pp;
struct g_consumer *cp;
struct g_geom *gp;
@@ -111,24 +112,24 @@
wakeup(sc);
mtx_unlock(&sc->sc_queue_mtx);
gp = pp->geom;
- pp->flags |= G_PF_WITHER;
- g_orphan_provider(pp, ENXIO);
+ g_wither_provider(pp, ENXIO);
callout_drain(&sc->sc_callout);
+ bioq_init(&queue);
mtx_lock(&sc->sc_queue_mtx);
- while ((bp = bioq_first(&sc->sc_inqueue)) != NULL) {
- bioq_remove(&sc->sc_inqueue, bp);
+ while ((bp = bioq_takefirst(&sc->sc_inqueue)) != NULL) {
sc->sc_queue_count--;
- G_GATE_LOGREQ(1, bp, "Request canceled.");
- g_io_deliver(bp, ENXIO);
+ bioq_insert_tail(&queue, bp);
}
- while ((bp = bioq_first(&sc->sc_outqueue)) != NULL) {
- bioq_remove(&sc->sc_outqueue, bp);
+ while ((bp = bioq_takefirst(&sc->sc_outqueue)) != NULL) {
sc->sc_queue_count--;
+ bioq_insert_tail(&queue, bp);
+ }
+ mtx_unlock(&sc->sc_queue_mtx);
+ g_topology_unlock();
+ while ((bp = bioq_takefirst(&queue)) != NULL) {
G_GATE_LOGREQ(1, bp, "Request canceled.");
g_io_deliver(bp, ENXIO);
}
- mtx_unlock(&sc->sc_queue_mtx);
- g_topology_unlock();
mtx_lock(&g_gate_units_lock);
/* One reference is ours. */
sc->sc_ref--;
@@ -246,8 +247,6 @@
}
cbp->bio_done = g_gate_done;
cbp->bio_offset = pbp->bio_offset + sc->sc_readoffset;
- cbp->bio_data = pbp->bio_data;
- cbp->bio_length = pbp->bio_length;
cbp->bio_to = sc->sc_readcons->provider;
g_io_request(cbp, sc->sc_readcons);
return;
@@ -337,6 +336,7 @@
static void
g_gate_guard(void *arg)
{
+ struct bio_queue_head queue;
struct g_gate_softc *sc;
struct bintime curtime;
struct bio *bp, *bp2;
@@ -344,6 +344,7 @@
sc = arg;
binuptime(&curtime);
g_gate_hold(sc->sc_unit, NULL);
+ bioq_init(&queue);
mtx_lock(&sc->sc_queue_mtx);
TAILQ_FOREACH_SAFE(bp, &sc->sc_inqueue.queue, bio_queue, bp2) {
if (curtime.sec - bp->bio_t0.sec < 5)
@@ -350,8 +351,7 @@
continue;
bioq_remove(&sc->sc_inqueue, bp);
sc->sc_queue_count--;
- G_GATE_LOGREQ(1, bp, "Request timeout.");
- g_io_deliver(bp, EIO);
+ bioq_insert_tail(&queue, bp);
}
TAILQ_FOREACH_SAFE(bp, &sc->sc_outqueue.queue, bio_queue, bp2) {
if (curtime.sec - bp->bio_t0.sec < 5)
@@ -358,10 +358,13 @@
continue;
bioq_remove(&sc->sc_outqueue, bp);
sc->sc_queue_count--;
+ bioq_insert_tail(&queue, bp);
+ }
+ mtx_unlock(&sc->sc_queue_mtx);
+ while ((bp = bioq_takefirst(&queue)) != NULL) {
G_GATE_LOGREQ(1, bp, "Request timeout.");
g_io_deliver(bp, EIO);
}
- mtx_unlock(&sc->sc_queue_mtx);
if ((sc->sc_flags & G_GATE_FLAG_DESTROY) == 0) {
callout_reset(&sc->sc_callout, sc->sc_timeout * hz,
g_gate_guard, sc);
@@ -485,7 +488,7 @@
if (sc->sc_queue_size > G_GATE_MAX_QUEUE_SIZE)
sc->sc_queue_size = G_GATE_MAX_QUEUE_SIZE;
sc->sc_timeout = ggio->gctl_timeout;
- callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_callout, 1);
mtx_lock(&g_gate_units_lock);
sc->sc_unit = g_gate_getunit(ggio->gctl_unit, &error);
@@ -545,6 +548,7 @@
if (ropp != NULL) {
cp = g_new_consumer(gp);
+ cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, ropp);
if (error != 0) {
G_GATE_DEBUG(1, "Unable to attach to %s.", ropp->name);
@@ -563,6 +567,7 @@
ggio->gctl_unit = sc->sc_unit;
pp = g_new_providerf(gp, "%s", name);
+ pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
pp->mediasize = ggio->gctl_mediasize;
pp->sectorsize = ggio->gctl_sectorsize;
sc->sc_provider = pp;
@@ -639,6 +644,7 @@
return (EINVAL);
}
cp = g_new_consumer(sc->sc_provider->geom);
+ cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
if (error != 0) {
G_GATE_DEBUG(1, "Unable to attach to %s.",
@@ -814,7 +820,7 @@
}
}
ggio->gctl_cmd = bp->bio_cmd;
- if ((bp->bio_cmd == BIO_DELETE || bp->bio_cmd == BIO_WRITE) &&
+ if (bp->bio_cmd == BIO_WRITE &&
bp->bio_length > ggio->gctl_length) {
mtx_unlock(&sc->sc_queue_mtx);
ggio->gctl_length = bp->bio_length;
More information about the Midnightbsd-cvs
mailing list