diff options
author | pjd <pjd@FreeBSD.org> | 2006-10-31 21:23:51 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2006-10-31 21:23:51 +0000 |
commit | c33849dc41d24ae1362682bce0b8ebce43af556a (patch) | |
tree | e1cf58f0328589a697dacbff3b7e0c1982735a33 /sys/geom/mirror | |
parent | 51fb042070317c283395fd7170157adbbc879898 (diff) | |
download | FreeBSD-src-c33849dc41d24ae1362682bce0b8ebce43af556a.zip FreeBSD-src-c33849dc41d24ae1362682bce0b8ebce43af556a.tar.gz |
Implement BIO_FLUSH handling by simply passing it down to the components.
Sponsored by: home.pl
Diffstat (limited to 'sys/geom/mirror')
-rw-r--r-- | sys/geom/mirror/g_mirror.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index fa956e2..f03da3b 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -1042,6 +1042,48 @@ g_mirror_kernel_dump(struct bio *bp) } static void +g_mirror_flush(struct g_mirror_softc *sc, struct bio *bp) +{ + struct bio_queue_head queue; + struct g_mirror_disk *disk; + struct g_consumer *cp; + struct bio *cbp; + + bioq_init(&queue); + LIST_FOREACH(disk, &sc->sc_disks, d_next) { + if (disk->d_state != G_MIRROR_DISK_STATE_ACTIVE) + continue; + cbp = g_clone_bio(bp); + if (cbp == NULL) { + for (cbp = bioq_first(&queue); cbp != NULL; + cbp = bioq_first(&queue)) { + bioq_remove(&queue, cbp); + g_destroy_bio(cbp); + } + if (bp->bio_error == 0) + bp->bio_error = ENOMEM; + g_io_deliver(bp, bp->bio_error); + return; + } + bioq_insert_tail(&queue, cbp); + cbp->bio_done = g_std_done; + cbp->bio_caller1 = disk; + cbp->bio_to = disk->d_consumer->provider; + } + for (cbp = bioq_first(&queue); cbp != NULL; cbp = bioq_first(&queue)) { + bioq_remove(&queue, cbp); + G_MIRROR_LOGREQ(3, cbp, "Sending request."); + disk = cbp->bio_caller1; + cbp->bio_caller1 = NULL; + cp = disk->d_consumer; + KASSERT(cp->acr >= 1 && cp->acw >= 1 && cp->ace >= 1, + ("Consumer %s not opened (r%dw%de%d).", cp->provider->name, + cp->acr, cp->acw, cp->ace)); + g_io_request(cbp, disk->d_consumer); + } +} + +static void g_mirror_start(struct bio *bp) { struct g_mirror_softc *sc; @@ -1061,6 +1103,9 @@ g_mirror_start(struct bio *bp) case BIO_WRITE: case BIO_DELETE: break; + case BIO_FLUSH: + g_mirror_flush(sc, bp); + return; case BIO_GETATTR: if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) { g_mirror_kernel_dump(bp); |