git: 7d495be8d4bd - main - exterr: print exterr for struct buf and bio in ddb show commands

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 04 Nov 2025 22:55:40 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=7d495be8d4bd3a0e315233346b2f7267b8390612

commit 7d495be8d4bd3a0e315233346b2f7267b8390612
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-11-04 20:53:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-11-04 22:55:20 +0000

    exterr: print exterr for struct buf and bio in ddb show commands
    
    Noted by:       imp
    Sponsored by:   The FreeBSD Foundation
---
 sys/geom/geom_subr.c | 4 ++++
 sys/kern/vfs_bio.c   | 2 ++
 sys/sys/exterr_cat.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index c70d55c6c321..c5dce730da79 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -38,9 +38,11 @@
 #include <sys/cdefs.h>
 #include "opt_ddb.h"
 
+#define	EXTERR_CATEGORY	EXTERR_CAT_GEOM
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/devicestat.h>
+#include <sys/exterrvar.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/bio.h>
@@ -1674,6 +1676,8 @@ DB_SHOW_COMMAND(bio, db_show_bio)
 		db_printf("  caller2: %p\n", bp->bio_caller2);
 		db_printf("  bio_from: %p\n", bp->bio_from);
 		db_printf("  bio_to: %p\n", bp->bio_to);
+		if ((bp->bio_flags & BIO_EXTERR) != 0)
+			exterr_db_print(&bp->bio_exterr);
 
 #if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING)
 		db_printf("  bio_track_bp: %p\n", bp->bio_track_bp);
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 22b7fe8d059a..880cc6b99951 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -5529,6 +5529,8 @@ DB_SHOW_COMMAND(buffer, db_show_buffer)
 		db_printf("\n");
 	}
 	BUF_LOCKPRINTINFO(bp);
+	if ((bp->b_ioflags & BIO_EXTERR) != 0)
+		exterr_db_print(&bp->b_exterr);
 #if defined(FULL_BUF_TRACKING)
 	db_printf("b_io_tracking: b_io_tcnt = %u\n", bp->b_io_tcnt);
 
diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h
index 34a4b9f86694..318e774542ca 100644
--- a/sys/sys/exterr_cat.h
+++ b/sys/sys/exterr_cat.h
@@ -23,6 +23,7 @@
 #define	EXTERR_CAT_VFSSYSCALL	9
 #define	EXTERR_CAT_VFSBIO	10
 #define	EXTERR_CAT_GEOMVFS	11
+#define	EXTERR_CAT_GEOM		12
 
 #endif