svn commit: r350694 - in head: share/man/man9 sys/dev/fdc sys/geom sys/geom/cache sys/geom/concat sys/geom/eli sys/geom/gate sys/geom/journal sys/geom/label sys/geom/linux_lvm sys/geom/mirror sys/g...

Conrad Meyer cem at FreeBSD.org
Wed Aug 7 19:28:46 UTC 2019


Author: cem
Date: Wed Aug  7 19:28:35 2019
New Revision: 350694
URL: https://svnweb.freebsd.org/changeset/base/350694

Log:
  GEOM: Reduce unnecessary log interleaving with sbufs
  
  Similar to what was done for device_printfs in r347229.
  
  Convert g_print_bio() to a thin shim around g_format_bio(), which acts on an
  sbuf; documented in g_bio.9.
  
  Reviewed by:	markj
  Discussed with:	rlibby
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D21165

Added:
  head/sys/geom/geom_dbg.h   (contents, props changed)
Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/g_bio.9
  head/sys/dev/fdc/fdc.c
  head/sys/geom/cache/g_cache.c
  head/sys/geom/cache/g_cache.h
  head/sys/geom/concat/g_concat.c
  head/sys/geom/concat/g_concat.h
  head/sys/geom/eli/g_eli.c
  head/sys/geom/eli/g_eli.h
  head/sys/geom/eli/g_eli_ctl.c
  head/sys/geom/eli/g_eli_integrity.c
  head/sys/geom/eli/g_eli_privacy.c
  head/sys/geom/gate/g_gate.c
  head/sys/geom/gate/g_gate.h
  head/sys/geom/geom.h
  head/sys/geom/geom_io.c
  head/sys/geom/geom_subr.c
  head/sys/geom/geom_vfs.c
  head/sys/geom/journal/g_journal.c
  head/sys/geom/journal/g_journal.h
  head/sys/geom/journal/g_journal_ufs.c
  head/sys/geom/label/g_label.c
  head/sys/geom/label/g_label.h
  head/sys/geom/label/g_label_ext2fs.c
  head/sys/geom/label/g_label_iso9660.c
  head/sys/geom/label/g_label_msdosfs.c
  head/sys/geom/label/g_label_reiserfs.c
  head/sys/geom/label/g_label_ufs.c
  head/sys/geom/linux_lvm/g_linux_lvm.c
  head/sys/geom/linux_lvm/g_linux_lvm.h
  head/sys/geom/mirror/g_mirror.c
  head/sys/geom/mirror/g_mirror.h
  head/sys/geom/mirror/g_mirror_ctl.c
  head/sys/geom/mountver/g_mountver.c
  head/sys/geom/mountver/g_mountver.h
  head/sys/geom/nop/g_nop.c
  head/sys/geom/nop/g_nop.h
  head/sys/geom/raid/g_raid.c
  head/sys/geom/raid/g_raid.h
  head/sys/geom/raid/md_ddf.c
  head/sys/geom/raid/md_intel.c
  head/sys/geom/raid/md_jmicron.c
  head/sys/geom/raid/md_nvidia.c
  head/sys/geom/raid/md_promise.c
  head/sys/geom/raid/md_sii.c
  head/sys/geom/raid/tr_concat.c
  head/sys/geom/raid/tr_raid0.c
  head/sys/geom/raid/tr_raid1.c
  head/sys/geom/raid/tr_raid1e.c
  head/sys/geom/raid3/g_raid3.c
  head/sys/geom/raid3/g_raid3.h
  head/sys/geom/sched/g_sched.c
  head/sys/geom/sched/g_sched.h
  head/sys/geom/shsec/g_shsec.c
  head/sys/geom/shsec/g_shsec.h
  head/sys/geom/stripe/g_stripe.c
  head/sys/geom/stripe/g_stripe.h
  head/sys/geom/vinum/geom_vinum.c
  head/sys/geom/vinum/geom_vinum.h
  head/sys/geom/vinum/geom_vinum_create.c
  head/sys/geom/vinum/geom_vinum_drive.c
  head/sys/geom/vinum/geom_vinum_events.c
  head/sys/geom/vinum/geom_vinum_init.c
  head/sys/geom/vinum/geom_vinum_move.c
  head/sys/geom/vinum/geom_vinum_plex.c
  head/sys/geom/vinum/geom_vinum_raid5.c
  head/sys/geom/vinum/geom_vinum_rename.c
  head/sys/geom/vinum/geom_vinum_rm.c
  head/sys/geom/vinum/geom_vinum_state.c
  head/sys/geom/vinum/geom_vinum_subr.c
  head/sys/geom/virstor/g_virstor.c
  head/sys/geom/virstor/g_virstor.h

