Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/md/md.c
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | |||||
static MALLOC_DEFINE(M_MDSECT, "md_sectors", "Memory Disk Sectors"); | static MALLOC_DEFINE(M_MDSECT, "md_sectors", "Memory Disk Sectors"); | ||||
static int md_debug; | static int md_debug; | ||||
SYSCTL_INT(_debug, OID_AUTO, mddebug, CTLFLAG_RW, &md_debug, 0, | SYSCTL_INT(_debug, OID_AUTO, mddebug, CTLFLAG_RW, &md_debug, 0, | ||||
"Enable md(4) debug messages"); | "Enable md(4) debug messages"); | ||||
static int md_malloc_wait; | static int md_malloc_wait; | ||||
SYSCTL_INT(_vm, OID_AUTO, md_malloc_wait, CTLFLAG_RW, &md_malloc_wait, 0, | SYSCTL_INT(_vm, OID_AUTO, md_malloc_wait, CTLFLAG_RW, &md_malloc_wait, 0, | ||||
"Allow malloc to wait for memory allocations"); | "Allow malloc to wait for memory allocations"); | ||||
static int md_direct; | |||||
SYSCTL_INT(_vm, OID_AUTO, md_direct, CTLFLAG_RW, &md_direct, 0, | |||||
"XXX"); | |||||
#if defined(MD_ROOT) && !defined(MD_ROOT_FSTYPE) | #if defined(MD_ROOT) && !defined(MD_ROOT_FSTYPE) | ||||
#define MD_ROOT_FSTYPE "ufs" | #define MD_ROOT_FSTYPE "ufs" | ||||
#endif | #endif | ||||
#if defined(MD_ROOT) | #if defined(MD_ROOT) | ||||
/* | /* | ||||
* Preloaded image gets put here. | * Preloaded image gets put here. | ||||
▲ Show 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | g_md_access(struct g_provider *pp, int r, int w, int e) | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
g_md_start(struct bio *bp) | g_md_start(struct bio *bp) | ||||
{ | { | ||||
struct md_s *sc; | struct md_s *sc; | ||||
int error; | |||||
sc = bp->bio_to->geom->softc; | sc = bp->bio_to->geom->softc; | ||||
if ((bp->bio_cmd == BIO_READ) || (bp->bio_cmd == BIO_WRITE)) { | if ((bp->bio_cmd == BIO_READ) || (bp->bio_cmd == BIO_WRITE)) { | ||||
devstat_start_transaction_bio(sc->devstat, bp); | devstat_start_transaction_bio(sc->devstat, bp); | ||||
if (md_direct != 0) { | |||||
error = sc->start(sc, bp); | |||||
/* | |||||
* Devstat uses (bio_bcount, bio_resid) for | |||||
* determining the length of the completed part | |||||
* of the i/o. g_io_deliver() will translate | |||||
* from bio_completed to that, but it also | |||||
* destroys the bio so we must do our own | |||||
* translation. | |||||
*/ | |||||
bp->bio_bcount = bp->bio_length; | |||||
devstat_end_transaction_bio(sc->devstat, bp); | |||||
bp->bio_completed = bp->bio_length - bp->bio_resid; | |||||
g_io_deliver(bp, error); | |||||
return; | |||||
} | |||||
} | } | ||||
mtx_lock(&sc->queue_mtx); | mtx_lock(&sc->queue_mtx); | ||||
bioq_disksort(&sc->bio_queue, bp); | bioq_disksort(&sc->bio_queue, bp); | ||||
wakeup(sc); | wakeup(sc); | ||||
mtx_unlock(&sc->queue_mtx); | mtx_unlock(&sc->queue_mtx); | ||||
} | } | ||||
#define MD_MALLOC_MOVE_ZERO 1 | #define MD_MALLOC_MOVE_ZERO 1 | ||||
▲ Show 20 Lines • Show All 1,685 Lines • Show Last 20 Lines |