Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/geom_io.c
Show First 20 Lines • Show All 876 Lines • ▼ Show 20 Lines | |||||
void * | void * | ||||
g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error) | g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error) | ||||
{ | { | ||||
struct bio *bp; | struct bio *bp; | ||||
void *ptr; | void *ptr; | ||||
int errorc; | int errorc; | ||||
KASSERT(length > 0 && length >= cp->provider->sectorsize && | KASSERT(length > 0 && length >= cp->provider->sectorsize && | ||||
length <= MAXPHYS, ("g_read_data(): invalid length %jd", | length <= maxphys, ("g_read_data(): invalid length %jd", | ||||
(intmax_t)length)); | (intmax_t)length)); | ||||
bp = g_alloc_bio(); | bp = g_alloc_bio(); | ||||
bp->bio_cmd = BIO_READ; | bp->bio_cmd = BIO_READ; | ||||
bp->bio_done = NULL; | bp->bio_done = NULL; | ||||
bp->bio_offset = offset; | bp->bio_offset = offset; | ||||
bp->bio_length = length; | bp->bio_length = length; | ||||
ptr = g_malloc(length, M_WAITOK); | ptr = g_malloc(length, M_WAITOK); | ||||
Show All 38 Lines | |||||
int | int | ||||
g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length) | g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length) | ||||
{ | { | ||||
struct bio *bp; | struct bio *bp; | ||||
int error; | int error; | ||||
KASSERT(length > 0 && length >= cp->provider->sectorsize && | KASSERT(length > 0 && length >= cp->provider->sectorsize && | ||||
length <= MAXPHYS, ("g_write_data(): invalid length %jd", | length <= maxphys, ("g_write_data(): invalid length %jd", | ||||
(intmax_t)length)); | (intmax_t)length)); | ||||
bp = g_alloc_bio(); | bp = g_alloc_bio(); | ||||
bp->bio_cmd = BIO_WRITE; | bp->bio_cmd = BIO_WRITE; | ||||
bp->bio_done = NULL; | bp->bio_done = NULL; | ||||
bp->bio_offset = offset; | bp->bio_offset = offset; | ||||
bp->bio_length = length; | bp->bio_length = length; | ||||
bp->bio_data = ptr; | bp->bio_data = ptr; | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |