Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/geom_io.c
Show First 20 Lines • Show All 888 Lines • ▼ Show 20 Lines | g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error) | ||||
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); | ||||
bp->bio_data = ptr; | bp->bio_data = ptr; | ||||
g_io_request(bp, cp); | g_io_request(bp, cp); | ||||
errorc = biowait(bp, "gread"); | errorc = biowait(bp, "gread"); | ||||
if (errorc == 0 && bp->bio_completed != length) | |||||
errorc = EIO; | |||||
if (error != NULL) | if (error != NULL) | ||||
*error = errorc; | *error = errorc; | ||||
g_destroy_bio(bp); | g_destroy_bio(bp); | ||||
if (errorc) { | if (errorc) { | ||||
g_free(ptr); | g_free(ptr); | ||||
ptr = NULL; | ptr = NULL; | ||||
} | } | ||||
return (ptr); | return (ptr); | ||||
Show All 38 Lines | g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_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; | ||||
g_io_request(bp, cp); | g_io_request(bp, cp); | ||||
error = biowait(bp, "gwrite"); | error = biowait(bp, "gwrite"); | ||||
if (error == 0 && bp->bio_completed != length) | |||||
error = EIO; | |||||
g_destroy_bio(bp); | g_destroy_bio(bp); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* A write function for use by ffs_sbput when used by GEOM-layer routines. | * A write function for use by ffs_sbput when used by GEOM-layer routines. | ||||
*/ | */ | ||||
int | int | ||||
Show All 15 Lines | g_delete_data(struct g_consumer *cp, off_t offset, off_t length) | ||||
bp = g_alloc_bio(); | bp = g_alloc_bio(); | ||||
bp->bio_cmd = BIO_DELETE; | bp->bio_cmd = BIO_DELETE; | ||||
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 = NULL; | bp->bio_data = NULL; | ||||
g_io_request(bp, cp); | g_io_request(bp, cp); | ||||
error = biowait(bp, "gdelete"); | error = biowait(bp, "gdelete"); | ||||
if (error == 0 && bp->bio_completed != length) | |||||
error = EIO; | |||||
g_destroy_bio(bp); | g_destroy_bio(bp); | ||||
return (error); | return (error); | ||||
} | } | ||||
void | void | ||||
g_print_bio(const char *prefix, const struct bio *bp, const char *fmtsuffix, | g_print_bio(const char *prefix, const struct bio *bp, const char *fmtsuffix, | ||||
...) | ...) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |