diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c index 85b31f001f6d..3df15e29778b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c @@ -314,7 +314,7 @@ vdev_geom_io(struct g_consumer *cp, int cmd, void *data, off_t offset, off_t siz error = 0; for (; off < offset; off += maxio, p += maxio, size -= maxio) { - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); bp->bio_cmd = cmd; bp->bio_done = NULL; bp->bio_offset = off; diff --git a/sys/dev/mmc/mmcsd.c b/sys/dev/mmc/mmcsd.c index 4ca0c2492797..77491234ca85 100644 --- a/sys/dev/mmc/mmcsd.c +++ b/sys/dev/mmc/mmcsd.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -487,7 +488,7 @@ mmcsd_dump(void *arg, void *virtual, vm_offset_t physical, if (!length) return (0); - bzero(&bp, sizeof(struct bio)); + g_reset_bio(&bp); bp.bio_disk = disk; bp.bio_pblkno = offset / disk->d_sectorsize; bp.bio_bcount = length; diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index 0cfebf1d724c..7b273641a5dd 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -1146,7 +1147,7 @@ vtblk_ident(struct vtblk_softc *sc) req->vbr_hdr.sector = 0; req->vbr_bp = &buf; - bzero(&buf, sizeof(struct bio)); + g_reset_bio(&buf); buf.bio_cmd = BIO_READ; buf.bio_data = dp->d_ident; @@ -1278,7 +1279,7 @@ vtblk_dump_write(struct vtblk_softc *sc, void *virtual, off_t offset, req->vbr_hdr.sector = offset / 512; req->vbr_bp = &buf; - bzero(&buf, sizeof(struct bio)); + g_reset_bio(&buf); buf.bio_cmd = BIO_WRITE; buf.bio_data = virtual; @@ -1300,7 +1301,7 @@ vtblk_dump_flush(struct vtblk_softc *sc) req->vbr_hdr.sector = 0; req->vbr_bp = &buf; - bzero(&buf, sizeof(struct bio)); + g_reset_bio(&buf); buf.bio_cmd = BIO_FLUSH; diff --git a/sys/geom/geom.h b/sys/geom/geom.h index f313d02b74c8..bf70d0bc3155 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -324,6 +324,7 @@ void g_unregister_classifier(struct g_classifier_hook *hook); 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_reset_bio(struct bio *); 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); int g_delete_data(struct g_consumer *cp, off_t offset, off_t length); diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 9dff151c6dad..5a2e4bd98e12 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -264,6 +264,13 @@ g_duplicate_bio(struct bio *bp) return(bp2); } +void +g_reset_bio(struct bio *bp) +{ + + bzero(bp, sizeof(bp)); +} + void g_io_init() { diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index f0eb10347769..f0b07b2406a6 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -1296,7 +1296,7 @@ g_journal_flush(struct g_journal_softc *sc) data = bp->bio_data; if (sc->sc_flags & GJF_DEVICE_CHECKSUM) MD5Update(&ctx, data, ent->je_length); - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); bp->bio_cflags = GJ_BIO_JOURNAL; bp->bio_offset = ent->je_offset; bp->bio_joffset = ent->je_joffset; @@ -1772,7 +1772,7 @@ g_journal_sync_read(struct g_consumer *cp, struct bio *bp, off_t offset, { int error; - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); bp->bio_cmd = BIO_READ; bp->bio_done = NULL; bp->bio_offset = offset; diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index cb2e41b26f42..70f5eb115fe3 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -1372,7 +1372,7 @@ g_mirror_sync_request(struct bio *bp) /* Send next synchronization request. */ data = bp->bio_data; - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); bp->bio_cmd = BIO_READ; bp->bio_offset = sync->ds_offset; bp->bio_length = MIN(MAXPHYS, sc->sc_mediasize - bp->bio_offset); diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index 839a2d46345c..4885319ab094 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -1011,7 +1011,7 @@ g_raid_tr_kerneldump_common(struct g_raid_tr_object *tr, vol = tr->tro_volume; sc = vol->v_softc; - bzero(&bp, sizeof(bp)); + g_reset_bio(&bp); bp.bio_cmd = BIO_WRITE; bp.bio_done = g_raid_tr_kerneldump_common_done; bp.bio_attribute = NULL; diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 132ef84c05a1..584076f4536d 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -1717,7 +1717,7 @@ g_raid3_sync_request(struct bio *bp) /* Send next synchronization request. */ data = bp->bio_data; - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); bp->bio_cmd = BIO_READ; bp->bio_offset = sync->ds_offset * (sc->sc_ndisks - 1); bp->bio_length = MIN(MAXPHYS, sc->sc_mediasize - bp->bio_offset); diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 5d75304a339c..a1483865fe5a 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -110,7 +110,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) error = 0; for (i = 0; i < uio->uio_iovcnt; i++) { while (uio->uio_iov[i].iov_len) { - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); if (uio->uio_rw == UIO_READ) { bp->bio_cmd = BIO_READ; curthread->td_ru.ru_inblock++;