summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2016-02-17 17:16:02 +0000
committerimp <imp@FreeBSD.org>2016-02-17 17:16:02 +0000
commit0bfb5dbc867a4ef73b0b2259adfd285a1cbaf5d2 (patch)
tree9d0b9ff9938b0c9fa10bfca4675a8a542491fbe6 /sys/geom
parenta8f5ecad19b5c936057dbbcda2353b9ca84b09f5 (diff)
downloadFreeBSD-src-0bfb5dbc867a4ef73b0b2259adfd285a1cbaf5d2.zip
FreeBSD-src-0bfb5dbc867a4ef73b0b2259adfd285a1cbaf5d2.tar.gz
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.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/geom.h1
-rw-r--r--sys/geom/geom_io.c7
-rw-r--r--sys/geom/journal/g_journal.c4
-rw-r--r--sys/geom/mirror/g_mirror.c2
-rw-r--r--sys/geom/raid/g_raid.c2
-rw-r--r--sys/geom/raid3/g_raid3.c2
6 files changed, 13 insertions, 5 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index f313d02..bf70d0b 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 9dff151..5a2e4bd 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -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()
{
diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c
index f0eb103..f0b07b2 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 cb2e41b..70f5eb1 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 839a2d4..4885319 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 132ef84..584076f 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);
OpenPOWER on IntegriCloud