From 4759b478a24308f1b05879cbaa6f87337dd14121 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 27 Aug 2004 14:43:11 +0000 Subject: Introduce g_alloc_bio() as a waiting variant of g_new_bio(). Use in places where we can sleep and where we previously failed to check for a NULL pointer. MT5 candidate. --- sys/geom/geom.h | 1 + sys/geom/geom_io.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 015baea..55a6f0c 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -264,6 +264,7 @@ void g_io_deliver(struct bio *bp, int error); int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr); void g_io_request(struct bio *bp, struct g_consumer *cp); struct bio *g_new_bio(void); +struct bio *g_alloc_bio(void); void * g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error); int g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length); void g_print_bio(struct bio *bp); diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 89b0e39..ba4c040 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -121,6 +121,15 @@ g_new_bio(void) return (bp); } +struct bio * +g_alloc_bio(void) +{ + struct bio *bp; + + bp = uma_zalloc(biozone, M_WAITOK | M_ZERO); + return (bp); +} + void g_destroy_bio(struct bio *bp) { @@ -166,7 +175,7 @@ g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr) int error; g_trace(G_T_BIO, "bio_getattr(%s)", attr); - bp = g_new_bio(); + bp = g_alloc_bio(); bp->bio_cmd = BIO_GETATTR; bp->bio_done = NULL; bp->bio_attribute = attr; @@ -439,7 +448,7 @@ g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error) KASSERT(length >= 512 && length <= DFLTPHYS, ("g_read_data(): invalid length %jd", (intmax_t)length)); - bp = g_new_bio(); + bp = g_alloc_bio(); bp->bio_cmd = BIO_READ; bp->bio_done = NULL; bp->bio_offset = offset; @@ -467,7 +476,7 @@ g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length) KASSERT(length >= 512 && length <= DFLTPHYS, ("g_write_data(): invalid length %jd", (intmax_t)length)); - bp = g_new_bio(); + bp = g_alloc_bio(); bp->bio_cmd = BIO_WRITE; bp->bio_done = NULL; bp->bio_offset = offset; -- cgit v1.1