From 92ee312dd4c08cb7072538412c1bf3c8123bab38 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Wed, 1 Mar 2006 19:01:58 +0000 Subject: [PATCH] Assert proper use of bio_caller1, bio_caller2, bio_cflags, bio_driver1, bio_driver2 and bio_pflags fields. Reviewed by: phk --- sys/geom/geom_io.c | 23 +++++++++++++++++++++++ sys/sys/bio.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 7ee1d25cd28d..1a4e4a4d5656 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -282,6 +282,21 @@ g_io_request(struct bio *bp, struct g_consumer *cp) KASSERT(bp->bio_data != NULL, ("NULL bp->data in g_io_request")); pp = cp->provider; KASSERT(pp != NULL, ("consumer not attached in g_io_request")); +#ifdef DIAGNOSTIC + KASSERT(bp->bio_driver1 == NULL, + ("bio_driver1 used by the consumer (geom %s)", cp->geom->name)); + KASSERT(bp->bio_driver2 == NULL, + ("bio_driver2 used by the consumer (geom %s)", cp->geom->name)); + KASSERT(bp->bio_pflags == 0, + ("bio_pflags used by the consumer (geom %s)", cp->geom->name)); + /* + * Remember consumer's private fields, so we can detect if they were + * modified by the provider. + */ + bp->_bio_caller1 = bp->bio_caller1; + bp->_bio_caller2 = bp->bio_caller2; + bp->_bio_cflags = bp->bio_cflags; +#endif if (bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) { KASSERT(bp->bio_offset % cp->provider->sectorsize == 0, @@ -336,6 +351,14 @@ g_io_deliver(struct bio *bp, int error) KASSERT(bp != NULL, ("NULL bp in g_io_deliver")); pp = bp->bio_to; KASSERT(pp != NULL, ("NULL bio_to in g_io_deliver")); +#ifdef DIAGNOSTIC + KASSERT(bp->bio_caller1 == bp->_bio_caller1, + ("bio_caller1 used by the provider %s", pp->name)); + KASSERT(bp->bio_caller2 == bp->_bio_caller2, + ("bio_caller2 used by the provider %s", pp->name)); + KASSERT(bp->bio_cflags == bp->_bio_cflags, + ("bio_cflags used by the provider %s", pp->name)); +#endif cp = bp->bio_from; if (cp == NULL) { bp->bio_error = error; diff --git a/sys/sys/bio.h b/sys/sys/bio.h index fa1756145b0c..2dbdfb9946ee 100644 --- a/sys/sys/bio.h +++ b/sys/sys/bio.h @@ -78,6 +78,11 @@ struct bio { bio_task_t *bio_task; /* Task_queue handler */ void *bio_task_arg; /* Argument to above */ +#ifdef DIAGNOSTIC + void *_bio_caller1; + void *_bio_caller2; + uint8_t _bio_cflags; +#endif /* XXX: these go away when bio chaining is introduced */ daddr_t bio_pblkno; /* physical block number */