path: root/sys/sys/bio.h
diff options
authorConrad Meyer <cem@FreeBSD.org>2016-10-31 23:09:52 +0000
committerConrad Meyer <cem@FreeBSD.org>2016-10-31 23:09:52 +0000
commit8532d381a91f1e201ab95ab7f913b723e8912571 (patch)
tree38a4d4d75a173395017b59aa5d986d25e29e841a /sys/sys/bio.h
parent2d5386cc2c570cf781c45cc948a800c8f8d4f0d0 (diff)
Add BUF_TRACKING and FULL_BUF_TRACKING buffer debugging
Upstream the BUF_TRACKING and FULL_BUF_TRACKING buffer debugging code. This can be handy in tracking down what code touched hung bios and bufs last. The full history is especially useful, but adds enough bloat that it shouldn't be enabled in release builds. Function names (or arbitrary string constants) are tracked in a fixed-size ring in bufs. Bios gain a pointer to the upper buf for tracking. SCSI CCBs gain a pointer to the upper bio for tracking. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8366
Notes: svn path=/head/; revision=308155
Diffstat (limited to 'sys/sys/bio.h')
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
index 8821fef59bb3..9c669537e7ed 100644
--- a/sys/sys/bio.h
+++ b/sys/sys/bio.h
@@ -121,6 +121,9 @@ struct bio {
void *_bio_caller2;
uint8_t _bio_cflags;
+#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING)
+ struct buf *bio_track_bp; /* Parent buf for tracking */
/* XXX: these go away when bio chaining is introduced */
daddr_t bio_pblkno; /* physical block number */
@@ -142,6 +145,23 @@ void biodone(struct bio *bp);
void biofinish(struct bio *bp, struct devstat *stat, int error);
int biowait(struct bio *bp, const char *wchan);
+#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING)
+void biotrack_buf(struct bio *bp, const char *location);
+static __inline void
+biotrack(struct bio *bp, const char *location)
+ if (bp->bio_track_bp != NULL)
+ biotrack_buf(bp, location);
+static __inline void
+biotrack(struct bio *bp __unused, const char *location __unused)
void bioq_disksort(struct bio_queue_head *ap, struct bio *bp);
struct bio *bioq_first(struct bio_queue_head *head);
struct bio *bioq_takefirst(struct bio_queue_head *head);