Modified: head/share/man/man9/Makefile
==============================================================================
--- head/share/man/man9/Makefile	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/share/man/man9/Makefile	Wed Aug  7 19:28:35 2019	(r350694)
@@ -1004,6 +1004,7 @@ MLINKS+=g_bio.9 g_alloc_bio.9 \
 	g_bio.9 g_clone_bio.9 \
 	g_bio.9 g_destroy_bio.9 \
 	g_bio.9 g_duplicate_bio.9 \
+	g_bio.9 g_format_bio.9 \
 	g_bio.9 g_new_bio.9 \
 	g_bio.9 g_print_bio.9 \
 	g_bio.9 g_reset_bio.9

Modified: head/share/man/man9/g_bio.9
==============================================================================
--- head/share/man/man9/g_bio.9	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/share/man/man9/g_bio.9	Wed Aug  7 19:28:35 2019	(r350694)
@@ -24,13 +24,14 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd Mar 7, 2018
+.Dd August 7, 2019
 .Dt G_BIO 9
 .Os
 .Sh NAME
 .Nm g_new_bio ,
 .Nm g_clone_bio ,
 .Nm g_destroy_bio ,
+.Nm g_format_bio ,
 .Nm g_print_bio ,
 .Nm g_reset_bio
 .Nd "GEOM bio controlling functions"
@@ -48,8 +49,13 @@
 .Ft void
 .Fn g_destroy_bio "struct bio *bp"
 .Ft void
-.Fn g_print_bio "struct bio *bp"
+.Fn g_format_bio "struct sbuf *sb" "const struct bio *bp"
 .Ft void
+.Fo g_print_bio
+.Fa "struct sbuf *sb" "const char *prefix" "const struct bio *bp"
+.Fa "const char *fmtsuffix" ...
+.Fc
+.Ft void
 .Fn g_reset_bio "struct bio *bp"
 .Sh DESCRIPTION
 A
@@ -204,12 +210,30 @@ function deallocates and destroys the given
 structure.
 .Pp
 The
-.Fn g_print_bio
+.Fn g_format_bio
 function prints information about the given
 .Vt bio
-structure (for debugging purposes).
+structure into the provided
+.Vt sbuf .
 .Pp
 The
+.Fn g_print_bio
+function is a convenience wrapper around
+.Fn g_format_bio
+that can be used for debugging purposes.
+It prints a provided
+.Fa prefix
+string, followed by the formatted
+.Vt bio ,
+followed by a
+.Fa fmtsuffix
+in the style of
+.Xr 9 printf .
+Any of the prefix or suffix strings may be the empty string.
+.Fn g_print_bio
+always prints a newline character at the end of the line.
+.Pp
+The
 .Fn g_reset_bio
 function resets the given
 .Vt bio
@@ -261,9 +285,7 @@ example_start(struct bio *bp)
 	struct example_softc *sc;
 	struct bio *cbp;
 
