diff options
author | pjd <pjd@FreeBSD.org> | 2006-03-01 19:01:58 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2006-03-01 19:01:58 +0000 |
commit | b4b6876e6e1c5d91245f03aba237d95302ce4a83 (patch) | |
tree | 7fa6b98f653ee9e64e9c9fe1a3c07e376a2b6e4d | |
parent | 1206eaa7895cf5cd1912bc9065cfbed44647ce0b (diff) | |
download | FreeBSD-src-b4b6876e6e1c5d91245f03aba237d95302ce4a83.zip FreeBSD-src-b4b6876e6e1c5d91245f03aba237d95302ce4a83.tar.gz |
Assert proper use of bio_caller1, bio_caller2, bio_cflags, bio_driver1,
bio_driver2 and bio_pflags fields.
Reviewed by: phk
-rw-r--r-- | sys/geom/geom_io.c | 23 | ||||
-rw-r--r-- | sys/sys/bio.h | 5 |
2 files changed, 28 insertions, 0 deletions
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 7ee1d25..1a4e4a4 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 fa17561..2dbdfb9 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 */ |