Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/mirror/g_mirror.c
Show All 39 Lines | |||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/sbuf.h> | #include <sys/sbuf.h> | ||||
#include <sys/sched.h> | #include <sys/sched.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/unistd.h> | |||||
#include <geom/geom.h> | #include <geom/geom.h> | ||||
#include <geom/mirror/g_mirror.h> | #include <geom/mirror/g_mirror.h> | ||||
FEATURE(geom_mirror, "GEOM mirroring support"); | FEATURE(geom_mirror, "GEOM mirroring support"); | ||||
static MALLOC_DEFINE(M_MIRROR, "mirror_data", "GEOM_MIRROR Data"); | static MALLOC_DEFINE(M_MIRROR, "mirror_data", "GEOM_MIRROR Data"); | ||||
▲ Show 20 Lines • Show All 1,059 Lines • ▼ Show 20 Lines | g_mirror_kernel_dump(struct bio *bp) | ||||
} | } | ||||
cbp->bio_done = g_std_done; | cbp->bio_done = g_std_done; | ||||
g_io_request(cbp, disk->d_consumer); | g_io_request(cbp, disk->d_consumer); | ||||
G_MIRROR_DEBUG(1, "Kernel dump will go to %s.", | G_MIRROR_DEBUG(1, "Kernel dump will go to %s.", | ||||
g_mirror_get_diskname(disk)); | g_mirror_get_diskname(disk)); | ||||
} | } | ||||
static void | static void | ||||
g_mirror_media(struct bio *bp) | |||||
{ | |||||
struct g_mirror_softc *sc; | |||||
struct g_mirror_disk *disk; | |||||
struct bio *cbp; | |||||
atomic_set_long((long *)bp->bio_data, _PC_MEDIA_MIRROR); | |||||
sc = bp->bio_to->private; | |||||
LIST_FOREACH(disk, &sc->sc_disks, d_next) { | |||||
cbp = g_clone_bio(bp); | |||||
if (cbp == NULL) { | |||||
g_io_deliver(bp, ENOMEM); | |||||
return; | |||||
} | |||||
cbp->bio_done = g_std_done; | |||||
g_io_request(cbp, disk->d_consumer); | |||||
} | |||||
} | |||||
static void | |||||
g_mirror_start(struct bio *bp) | g_mirror_start(struct bio *bp) | ||||
{ | { | ||||
struct g_mirror_softc *sc; | struct g_mirror_softc *sc; | ||||
sc = bp->bio_to->private; | sc = bp->bio_to->private; | ||||
/* | /* | ||||
* If sc == NULL or there are no valid disks, provider's error | * If sc == NULL or there are no valid disks, provider's error | ||||
* should be set and g_mirror_start() should not be called at all. | * should be set and g_mirror_start() should not be called at all. | ||||
Show All 10 Lines | g_mirror_start(struct bio *bp) | ||||
case BIO_FLUSH: | case BIO_FLUSH: | ||||
break; | break; | ||||
case BIO_GETATTR: | case BIO_GETATTR: | ||||
if (!strcmp(bp->bio_attribute, "GEOM::candelete")) { | if (!strcmp(bp->bio_attribute, "GEOM::candelete")) { | ||||
g_mirror_candelete(bp); | g_mirror_candelete(bp); | ||||
return; | return; | ||||
} else if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) { | } else if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) { | ||||
g_mirror_kernel_dump(bp); | g_mirror_kernel_dump(bp); | ||||
return; | |||||
} else if (strcmp("GEOM::media", bp->bio_attribute) == 0) { | |||||
g_mirror_media(bp); | |||||
return; | return; | ||||
} | } | ||||
/* FALLTHROUGH */ | /* FALLTHROUGH */ | ||||
default: | default: | ||||
g_io_deliver(bp, EOPNOTSUPP); | g_io_deliver(bp, EOPNOTSUPP); | ||||
return; | return; | ||||
} | } | ||||
mtx_lock(&sc->sc_queue_mtx); | mtx_lock(&sc->sc_queue_mtx); | ||||
▲ Show 20 Lines • Show All 2,332 Lines • Show Last 20 Lines |