-	printf("Request received: ");
-	g_print_bio(bp);
-	printf("\\n");
+	g_print_bio("Request received: ", bp, "");
 
 	sc = bp->bio_to->geom->softc;
 	if (sc == NULL) {

Modified: head/sys/dev/fdc/fdc.c
==============================================================================
--- head/sys/dev/fdc/fdc.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/dev/fdc/fdc.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -1160,10 +1160,8 @@ fdc_thread(void *arg)
 		mtx_unlock(&fdc->fdc_mtx);
 		i = fdc_worker(fdc);
 		if (i && debugflags & 0x20) {
-			if (fdc->bp != NULL) {
-				g_print_bio(fdc->bp);
-				printf("\n");
-			}
+			if (fdc->bp != NULL)
+				g_print_bio("", fdc->bp, "");
 			printf("Retry line %d\n", retry_line);
 		}
 		fdc->retry += i;

Modified: head/sys/geom/cache/g_cache.c
==============================================================================
--- head/sys/geom/cache/g_cache.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/cache/g_cache.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/time.h>
 #include <vm/uma.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/cache/g_cache.h>
 
 FEATURE(geom_cache, "GEOM cache module");

Modified: head/sys/geom/cache/g_cache.h
==============================================================================
--- head/sys/geom/cache/g_cache.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/cache/g_cache.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -41,25 +41,10 @@
 #define	G_CACHE_TYPE_MANUAL	0
 #define	G_CACHE_TYPE_AUTOMATIC	1
 
-#define	G_CACHE_DEBUG(lvl, ...)	do {					\
-	if (g_cache_debug >= (lvl)) {					\
-		printf("GEOM_CACHE");					\
-		if (g_cache_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	G_CACHE_LOGREQ(bp, ...)	do {					\
-	if (g_cache_debug >= 2) {					\
-		printf("GEOM_CACHE[2]: ");				\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define G_CACHE_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_CACHE", g_cache_debug, (lvl), NULL, __VA_ARGS__)
+#define G_CACHE_LOGREQ(bp, ...) \
+    _GEOM_DEBUG("GEOM_CACHE", g_cache_debug, 2, (bp), __VA_ARGS__)
 
 #define	G_CACHE_BUCKETS		(1 << 3)
 #define	G_CACHE_BUCKET(bno)	((bno) & (G_CACHE_BUCKETS - 1))

Modified: head/sys/geom/concat/g_concat.c
==============================================================================
--- head/sys/geom/concat/g_concat.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/concat/g_concat.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/malloc.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/concat/g_concat.h>
 
 FEATURE(geom_concat, "GEOM concatenation support");

Modified: head/sys/geom/concat/g_concat.h
==============================================================================
--- head/sys/geom/concat/g_concat.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/concat/g_concat.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -49,25 +49,10 @@
 #define	G_CONCAT_TYPE_MANUAL	0
 #define	G_CONCAT_TYPE_AUTOMATIC	1
 
-#define	G_CONCAT_DEBUG(lvl, ...)	do {				\
-	if (g_concat_debug >= (lvl)) {					\
-		printf("GEOM_CONCAT");					\
-		if (g_concat_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	G_CONCAT_LOGREQ(bp, ...)	do {				\
-	if (g_concat_debug >= 2) {					\
-		printf("GEOM_CONCAT[2]: ");				\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define G_CONCAT_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_CONCAT", g_concat_debug, (lvl), NULL, __VA_ARGS__)
+#define G_CONCAT_LOGREQ(bp, ...) \
+    _GEOM_DEBUG("GEOM_CONCAT", g_concat_debug, 2, (bp), __VA_ARGS__)
 
 struct g_concat_disk {
 	struct g_consumer	*d_consumer;

Modified: head/sys/geom/eli/g_eli.c
==============================================================================
--- head/sys/geom/eli/g_eli.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/eli/g_eli.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/uma.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/eli/g_eli.h>
 #include <geom/eli/pkcs5v2.h>
 

Modified: head/sys/geom/eli/g_eli.h
==============================================================================
--- head/sys/geom/eli/g_eli.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/eli/g_eli.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -155,28 +155,10 @@ extern int g_eli_debug;
 extern u_int g_eli_overwrites;
 extern u_int g_eli_batch;
 
-#define	G_ELI_DEBUG(lvl, ...)	do {					\
-	if (g_eli_debug >= (lvl)) {					\
-		printf("GEOM_ELI");					\
-		if (g_eli_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	G_ELI_LOGREQ(lvl, bp, ...)	do {				\
-	if (g_eli_debug >= (lvl)) {					\
-		printf("GEOM_ELI");					\
-		if (g_eli_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	G_ELI_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_ELI", g_eli_debug, (lvl), NULL, __VA_ARGS__)
+#define	G_ELI_LOGREQ(lvl, bp, ...) \
+    _GEOM_DEBUG("GEOM_ELI", g_eli_debug, (lvl), (bp), __VA_ARGS__)
 
 struct g_eli_worker {
 	struct g_eli_softc	*w_softc;

Modified: head/sys/geom/eli/g_eli_ctl.c
==============================================================================
--- head/sys/geom/eli/g_eli_ctl.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/eli/g_eli_ctl.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/uma.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/eli/g_eli.h>
 
 

Modified: head/sys/geom/eli/g_eli_integrity.c
==============================================================================
--- head/sys/geom/eli/g_eli_integrity.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/eli/g_eli_integrity.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/uma.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/eli/g_eli.h>
 #include <geom/eli/pkcs5v2.h>
 

Modified: head/sys/geom/eli/g_eli_privacy.c
==============================================================================
--- head/sys/geom/eli/g_eli_privacy.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/eli/g_eli_privacy.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/uma.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/eli/g_eli.h>
 #include <geom/eli/pkcs5v2.h>
 

Modified: head/sys/geom/gate/g_gate.c
==============================================================================
--- head/sys/geom/gate/g_gate.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/gate/g_gate.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/atomic.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/gate/g_gate.h>
 
 FEATURE(geom_gate, "GEOM Gate module");

Modified: head/sys/geom/gate/g_gate.h
==============================================================================
--- head/sys/geom/gate/g_gate.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/gate/g_gate.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -103,28 +103,10 @@ struct g_gate_softc {
 	char			 sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */
 };
 
-#define	G_GATE_DEBUG(lvl, ...)	do {					\
-	if (g_gate_debug >= (lvl)) {					\
-		printf("GEOM_GATE");					\
-		if (g_gate_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	G_GATE_LOGREQ(lvl, bp, ...)	do {				\
-	if (g_gate_debug >= (lvl)) {					\
-		printf("GEOM_GATE");					\
-		if (g_gate_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	G_GATE_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_GATE", g_gate_debug, (lvl), NULL, __VA_ARGS__)
+#define	G_GATE_LOGREQ(lvl, bp, ...) \
+    _GEOM_DEBUG("GEOM_GATE", g_gate_debug, (lvl), (bp), __VA_ARGS__)
 #endif	/* !_KERNEL */
 
 struct g_gate_ctl_create {

Modified: head/sys/geom/geom.h
==============================================================================
--- head/sys/geom/geom.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/geom.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -345,7 +345,8 @@ 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);
-void g_print_bio(struct bio *bp);
+void g_format_bio(struct sbuf *, const struct bio *bp);
+void g_print_bio(const char *prefix, const struct bio *bp, const char *fmtsuffix, ...) __printflike(3, 4);
 int g_use_g_read_data(void *, off_t, void **, int);
 int g_use_g_write_data(void *, off_t, void *, int);
 

Added: head/sys/geom/geom_dbg.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/geom/geom_dbg.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -0,0 +1,49 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Conrad Meyer <cem at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#pragma once
+
+#ifdef _KERNEL
+
+#define _GEOM_DEBUG(classname, ctrlvar, loglvl, biop, formatstr, ...)	\
+do {									\
+	const int __control = (ctrlvar);				\
+	const int __level = (loglvl);					\
+									\
+	if (__control < __level)					\
+		break;							\
+									\
+	g_dbg_printf((classname), (__control > 0) ? __level : -1,	\
+	    (biop), ": " formatstr, ## __VA_ARGS__);			\
+} while (0)
+
+void g_dbg_printf(const char *classname, int lvl, struct bio *bp,
+    const char *format, ...) __printflike(4, 5);
+
+#endif /* _KERNEL */

Modified: head/sys/geom/geom_io.c
==============================================================================
--- head/sys/geom/geom_io.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/geom_io.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -49,9 +49,11 @@ __FBSDID("$FreeBSD$");
 #include <sys/bio.h>
 #include <sys/ktr.h>
 #include <sys/proc.h>
+#include <sys/sbuf.h>
 #include <sys/stack.h>
 #include <sys/sysctl.h>
 #include <sys/vmem.h>
+#include <machine/stdarg.h>
 
 #include <sys/errno.h>
 #include <geom/geom.h>
@@ -1029,8 +1031,37 @@ g_delete_data(struct g_consumer *cp, off_t offset, off
 }
 
 void
-g_print_bio(struct bio *bp)
+g_print_bio(const char *prefix, const struct bio *bp, const char *fmtsuffix,
+    ...)
 {
+#ifndef PRINTF_BUFR_SIZE
+#define PRINTF_BUFR_SIZE 64
+#endif
+	char bufr[PRINTF_BUFR_SIZE];
+	struct sbuf sb, *sbp __unused;
+	va_list ap;
+
+	sbp = sbuf_new(&sb, bufr, sizeof(bufr), SBUF_FIXEDLEN);
+	KASSERT(sbp != NULL, ("sbuf_new misused?"));
+
+	sbuf_set_drain(&sb, sbuf_printf_drain, NULL);
+
+	sbuf_cat(&sb, prefix);
+	g_format_bio(&sb, bp);
+
+	va_start(ap, fmtsuffix);
+	sbuf_vprintf(&sb, fmtsuffix, ap);
+	va_end(ap);
+
+	sbuf_nl_terminate(&sb);
+
+	sbuf_finish(&sb);
+	sbuf_delete(&sb);
+}
+
+void
+g_format_bio(struct sbuf *sb, const struct bio *bp)
+{
 	const char *pname, *cmd = NULL;
 
 	if (bp->bio_to != NULL)
@@ -1041,11 +1072,12 @@ g_print_bio(struct bio *bp)
 	switch (bp->bio_cmd) {
 	case BIO_GETATTR:
 		cmd = "GETATTR";
-		printf("%s[%s(attr=%s)]", pname, cmd, bp->bio_attribute);
+		sbuf_printf(sb, "%s[%s(attr=%s)]", pname, cmd,
+		    bp->bio_attribute);
 		return;
 	case BIO_FLUSH:
 		cmd = "FLUSH";
-		printf("%s[%s]", pname, cmd);
+		sbuf_printf(sb, "%s[%s]", pname, cmd);
 		return;
 	case BIO_ZONE: {
 		char *subcmd = NULL;
@@ -1073,7 +1105,7 @@ g_print_bio(struct bio *bp)
 			subcmd = "UNKNOWN";
 			break;
 		}
-		printf("%s[%s,%s]", pname, cmd, subcmd);
+		sbuf_printf(sb, "%s[%s,%s]", pname, cmd, subcmd);
 		return;
 	}
 	case BIO_READ:
@@ -1087,9 +1119,9 @@ g_print_bio(struct bio *bp)
 		break;
 	default:
 		cmd = "UNKNOWN";
-		printf("%s[%s()]", pname, cmd);
+		sbuf_printf(sb, "%s[%s()]", pname, cmd);
 		return;
 	}
-	printf("%s[%s(offset=%jd, length=%jd)]", pname, cmd,
+	sbuf_printf(sb, "%s[%s(offset=%jd, length=%jd)]", pname, cmd,
 	    (intmax_t)bp->bio_offset, (intmax_t)bp->bio_length);
 }

Modified: head/sys/geom/geom_subr.c
==============================================================================
--- head/sys/geom/geom_subr.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/geom_subr.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/errno.h>
 #include <sys/sbuf.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/geom_int.h>
 #include <machine/stdarg.h>
 
@@ -76,6 +77,44 @@ struct g_hh00 {
 	int			error;
 	int			post;
 };
+
+void
+g_dbg_printf(const char *classname, int lvl, struct bio *bp,
+    const char *format,
+    ...)
+{
+#ifndef PRINTF_BUFR_SIZE
+#define PRINTF_BUFR_SIZE 64
+#endif
+	char bufr[PRINTF_BUFR_SIZE];
+	struct sbuf sb, *sbp __unused;
+	va_list ap;
+
+	sbp = sbuf_new(&sb, bufr, sizeof(bufr), SBUF_FIXEDLEN);
+	KASSERT(sbp != NULL, ("sbuf_new misused?"));
+
+	sbuf_set_drain(&sb, sbuf_printf_drain, NULL);
+
+	sbuf_cat(&sb, classname);
+	if (lvl >= 0)
+		sbuf_printf(&sb, "[%d]", lvl);
+	
+	va_start(ap, format);
+	sbuf_vprintf(&sb, format, ap);
+	va_end(ap);
+
+	if (bp != NULL) {
+		sbuf_putc(&sb, ' ');
+		g_format_bio(&sb, bp);
+	}
+
+	/* Terminate the debug line with a single '\n'. */
+	sbuf_nl_terminate(&sb);
+
+	/* Flush line to printf. */
+	sbuf_finish(&sb);
+	sbuf_delete(&sb);
+}
 
 /*
  * This event offers a new class a chance to taste all preexisting providers.

Modified: head/sys/geom/geom_vfs.c
==============================================================================
--- head/sys/geom/geom_vfs.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/geom_vfs.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mutex.h>
+#include <sys/sbuf.h>
 #include <sys/vnode.h>
 #include <sys/mount.h>
 
@@ -138,11 +139,9 @@ g_vfs_done(struct bio *bip)
 
 	cp = bip->bio_from;
 	sc = cp->geom->softc;
-	if (bip->bio_error) {
-		printf("g_vfs_done():");
-		g_print_bio(bip);
-		printf("error = %d\n", bip->bio_error);
-	}
+	if (bip->bio_error)
+		g_print_bio("g_vfs_done():", bip, "error = %d",
+		    bip->bio_error);
 	bp->b_error = bip->bio_error;
 	bp->b_ioflags = bip->bio_flags;
 	if (bip->bio_error)

Modified: head/sys/geom/journal/g_journal.c
==============================================================================
--- head/sys/geom/journal/g_journal.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/journal/g_journal.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm.h>
 #include <vm/vm_kern.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 
 #include <geom/journal/g_journal.h>
 

Modified: head/sys/geom/journal/g_journal.h
==============================================================================
--- head/sys/geom/journal/g_journal.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/journal/g_journal.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -49,28 +49,10 @@
 #ifdef _KERNEL
 extern int g_journal_debug;
 
-#define	GJ_DEBUG(lvl, ...)	do {					\
-	if (g_journal_debug >= (lvl)) {					\
-		printf("GEOM_JOURNAL");					\
-		if (g_journal_debug > 0)				\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	GJ_LOGREQ(lvl, bp, ...)	do {					\
-	if (g_journal_debug >= (lvl)) {					\
-		printf("GEOM_JOURNAL");					\
-		if (g_journal_debug > 0)				\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	GJ_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_JOURNAL", g_journal_debug, (lvl), NULL, __VA_ARGS__)
+#define	GJ_LOGREQ(lvl, bp, ...) \
+    _GEOM_DEBUG("GEOM_JOURNAL", g_journal_debug, (lvl), (bp), __VA_ARGS__)
 
 #define	JEMPTY(sc)	((sc)->sc_journal_offset -			\
 			 (sc)->sc_jprovider->sectorsize ==		\

Modified: head/sys/geom/journal/g_journal_ufs.c
==============================================================================
--- head/sys/geom/journal/g_journal_ufs.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/journal/g_journal_ufs.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <ufs/ffs/ffs_extern.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/journal/g_journal.h>
 
 static int

Modified: head/sys/geom/label/g_label.c
==============================================================================
--- head/sys/geom/label/g_label.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/stddef.h>
 #include <sys/sysctl.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/geom_slice.h>
 #include <geom/label/g_label.h>
 

Modified: head/sys/geom/label/g_label.h
==============================================================================
--- head/sys/geom/label/g_label.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -50,16 +50,8 @@
 #ifdef _KERNEL
 extern u_int g_label_debug;
 
-#define	G_LABEL_DEBUG(lvl, ...)	do {					\
-	if (g_label_debug >= (lvl)) {					\
-		printf("GEOM_LABEL");					\
-		if (g_label_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define G_LABEL_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_LABEL", g_label_debug, (lvl), NULL, __VA_ARGS__)
 
 SYSCTL_DECL(_kern_geom_label);
 

Modified: head/sys/geom/label/g_label_ext2fs.c
==============================================================================
--- head/sys/geom/label/g_label_ext2fs.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label_ext2fs.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/label/g_label.h>
 
 #define EXT2FS_SB_OFFSET	1024

Modified: head/sys/geom/label/g_label_iso9660.c
==============================================================================
--- head/sys/geom/label/g_label_iso9660.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label_iso9660.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/label/g_label.h>
 
 #define G_LABEL_ISO9660_DIR	"iso9660"

Modified: head/sys/geom/label/g_label_msdosfs.c
==============================================================================
--- head/sys/geom/label/g_label_msdosfs.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label_msdosfs.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/label/g_label.h>
 #include <geom/label/g_label_msdosfs.h>
 

Modified: head/sys/geom/label/g_label_reiserfs.c
==============================================================================
--- head/sys/geom/label/g_label_reiserfs.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label_reiserfs.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/label/g_label.h>
 
 #define REISERFS_NEW_DISK_OFFSET 64 * 1024

Modified: head/sys/geom/label/g_label_ufs.c
==============================================================================
--- head/sys/geom/label/g_label_ufs.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/label/g_label_ufs.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <ufs/ffs/ffs_extern.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/label/g_label.h>
 
 #define G_LABEL_UFS_VOLUME_DIR	"ufs"

Modified: head/sys/geom/linux_lvm/g_linux_lvm.c
==============================================================================
--- head/sys/geom/linux_lvm/g_linux_lvm.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/linux_lvm/g_linux_lvm.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <sys/endian.h>
 
 #include <geom/linux_lvm/g_linux_lvm.h>

Modified: head/sys/geom/linux_lvm/g_linux_lvm.h
==============================================================================
--- head/sys/geom/linux_lvm/g_linux_lvm.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/linux_lvm/g_linux_lvm.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -28,16 +28,8 @@
  * $FreeBSD$
  */
 
-#define	G_LLVM_DEBUG(lvl, ...)	do {					\
-	if (g_llvm_debug >= (lvl)) {					\
-		printf("GEOM_LINUX_LVM");				\
-		if (g_llvm_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	G_LLVM_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_LINUX_LVM", g_llvm_debug, (lvl), NULL, __VA_ARGS__)
 
 #define	G_LLVM_CLASS_NAME	"LINUX_LVM"
 #define	G_LLVM_NAMELEN		128

Modified: head/sys/geom/mirror/g_mirror.c
==============================================================================
--- head/sys/geom/mirror/g_mirror.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/mirror/g_mirror.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/mirror/g_mirror.h>
 
 FEATURE(geom_mirror, "GEOM mirroring support");

Modified: head/sys/geom/mirror/g_mirror.h
==============================================================================
--- head/sys/geom/mirror/g_mirror.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/mirror/g_mirror.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -86,28 +86,10 @@
 
 extern int g_mirror_debug;
 
-#define	G_MIRROR_DEBUG(lvl, ...)	do {				\
-	if (g_mirror_debug >= (lvl)) {					\
-		printf("GEOM_MIRROR");					\
-		if (g_mirror_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	G_MIRROR_LOGREQ(lvl, bp, ...)	do {				\
-	if (g_mirror_debug >= (lvl)) {					\
-		printf("GEOM_MIRROR");					\
-		if (g_mirror_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define G_MIRROR_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_MIRROR", g_mirror_debug, (lvl), NULL, __VA_ARGS__)
+#define G_MIRROR_LOGREQ(lvl, bp, ...) \
+    _GEOM_DEBUG("GEOM_MIRROR", g_mirror_debug, (lvl), (bp), __VA_ARGS__)
 
 #define	G_MIRROR_BIO_FLAG_REGULAR	0x01
 #define	G_MIRROR_BIO_FLAG_SYNC		0x02

Modified: head/sys/geom/mirror/g_mirror_ctl.c
==============================================================================
--- head/sys/geom/mirror/g_mirror_ctl.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/mirror/g_mirror_ctl.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sx.h>
 
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/geom_int.h>
 #include <geom/mirror/g_mirror.h>
 

Modified: head/sys/geom/mountver/g_mountver.c
==============================================================================
--- head/sys/geom/mountver/g_mountver.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/mountver/g_mountver.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/eventhandler.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/mountver/g_mountver.h>
 
 

Modified: head/sys/geom/mountver/g_mountver.h
==============================================================================
--- head/sys/geom/mountver/g_mountver.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/mountver/g_mountver.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -38,25 +38,10 @@
 
 #ifdef _KERNEL
 
-#define	G_MOUNTVER_DEBUG(lvl, ...)	do {				\
-	if (g_mountver_debug >= (lvl)) {				\
-		printf("GEOM_MOUNTVER");				\
-		if (g_mountver_debug > 0)				\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-#define	G_MOUNTVER_LOGREQ(bp, ...)	do {				\
-	if (g_mountver_debug >= 2) {					\
-		printf("GEOM_MOUNTVER[2]: ");				\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	G_MOUNTVER_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_MOUNTVER", g_mountver_debug, (lvl), NULL, __VA_ARGS__)
+#define	G_MOUNTVER_LOGREQ(bp, ...) \
+    _GEOM_DEBUG("GEOM_MOUNTVER", g_mountver_debug, 2, (bp), __VA_ARGS__)
 
 struct g_mountver_softc {
 	TAILQ_HEAD(, bio)		sc_queue;

Modified: head/sys/geom/nop/g_nop.c
==============================================================================
--- head/sys/geom/nop/g_nop.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/nop/g_nop.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/malloc.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <geom/nop/g_nop.h>
 
 

Modified: head/sys/geom/nop/g_nop.h
==============================================================================
--- head/sys/geom/nop/g_nop.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/nop/g_nop.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -41,26 +41,11 @@
 #define G_NOP_PHYSPATH_PASSTHROUGH "\255"
 
 #ifdef _KERNEL
-#define	G_NOP_DEBUG(lvl, ...)	do {					\
-	if (g_nop_debug >= (lvl)) {					\
-		printf("GEOM_NOP");					\
-		if (g_nop_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	G_NOP_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_NOP", g_nop_debug, (lvl), NULL, __VA_ARGS__)
+#define G_NOP_LOGREQLVL(lvl, bp, ...) \
+    _GEOM_DEBUG("GEOM_NOP", g_nop_debug, (lvl), (bp), __VA_ARGS__)
 #define	G_NOP_LOGREQ(bp, ...)	G_NOP_LOGREQLVL(2, bp, __VA_ARGS__)
-#define G_NOP_LOGREQLVL(lvl, bp, ...) do {				\
-	if (g_nop_debug >= (lvl)) {					\
-		printf("GEOM_NOP[%d]: ", (lvl));			\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
 
 struct g_nop_delay;
 

Modified: head/sys/geom/raid/g_raid.c
==============================================================================
--- head/sys/geom/raid/g_raid.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/g_raid.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/eventhandler.h>
 #include <vm/uma.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include <sys/proc.h>
 #include <sys/kthread.h>
 #include <sys/sched.h>

Modified: head/sys/geom/raid/g_raid.h
==============================================================================
--- head/sys/geom/raid/g_raid.h	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/g_raid.h	Wed Aug  7 19:28:35 2019	(r350694)
@@ -61,39 +61,13 @@ extern int g_raid_read_err_thresh;
 extern u_int g_raid_start_timeout;
 extern struct g_class g_raid_class;
 
-#define	G_RAID_DEBUG(lvl, fmt, ...)	do {				\
-	if (g_raid_debug >= (lvl)) {					\
-		if (g_raid_debug > 0) {					\
-			printf("GEOM_RAID[%u]: " fmt "\n",		\
-			    lvl, ## __VA_ARGS__);			\
-		} else {						\
-			printf("GEOM_RAID: " fmt "\n",			\
-			    ## __VA_ARGS__);				\
-		}							\
-	}								\
-} while (0)
-#define	G_RAID_DEBUG1(lvl, sc, fmt, ...)	do {			\
-	if (g_raid_debug >= (lvl)) {					\
-		if (g_raid_debug > 0) {					\
-			printf("GEOM_RAID[%u]: %s: " fmt "\n",		\
-			    lvl, (sc)->sc_name, ## __VA_ARGS__);	\
-		} else {						\
-			printf("GEOM_RAID: %s: " fmt "\n",		\
-			    (sc)->sc_name, ## __VA_ARGS__);		\
-		}							\
-	}								\
-} while (0)
-#define	G_RAID_LOGREQ(lvl, bp, fmt, ...)	do {			\
-	if (g_raid_debug >= (lvl)) {					\
-		if (g_raid_debug > 0) {					\
-			printf("GEOM_RAID[%u]: " fmt " ",		\
-			    lvl, ## __VA_ARGS__);			\
-		} else							\
-			printf("GEOM_RAID: " fmt " ", ## __VA_ARGS__);	\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+#define	G_RAID_DEBUG(lvl, ...) \
+    _GEOM_DEBUG("GEOM_RAID", g_raid_debug, (lvl), NULL, __VA_ARGS__)
+#define	G_RAID_DEBUG1(lvl, sc, fmt, ...)				\
+    _GEOM_DEBUG("GEOM_RAID", g_raid_debug, (lvl), NULL, "%s: " fmt,	\
+	(sc)->sc_name, ## __VA_ARGS__)
+#define	G_RAID_LOGREQ(lvl, bp, ...) \
+    _GEOM_DEBUG("GEOM_RAID", g_raid_debug, (lvl), (bp), __VA_ARGS__)
 
 /*
  * Flags we use to distinguish I/O initiated by the TR layer to maintain

Modified: head/sys/geom/raid/md_ddf.c
==============================================================================
--- head/sys/geom/raid/md_ddf.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/md_ddf.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/clock.h>
 #include <sys/disk.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "geom/raid/md_ddf.h"
 #include "g_raid_md_if.h"

Modified: head/sys/geom/raid/md_intel.c
==============================================================================
--- head/sys/geom/raid/md_intel.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/md_intel.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/taskqueue.h>
 #include <sys/disk.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_md_if.h"
 

Modified: head/sys/geom/raid/md_jmicron.c
==============================================================================
--- head/sys/geom/raid/md_jmicron.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/md_jmicron.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/taskqueue.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_md_if.h"
 

Modified: head/sys/geom/raid/md_nvidia.c
==============================================================================
--- head/sys/geom/raid/md_nvidia.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/md_nvidia.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/taskqueue.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_md_if.h"
 

Modified: head/sys/geom/raid/md_promise.c
==============================================================================
--- head/sys/geom/raid/md_promise.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/md_promise.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/systm.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_md_if.h"
 

Modified: head/sys/geom/raid/md_sii.c
==============================================================================
--- head/sys/geom/raid/md_sii.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/md_sii.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/taskqueue.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_md_if.h"
 

Modified: head/sys/geom/raid/tr_concat.c
==============================================================================
--- head/sys/geom/raid/tr_concat.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/tr_concat.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/systm.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_tr_if.h"
 

Modified: head/sys/geom/raid/tr_raid0.c
==============================================================================
--- head/sys/geom/raid/tr_raid0.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/tr_raid0.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/systm.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_tr_if.h"
 

Modified: head/sys/geom/raid/tr_raid1.c
==============================================================================
--- head/sys/geom/raid/tr_raid1.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/tr_raid1.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <geom/geom.h>
+#include <geom/geom_dbg.h>
 #include "geom/raid/g_raid.h"
 #include "g_raid_tr_if.h"
 

Modified: head/sys/geom/raid/tr_raid1e.c
==============================================================================
--- head/sys/geom/raid/tr_raid1e.c	Wed Aug  7 19:27:14 2019	(r350693)
+++ head/sys/geom/raid/tr_raid1e.c	Wed Aug  7 19:28:35 2019	(r350694)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/systm.h>

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list