From 8e007c52fd18f61dd9c1db7afab09d45931d0aa4 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Wed, 13 Sep 2006 15:46:49 +0000 Subject: [PATCH] Fix synchronization in gmirror and graid3 which I broken. Synchronization request can still have bio_to set to sc_provider (this is READ part of a synchronization request) and in this case g_{mirror,raid3}_sync() wasn't called as it should be. MFC after: 1 week --- sys/geom/mirror/g_mirror.c | 11 +++++++---- sys/geom/raid3/g_raid3.c | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 1d8e6af2f5e..fa956e25fb5 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -874,7 +874,7 @@ g_mirror_done(struct bio *bp) struct g_mirror_softc *sc; sc = bp->bio_from->geom->softc; - bp->bio_cflags |= G_MIRROR_BIO_FLAG_REGULAR; + bp->bio_cflags = G_MIRROR_BIO_FLAG_REGULAR; mtx_lock(&sc->sc_queue_mtx); bioq_disksort(&sc->sc_queue, bp); wakeup(sc); @@ -1002,7 +1002,7 @@ g_mirror_sync_done(struct bio *bp) G_MIRROR_LOGREQ(3, bp, "Synchronization request delivered."); sc = bp->bio_from->geom->softc; - bp->bio_cflags |= G_MIRROR_BIO_FLAG_SYNC; + bp->bio_cflags = G_MIRROR_BIO_FLAG_SYNC; mtx_lock(&sc->sc_queue_mtx); bioq_disksort(&sc->sc_queue, bp); wakeup(sc); @@ -1813,11 +1813,14 @@ g_mirror_worker(void *arg) bioq_remove(&sc->sc_queue, bp); mtx_unlock(&sc->sc_queue_mtx); - if (bp->bio_to != sc->sc_provider) { + if (bp->bio_from->geom == sc->sc_sync.ds_geom && + (bp->bio_cflags & G_MIRROR_BIO_FLAG_SYNC) != 0) { + g_mirror_sync_request(bp); /* READ */ + } else if (bp->bio_to != sc->sc_provider) { if ((bp->bio_cflags & G_MIRROR_BIO_FLAG_REGULAR) != 0) g_mirror_regular_request(bp); else if ((bp->bio_cflags & G_MIRROR_BIO_FLAG_SYNC) != 0) - g_mirror_sync_request(bp); + g_mirror_sync_request(bp); /* WRITE */ else { KASSERT(0, ("Invalid request cflags=0x%hhx to=%s.", diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 23e2f1b2d3f..1f0b697a6df 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -2061,11 +2061,14 @@ process: bioq_remove(&sc->sc_queue, bp); mtx_unlock(&sc->sc_queue_mtx); - if (bp->bio_to != sc->sc_provider) { + if (bp->bio_from->geom == sc->sc_sync.ds_geom && + (bp->bio_cflags & G_RAID3_BIO_CFLAG_SYNC) != 0) { + g_raid3_sync_request(bp); /* READ */ + } else if (bp->bio_to != sc->sc_provider) { if ((bp->bio_cflags & G_RAID3_BIO_CFLAG_REGULAR) != 0) g_raid3_regular_request(bp); else if ((bp->bio_cflags & G_RAID3_BIO_CFLAG_SYNC) != 0) - g_raid3_sync_request(bp); + g_raid3_sync_request(bp); /* WRITE */ else { KASSERT(0, ("Invalid request cflags=0x%hhx to=%s.",