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.
This commit is contained in:
parent
a8f5ecad19
commit
0bfb5dbc86
@ -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;
|
||||
|
@ -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_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;
|
||||
|
@ -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, 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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user