diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2019-08-07 19:28:35 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2019-08-07 19:28:35 +0000 |
commit | ac03832ef3afa26cc8e23bf5cfeaa32501b21c3e (patch) | |
tree | 099c85706b554866296760b5ba97548aaa140133 | |
parent | 76cb1112da20279c59bc8189519c4122a4d0d96a (diff) |
Notes
73 files changed, 279 insertions, 368 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 61be7beca9ebb..249a988918def 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -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 diff --git a/share/man/man9/g_bio.9 b/share/man/man9/g_bio.9 index e23cebab2daf6..9b317416303b0 100644 --- a/share/man/man9/g_bio.9 +++ b/share/man/man9/g_bio.9 @@ -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,7 +49,12 @@ .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 @@ -204,10 +210,28 @@ 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 @@ -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) { diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 6e683b9984815..ab938725c0899 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -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; diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c index 6ea9606721c68..38d68a81cbcc6 100644 --- a/sys/geom/cache/g_cache.c +++ b/sys/geom/cache/g_cache.c @@ -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"); diff --git a/sys/geom/cache/g_cache.h b/sys/geom/cache/g_cache.h index c3b0e86fefbf4..60caf19a4a8da 100644 --- a/sys/geom/cache/g_cache.h +++ b/sys/geom/cache/g_cache.h @@ -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)) diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c index e686ffc512850..13a2fee871baa 100644 --- a/sys/geom/concat/g_concat.c +++ b/sys/geom/concat/g_concat.c @@ -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"); diff --git a/sys/geom/concat/g_concat.h b/sys/geom/concat/g_concat.h index da7b6ff722029..32e60b1b4cb20 100644 --- a/sys/geom/concat/g_concat.h +++ b/sys/geom/concat/g_concat.h @@ -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; diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index f756b158128e0..32a91f202dae2 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -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> diff --git a/sys/geom/eli/g_eli.h b/sys/geom/eli/g_eli.h index fbf81ceabcce3..e387782d949b7 100644 --- a/sys/geom/eli/g_eli.h +++ b/sys/geom/eli/g_eli.h @@ -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; diff --git a/sys/geom/eli/g_eli_ctl.c b/sys/geom/eli/g_eli_ctl.c index b62ff5376f77b..d95b7f49ca41b 100644 --- a/sys/geom/eli/g_eli_ctl.c +++ b/sys/geom/eli/g_eli_ctl.c @@ -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> diff --git a/sys/geom/eli/g_eli_integrity.c b/sys/geom/eli/g_eli_integrity.c index f95cb6f14a790..abb7279a7f466 100644 --- a/sys/geom/eli/g_eli_integrity.c +++ b/sys/geom/eli/g_eli_integrity.c @@ -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> diff --git a/sys/geom/eli/g_eli_privacy.c b/sys/geom/eli/g_eli_privacy.c index 6dbda7f0ef035..0a9e809e8b350 100644 --- a/sys/geom/eli/g_eli_privacy.c +++ b/sys/geom/eli/g_eli_privacy.c @@ -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> diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index 8c9b1a91098e4..e3b35deb2b79e 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -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"); diff --git a/sys/geom/gate/g_gate.h b/sys/geom/gate/g_gate.h index 34c6738f8d6e3..2c466c1779109 100644 --- a/sys/geom/gate/g_gate.h +++ b/sys/geom/gate/g_gate.h @@ -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 { diff --git a/sys/geom/geom.h b/sys/geom/geom.h index e4f0ed095eafb..b13e59d9b6d98 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -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); diff --git a/sys/geom/geom_dbg.h b/sys/geom/geom_dbg.h new file mode 100644 index 0000000000000..455d80f455777 --- /dev/null +++ b/sys/geom/geom_dbg.h @@ -0,0 +1,49 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Conrad Meyer <cem@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 */ diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 58bf324e0e3e5..bdade2855f8e5 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -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,7 +1031,36 @@ g_delete_data(struct g_consumer *cp, off_t offset, off_t length) } 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; @@ -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); } diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index f703e3473ab33..d829b54aa2b9f 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -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> @@ -77,6 +78,44 @@ struct g_hh00 { 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. */ diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c index 7448ed3cea65a..928ffc7e1b66c 100644 --- a/sys/geom/geom_vfs.c +++ b/sys/geom/geom_vfs.c @@ -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) diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 8ed8b8d699658..3f5e3ddcd4066 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -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> diff --git a/sys/geom/journal/g_journal.h b/sys/geom/journal/g_journal.h index cc5ae183f683d..fa6127537c368 100644 --- a/sys/geom/journal/g_journal.h +++ b/sys/geom/journal/g_journal.h @@ -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 == \ diff --git a/sys/geom/journal/g_journal_ufs.c b/sys/geom/journal/g_journal_ufs.c index 028c680794828..dbb4166016774 100644 --- a/sys/geom/journal/g_journal_ufs.c +++ b/sys/geom/journal/g_journal_ufs.c @@ -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 diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c index a61a39ae094c0..c37ca3511890c 100644 --- a/sys/geom/label/g_label.c +++ b/sys/geom/label/g_label.c @@ -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> diff --git a/sys/geom/label/g_label.h b/sys/geom/label/g_label.h index 94dbeff2d57b8..77c89b589e8f3 100644 --- a/sys/geom/label/g_label.h +++ b/sys/geom/label/g_label.h @@ -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); diff --git a/sys/geom/label/g_label_ext2fs.c b/sys/geom/label/g_label_ext2fs.c index 776fdc1ec47ae..783ea0c4e61ef 100644 --- a/sys/geom/label/g_label_ext2fs.c +++ b/sys/geom/label/g_label_ext2fs.c @@ -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 diff --git a/sys/geom/label/g_label_iso9660.c b/sys/geom/label/g_label_iso9660.c index 32486d69d9fa2..3b1926696a6f6 100644 --- a/sys/geom/label/g_label_iso9660.c +++ b/sys/geom/label/g_label_iso9660.c @@ -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" diff --git a/sys/geom/label/g_label_msdosfs.c b/sys/geom/label/g_label_msdosfs.c index ca70bfcaef04a..d78f728f4c4aa 100644 --- a/sys/geom/label/g_label_msdosfs.c +++ b/sys/geom/label/g_label_msdosfs.c @@ -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> diff --git a/sys/geom/label/g_label_reiserfs.c b/sys/geom/label/g_label_reiserfs.c index 36e307e98abf6..385f906035b8f 100644 --- a/sys/geom/label/g_label_reiserfs.c +++ b/sys/geom/label/g_label_reiserfs.c @@ -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 diff --git a/sys/geom/label/g_label_ufs.c b/sys/geom/label/g_label_ufs.c index 2b4871379fe15..8b90b70a40a9a 100644 --- a/sys/geom/label/g_label_ufs.c +++ b/sys/geom/label/g_label_ufs.c @@ -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" diff --git a/sys/geom/linux_lvm/g_linux_lvm.c b/sys/geom/linux_lvm/g_linux_lvm.c index 06fdfbcf78784..d96ef264ee0fa 100644 --- a/sys/geom/linux_lvm/g_linux_lvm.c +++ b/sys/geom/linux_lvm/g_linux_lvm.c @@ -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> diff --git a/sys/geom/linux_lvm/g_linux_lvm.h b/sys/geom/linux_lvm/g_linux_lvm.h index 043f164fe8a5d..9133a982a782e 100644 --- a/sys/geom/linux_lvm/g_linux_lvm.h +++ b/sys/geom/linux_lvm/g_linux_lvm.h @@ -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 diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 0fd9fe33ba786..0ab933eca6007 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -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"); diff --git a/sys/geom/mirror/g_mirror.h b/sys/geom/mirror/g_mirror.h index 370715a831e00..57f341f752e1c 100644 --- a/sys/geom/mirror/g_mirror.h +++ b/sys/geom/mirror/g_mirror.h @@ -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 diff --git a/sys/geom/mirror/g_mirror_ctl.c b/sys/geom/mirror/g_mirror_ctl.c index 2d598d944d27e..cf362d4ffb5ef 100644 --- a/sys/geom/mirror/g_mirror_ctl.c +++ b/sys/geom/mirror/g_mirror_ctl.c @@ -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> diff --git a/sys/geom/mountver/g_mountver.c b/sys/geom/mountver/g_mountver.c index c3d57e8f2070c..22dcc965e5dc7 100644 --- a/sys/geom/mountver/g_mountver.c +++ b/sys/geom/mountver/g_mountver.c @@ -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> diff --git a/sys/geom/mountver/g_mountver.h b/sys/geom/mountver/g_mountver.h index 6d7c2d7241c5a..34ca831384f63 100644 --- a/sys/geom/mountver/g_mountver.h +++ b/sys/geom/mountver/g_mountver.h @@ -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; diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c index fca272e2363d9..6c7706b52cd35 100644 --- a/sys/geom/nop/g_nop.c +++ b/sys/geom/nop/g_nop.c @@ -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> diff --git a/sys/geom/nop/g_nop.h b/sys/geom/nop/g_nop.h index 95894bc1283f9..d7649ac1c23f9 100644 --- a/sys/geom/nop/g_nop.h +++ b/sys/geom/nop/g_nop.h @@ -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; diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index 85e237f95b664..1de716a1eca09 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -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> diff --git a/sys/geom/raid/g_raid.h b/sys/geom/raid/g_raid.h index e693e3c00504c..96cddd377d1ed 100644 --- a/sys/geom/raid/g_raid.h +++ b/sys/geom/raid/g_raid.h @@ -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 diff --git a/sys/geom/raid/md_ddf.c b/sys/geom/raid/md_ddf.c index a731da89d8eaa..3d3e460d1eb28 100644 --- a/sys/geom/raid/md_ddf.c +++ b/sys/geom/raid/md_ddf.c @@ -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" diff --git a/sys/geom/raid/md_intel.c b/sys/geom/raid/md_intel.c index 91af664bb63f1..50bd6c76d0585 100644 --- a/sys/geom/raid/md_intel.c +++ b/sys/geom/raid/md_intel.c @@ -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" diff --git a/sys/geom/raid/md_jmicron.c b/sys/geom/raid/md_jmicron.c index 5d73d4fe183ce..236ac6e02bad4 100644 --- a/sys/geom/raid/md_jmicron.c +++ b/sys/geom/raid/md_jmicron.c @@ -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" diff --git a/sys/geom/raid/md_nvidia.c b/sys/geom/raid/md_nvidia.c index 7d84b1750b3db..0aacbd47962fa 100644 --- a/sys/geom/raid/md_nvidia.c +++ b/sys/geom/raid/md_nvidia.c @@ -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" diff --git a/sys/geom/raid/md_promise.c b/sys/geom/raid/md_promise.c index edbcd074184fe..f0708111e0ac3 100644 --- a/sys/geom/raid/md_promise.c +++ b/sys/geom/raid/md_promise.c @@ -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" diff --git a/sys/geom/raid/md_sii.c b/sys/geom/raid/md_sii.c index a767f235564d0..b54c97a304193 100644 --- a/sys/geom/raid/md_sii.c +++ b/sys/geom/raid/md_sii.c @@ -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" diff --git a/sys/geom/raid/tr_concat.c b/sys/geom/raid/tr_concat.c index 97d7111fe8017..57314d84ccbcd 100644 --- a/sys/geom/raid/tr_concat.c +++ b/sys/geom/raid/tr_concat.c @@ -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" diff --git a/sys/geom/raid/tr_raid0.c b/sys/geom/raid/tr_raid0.c index 33a802103f0c6..31d753fd297cf 100644 --- a/sys/geom/raid/tr_raid0.c +++ b/sys/geom/raid/tr_raid0.c @@ -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" diff --git a/sys/geom/raid/tr_raid1.c b/sys/geom/raid/tr_raid1.c index f754bf0251bd9..fa0e10767421b 100644 --- a/sys/geom/raid/tr_raid1.c +++ b/sys/geom/raid/tr_raid1.c @@ -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" diff --git a/sys/geom/raid/tr_raid1e.c b/sys/geom/raid/tr_raid1e.c index 58dd858ed8d8c..f0f73c37d4394 100644 --- a/sys/geom/raid/tr_raid1e.c +++ b/sys/geom/raid/tr_raid1e.c @@ -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" diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 02ec5b45c694a..1dd8a2e08d2be 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -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> diff --git a/sys/geom/raid3/g_raid3.h b/sys/geom/raid3/g_raid3.h index 005b388e021c6..8f0d92dee7ef4 100644 --- a/sys/geom/raid3/g_raid3.h +++ b/sys/geom/raid3/g_raid3.h @@ -69,28 +69,10 @@ #ifdef _KERNEL extern u_int g_raid3_debug; -#define G_RAID3_DEBUG(lvl, ...) do { \ - if (g_raid3_debug >= (lvl)) { \ - printf("GEOM_RAID3"); \ - if (g_raid3_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } \ -} while (0) -#define G_RAID3_LOGREQ(lvl, bp, ...) do { \ - if (g_raid3_debug >= (lvl)) { \ - printf("GEOM_RAID3"); \ - if (g_raid3_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf(" "); \ - g_print_bio(bp); \ - printf("\n"); \ - } \ -} while (0) +#define G_RAID3_DEBUG(lvl, ...) \ + _GEOM_DEBUG("GEOM_RAID3", g_raid3_debug, (lvl), NULL, __VA_ARGS__) +#define G_RAID3_LOGREQ(lvl, bp, ...) \ + _GEOM_DEBUG("GEOM_RAID3", g_raid3_debug, (lvl), (bp), __VA_ARGS__) #define G_RAID3_BIO_CFLAG_REGULAR 0x01 #define G_RAID3_BIO_CFLAG_SYNC 0x02 diff --git a/sys/geom/sched/g_sched.c b/sys/geom/sched/g_sched.c index 54a521d888656..537f581534b0e 100644 --- a/sys/geom/sched/g_sched.c +++ b/sys/geom/sched/g_sched.c @@ -118,6 +118,7 @@ #include <sys/malloc.h> #include <sys/proc.h> /* we access curthread */ #include <geom/geom.h> +#include <geom/geom_dbg.h> #include "gs_scheduler.h" #include "g_sched.h" /* geom hooks */ diff --git a/sys/geom/sched/g_sched.h b/sys/geom/sched/g_sched.h index 427fec41ff503..e2db2471c9ab0 100644 --- a/sys/geom/sched/g_sched.h +++ b/sys/geom/sched/g_sched.h @@ -44,26 +44,10 @@ #define G_SCHED_SUFFIX ".sched." #ifdef _KERNEL -#define G_SCHED_DEBUG(lvl, ...) do { \ - if (me.gs_debug >= (lvl)) { \ - printf("GEOM_SCHED"); \ - if (me.gs_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } \ -} while (0) - -#define G_SCHED_LOGREQ(bp, ...) do { \ - if (me.gs_debug >= 2) { \ - printf("GEOM_SCHED[2]: "); \ - printf(__VA_ARGS__); \ - printf(" "); \ - g_print_bio(bp); \ - printf("\n"); \ - } \ -} while (0) +#define G_SCHED_DEBUG(lvl, ...) \ + _GEOM_DEBUG("GEOM_SCHED", me.gs_debug, (lvl), NULL, __VA_ARGS__) +#define G_SCHED_LOGREQ(bp, ...) \ + _GEOM_DEBUG("GEOM_SCHED", me.gs_debug, 2, (bp), __VA_ARGS__) LIST_HEAD(g_hash, g_sched_class); diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c index fedf2bb9105bd..981b3ef9f2164 100644 --- a/sys/geom/shsec/g_shsec.c +++ b/sys/geom/shsec/g_shsec.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <vm/uma.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/shsec/g_shsec.h> FEATURE(geom_shsec, "GEOM shared secret device support"); diff --git a/sys/geom/shsec/g_shsec.h b/sys/geom/shsec/g_shsec.h index 942adcd7d1d72..7da43e0edde53 100644 --- a/sys/geom/shsec/g_shsec.h +++ b/sys/geom/shsec/g_shsec.h @@ -46,28 +46,10 @@ #ifdef _KERNEL #define G_SHSEC_BFLAG_FIRST 0x1 -#define G_SHSEC_DEBUG(lvl, ...) do { \ - if (g_shsec_debug >= (lvl)) { \ - printf("GEOM_SHSEC"); \ - if (g_shsec_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } \ -} while (0) -#define G_SHSEC_LOGREQ(lvl, bp, ...) do { \ - if (g_shsec_debug >= (lvl)) { \ - printf("GEOM_SHSEC"); \ - if (g_shsec_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf(" "); \ - g_print_bio(bp); \ - printf("\n"); \ - } \ -} while (0) +#define G_SHSEC_DEBUG(lvl, ...) \ + _GEOM_DEBUG("GEOM_SHSEC", g_shsec_debug, (lvl), NULL, __VA_ARGS__) +#define G_SHSEC_LOGREQ(lvl, bp, ...) \ + _GEOM_DEBUG("GEOM_SHSEC", g_shsec_debug, (lvl), (bp), __VA_ARGS__) struct g_shsec_softc { u_int sc_type; /* provider type */ diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 23873f778670a..91b8b362e319f 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <vm/uma.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/stripe/g_stripe.h> FEATURE(geom_stripe, "GEOM striping support"); diff --git a/sys/geom/stripe/g_stripe.h b/sys/geom/stripe/g_stripe.h index beef7fe24116c..90b97426713ca 100644 --- a/sys/geom/stripe/g_stripe.h +++ b/sys/geom/stripe/g_stripe.h @@ -49,25 +49,10 @@ #define G_STRIPE_TYPE_MANUAL 0 #define G_STRIPE_TYPE_AUTOMATIC 1 -#define G_STRIPE_DEBUG(lvl, ...) do { \ - if (g_stripe_debug >= (lvl)) { \ - printf("GEOM_STRIPE"); \ - if (g_stripe_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } \ -} while (0) -#define G_STRIPE_LOGREQ(bp, ...) do { \ - if (g_stripe_debug >= 2) { \ - printf("GEOM_STRIPE[2]: "); \ - printf(__VA_ARGS__); \ - printf(" "); \ - g_print_bio(bp); \ - printf("\n"); \ - } \ -} while (0) +#define G_STRIPE_DEBUG(lvl, ...) \ + _GEOM_DEBUG("GEOM_STRIPE", g_stripe_debug, (lvl), NULL, __VA_ARGS__) +#define G_STRIPE_LOGREQ(bp, ...) \ + _GEOM_DEBUG("GEOM_STRIPE", g_stripe_debug, 2, (bp), __VA_ARGS__) struct g_stripe_softc { u_int sc_type; /* provider type */ diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c index 76128de72510d..500b55a04f96f 100644 --- a/sys/geom/vinum/geom_vinum.c +++ b/sys/geom/vinum/geom_vinum.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> #include <geom/vinum/geom_vinum_raid5.h> diff --git a/sys/geom/vinum/geom_vinum.h b/sys/geom/vinum/geom_vinum.h index e6057efd0dabb..f9ddd6859e3bb 100644 --- a/sys/geom/vinum/geom_vinum.h +++ b/sys/geom/vinum/geom_vinum.h @@ -157,28 +157,9 @@ int gv_sync_complete(struct gv_plex *, struct bio *); extern u_int g_vinum_debug; -#define G_VINUM_DEBUG(lvl, ...) do { \ - if (g_vinum_debug >= (lvl)) { \ - printf("GEOM_VINUM"); \ - if (g_vinum_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } \ -} while (0) - -#define G_VINUM_LOGREQ(lvl, bp, ...) do { \ - if (g_vinum_debug >= (lvl)) { \ - printf("GEOM_VINUM"); \ - if (g_vinum_debug > 0) \ - printf("[%u]", lvl); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf(" "); \ - g_print_bio(bp); \ - printf("\n"); \ - } \ -} while (0) +#define G_VINUM_DEBUG(lvl, ...) \ + _GEOM_DEBUG("GEOM_VINUM", g_vinum_debug, (lvl), NULL, __VA_ARGS__) +#define G_VINUM_LOGREQ(lvl, bp, ...) \ + _GEOM_DEBUG("GEOM_VINUM", g_vinum_debug, (lvl), (bp), __VA_ARGS__) #endif /* !_GEOM_VINUM_H_ */ diff --git a/sys/geom/vinum/geom_vinum_create.c b/sys/geom/vinum/geom_vinum_create.c index 61a5f03dbf77e..036ce82c45e8a 100644 --- a/sys/geom/vinum/geom_vinum_create.c +++ b/sys/geom/vinum/geom_vinum_create.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_drive.c b/sys/geom/vinum/geom_vinum_drive.c index 9b6d17d3d6710..788dd9769326b 100644 --- a/sys/geom/vinum/geom_vinum_drive.c +++ b/sys/geom/vinum/geom_vinum_drive.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_events.c b/sys/geom/vinum/geom_vinum_events.c index 8d132d91d2c58..b316110925766 100644 --- a/sys/geom/vinum/geom_vinum_events.c +++ b/sys/geom/vinum/geom_vinum_events.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_init.c b/sys/geom/vinum/geom_vinum_init.c index 0f09c7c0d1b12..43dab4dd57b20 100644 --- a/sys/geom/vinum/geom_vinum_init.c +++ b/sys/geom/vinum/geom_vinum_init.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_move.c b/sys/geom/vinum/geom_vinum_move.c index 193812ac04d04..f2f38a69d1035 100644 --- a/sys/geom/vinum/geom_vinum_move.c +++ b/sys/geom/vinum/geom_vinum_move.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_plex.c b/sys/geom/vinum/geom_vinum_plex.c index f067762eb26f9..179ad19d2fcab 100644 --- a/sys/geom/vinum/geom_vinum_plex.c +++ b/sys/geom/vinum/geom_vinum_plex.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum_raid5.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_raid5.c b/sys/geom/vinum/geom_vinum_raid5.c index c4c768bac7091..7f2011d6b1989 100644 --- a/sys/geom/vinum/geom_vinum_raid5.c +++ b/sys/geom/vinum/geom_vinum_raid5.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum_raid5.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_rename.c b/sys/geom/vinum/geom_vinum_rename.c index b1415850f6f48..688673268ef93 100644 --- a/sys/geom/vinum/geom_vinum_rename.c +++ b/sys/geom/vinum/geom_vinum_rename.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_rm.c b/sys/geom/vinum/geom_vinum_rm.c index 71e267be9f16b..6bd4c28d9e484 100644 --- a/sys/geom/vinum/geom_vinum_rm.c +++ b/sys/geom/vinum/geom_vinum_rm.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> diff --git a/sys/geom/vinum/geom_vinum_state.c b/sys/geom/vinum/geom_vinum_state.c index d57f995420531..5c6beec6835b6 100644 --- a/sys/geom/vinum/geom_vinum_state.c +++ b/sys/geom/vinum/geom_vinum_state.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> #include <geom/vinum/geom_vinum_share.h> diff --git a/sys/geom/vinum/geom_vinum_subr.c b/sys/geom/vinum/geom_vinum_subr.c index 6e65a65f3389e..ce9c689fb66b6 100644 --- a/sys/geom/vinum/geom_vinum_subr.c +++ b/sys/geom/vinum/geom_vinum_subr.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/vinum/geom_vinum_var.h> #include <geom/vinum/geom_vinum.h> #include <geom/vinum/geom_vinum_share.h> diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c index f9549dfd11e16..cc9caa3f99a80 100644 --- a/sys/geom/virstor/g_virstor.c +++ b/sys/geom/virstor/g_virstor.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <vm/uma.h> #include <geom/geom.h> +#include <geom/geom_dbg.h> #include <geom/virstor/g_virstor.h> #include <geom/virstor/g_virstor_md.h> diff --git a/sys/geom/virstor/g_virstor.h b/sys/geom/virstor/g_virstor.h index 3e0d21cb13a63..1bcd734a81e99 100644 --- a/sys/geom/virstor/g_virstor.h +++ b/sys/geom/virstor/g_virstor.h @@ -47,30 +47,12 @@ struct virstor_map_entry { #ifdef _KERNEL -#define LOG_MSG(lvl, ...) do { \ - if (g_virstor_debug >= (lvl)) { \ - printf("GEOM_" G_VIRSTOR_CLASS_NAME); \ - if ((lvl) > 0) \ - printf("[%u]", (lvl)); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } \ -} while (0) +#define LOG_MSG(lvl, ...) \ + _GEOM_DEBUG("GEOM_VIRSTOR", g_virstor_debug, (lvl), NULL, __VA_ARGS__) #define LOG_MESSAGE LOG_MSG -#define LOG_REQ(lvl, bp, ...) do { \ - if (g_virstor_debug >= (lvl)) { \ - printf("GEOM_" G_VIRSTOR_CLASS_NAME); \ - if ((lvl) > 0) \ - printf("[%u]", (lvl)); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf(" "); \ - g_print_bio(bp); \ - printf("\n"); \ - } \ -} while (0) +#define LOG_REQ(lvl, bp, ...) \ + _GEOM_DEBUG("GEOM_VIRSTOR", g_virstor_debug, (lvl), (bp), __VA_ARGS__) #define LOG_REQUEST LOG_REQ /* "critical" system announcements (e.g. "geom is up") */ |