Date: Wed, 17 Feb 2016 17:16:02 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295707 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs dev/mmc dev/virtio/block geom geom/journal geom/mirror geom/raid geom/raid3 kern Message-ID: <201602171716.u1HHG2c2098316@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Wed Feb 17 17:16:02 2016 New Revision: 295707 URL: https://svnweb.freebsd.org/changeset/base/295707 Log: Create an API to reset a struct bio (g_reset_bio). This is mandatory for all struct bio you get back from g_{new,alloc}_bio. Temporary bios that you create on the stack or elsewhere should use this before first use of the bio, and between uses of the bio. At the moment, it is nothing more than a wrapper around bzero, but that may change in the future. The wrapper also removes one place where we encode the size of struct bio in the KBI. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c head/sys/dev/mmc/mmcsd.c head/sys/dev/virtio/block/virtio_blk.c head/sys/geom/geom.h head/sys/geom/geom_io.c head/sys/geom/journal/g_journal.c head/sys/geom/mirror/g_mirror.c head/sys/geom/raid/g_raid.c head/sys/geom/raid3/g_raid3.c head/sys/kern/kern_physio.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Wed Feb 17 17:16:02 2016 (r295707) @@ -314,7 +314,7 @@ vdev_geom_io(struct g_consumer *cp, int 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; Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/dev/mmc/mmcsd.c Wed Feb 17 17:16:02 2016 (r295707) @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/mutex.h> #include <sys/time.h> +#include <geom/geom.h> #include <geom/geom_disk.h> #include <dev/mmc/mmcbrvar.h> @@ -487,7 +488,7 @@ mmcsd_dump(void *arg, void *virtual, vm_ 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; Modified: head/sys/dev/virtio/block/virtio_blk.c ============================================================================== --- head/sys/dev/virtio/block/virtio_blk.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/dev/virtio/block/virtio_blk.c Wed Feb 17 17:16:02 2016 (r295707) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/queue.h> +#include <geom/geom.h> #include <geom/geom_disk.h> #include <machine/bus.h> @@ -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, 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; Modified: head/sys/geom/geom.h ============================================================================== --- head/sys/geom/geom.h Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/geom/geom.h Wed Feb 17 17:16:02 2016 (r295707) @@ -324,6 +324,7 @@ void g_unregister_classifier(struct g_cl 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); Modified: head/sys/geom/geom_io.c ============================================================================== --- head/sys/geom/geom_io.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/geom/geom_io.c Wed Feb 17 17:16:02 2016 (r295707) @@ -265,6 +265,13 @@ g_duplicate_bio(struct bio *bp) } void +g_reset_bio(struct bio *bp) +{ + + bzero(bp, sizeof(bp)); +} + +void g_io_init() { Modified: head/sys/geom/journal/g_journal.c ============================================================================== --- head/sys/geom/journal/g_journal.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/geom/journal/g_journal.c Wed Feb 17 17:16:02 2016 (r295707) @@ -1296,7 +1296,7 @@ g_journal_flush(struct g_journal_softc * 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 *c { int error; - bzero(bp, sizeof(*bp)); + g_reset_bio(bp); bp->bio_cmd = BIO_READ; bp->bio_done = NULL; bp->bio_offset = offset; Modified: head/sys/geom/mirror/g_mirror.c ============================================================================== --- head/sys/geom/mirror/g_mirror.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/geom/mirror/g_mirror.c Wed Feb 17 17:16:02 2016 (r295707) @@ -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); Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/geom/raid/g_raid.c Wed Feb 17 17:16:02 2016 (r295707) @@ -1011,7 +1011,7 @@ g_raid_tr_kerneldump_common(struct g_rai 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; Modified: head/sys/geom/raid3/g_raid3.c ============================================================================== --- head/sys/geom/raid3/g_raid3.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/geom/raid3/g_raid3.c Wed Feb 17 17:16:02 2016 (r295707) @@ -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); Modified: head/sys/kern/kern_physio.c ============================================================================== --- head/sys/kern/kern_physio.c Wed Feb 17 16:13:22 2016 (r295706) +++ head/sys/kern/kern_physio.c Wed Feb 17 17:16:02 2016 (r295707) @@ -110,7 +110,7 @@ physio(struct cdev *dev, struct uio *uio 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++;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602171716.u1HHG2c2098316>