Page MenuHomeFreeBSD

D21165.id60491.diff
No OneTemporary

D21165.id60491.diff

Index: sys/geom/cache/g_cache.h
===================================================================
--- sys/geom/cache/g_cache.h
+++ sys/geom/cache/g_cache.h
@@ -32,6 +32,9 @@
#define _G_CACHE_H_
#include <sys/endian.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
#define G_CACHE_CLASS_NAME "CACHE"
#define G_CACHE_MAGIC "GEOM::CACHE"
@@ -41,25 +44,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))
Index: sys/geom/concat/g_concat.h
===================================================================
--- sys/geom/concat/g_concat.h
+++ sys/geom/concat/g_concat.h
@@ -32,6 +32,9 @@
#define _G_CONCAT_H_
#include <sys/endian.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
#define G_CONCAT_CLASS_NAME "CONCAT"
@@ -49,25 +52,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;
Index: sys/geom/eli/g_eli.h
===================================================================
--- sys/geom/eli/g_eli.h
+++ sys/geom/eli/g_eli.h
@@ -43,6 +43,7 @@
#include <sys/lock.h>
#include <sys/mutex.h>
#include <geom/geom.h>
+#include <geom/geom_int.h>
#include <crypto/intake.h>
#else
#include <assert.h>
@@ -155,28 +156,10 @@
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;
Index: sys/geom/gate/g_gate.h
===================================================================
--- sys/geom/gate/g_gate.h
+++ sys/geom/gate/g_gate.h
@@ -37,6 +37,9 @@
#include <sys/queue.h>
#include <geom/geom.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
#define G_GATE_CLASS_NAME "GATE"
#define G_GATE_PROVIDER_NAME "ggate"
@@ -103,28 +106,10 @@
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 {
Index: sys/geom/geom.h
===================================================================
--- sys/geom/geom.h
+++ sys/geom/geom.h
@@ -346,6 +346,7 @@
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 *, struct bio *bp);
int g_use_g_read_data(void *, off_t, void **, int);
int g_use_g_write_data(void *, off_t, void *, int);
Index: sys/geom/geom_int.h
===================================================================
--- sys/geom/geom_int.h
+++ sys/geom/geom_int.h
@@ -37,9 +37,22 @@
* $FreeBSD$
*/
+#pragma once
+
LIST_HEAD(class_list_head, g_class);
TAILQ_HEAD(g_tailq_head, g_geom);
+#define _GEOM_DEBUG(gcls, ctrlvar, loglvl, biop, formatstr, ...) do { \
+ const int __control = (ctrlvar); \
+ const int __level = (loglvl); \
+ \
+ if (__control < __level) \
+ break; \
+ \
+ g_dbg_printf((gcls), (__control > 0) ? __level : -1, (biop), \
+ ": " formatstr, ## __VA_ARGS__); \
+} while (0)
+
extern int g_collectstats;
#define G_STATS_PROVIDERS 1 /* Collect I/O stats for providers */
#define G_STATS_CONSUMERS 2 /* Collect I/O stats for consumers */
@@ -60,7 +73,7 @@
void g_confxml(void *, int flag);
void g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
void g_conf_cat_escaped(struct sbuf *sb, const char *buf);
-void g_conf_printf_escaped(struct sbuf *sb, const char *fmt, ...);
+void g_conf_printf_escaped(struct sbuf *sb, const char *fmt, ...) __printflike(2, 3);
void g_confdot(void *, int flag);
void g_conftxt(void *, int flag);
@@ -73,6 +86,7 @@
extern struct class_list_head g_classes;
extern char *g_wait_event, *g_wait_sim, *g_wait_up, *g_wait_down;
void g_wither_washer(void);
+void g_dbg_printf(const char *gcls, int lvl, struct bio *bp, const char *format, ...) __printflike(4, 5);
/* geom_io.c */
void g_io_init(void);
Index: sys/geom/geom_io.c
===================================================================
--- sys/geom/geom_io.c
+++ sys/geom/geom_io.c
@@ -49,6 +49,7 @@
#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>
@@ -1030,6 +1031,24 @@
void
g_print_bio(struct bio *bp)
+{
+#ifndef PRINTF_BUFR_SIZE
+#define PRINTF_BUFR_SIZE 64
+#endif
+ char bufr[PRINTF_BUFR_SIZE];
+ struct sbuf sb, *sbp __unused;
+
+ sbp = sbuf_new(&sb, bufr, sizeof(bufr), SBUF_FIXEDLEN);
+ KASSERT(sbp != NULL, ("sbuf_new misused?"));
+
+ sbuf_set_drain(&sb, sbuf_printf_drain, NULL);
+ g_format_bio(&sb, bp);
+ sbuf_finish(&sb);
+ sbuf_delete(&sb);
+}
+
+void
+g_format_bio(struct sbuf *sb, struct bio *bp)
{
const char *pname, *cmd = NULL;
@@ -1041,11 +1060,12 @@
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 +1093,7 @@
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 +1107,9 @@
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);
}
Index: sys/geom/geom_subr.c
===================================================================
--- sys/geom/geom_subr.c
+++ sys/geom/geom_subr.c
@@ -77,6 +77,43 @@
int post;
};
+void
+g_dbg_printf(const char *gcls, 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, gcls);
+ 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.
*/
Index: sys/geom/journal/g_journal.h
===================================================================
--- sys/geom/journal/g_journal.h
+++ sys/geom/journal/g_journal.h
@@ -35,6 +35,7 @@
#include <sys/md5.h>
#ifdef _KERNEL
#include <sys/bio.h>
+#include <geom/geom_int.h>
#endif
#define G_JOURNAL_CLASS_NAME "JOURNAL"
@@ -49,28 +50,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 == \
Index: sys/geom/label/g_label.h
===================================================================
--- sys/geom/label/g_label.h
+++ sys/geom/label/g_label.h
@@ -34,6 +34,7 @@
#include <sys/endian.h>
#ifdef _KERNEL
#include <sys/sysctl.h>
+#include <geom/geom_int.h>
#endif
#define G_LABEL_CLASS_NAME "LABEL"
@@ -50,16 +51,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);
Index: sys/geom/linux_lvm/g_linux_lvm.h
===================================================================
--- sys/geom/linux_lvm/g_linux_lvm.h
+++ sys/geom/linux_lvm/g_linux_lvm.h
@@ -28,16 +28,12 @@
* $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)
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
+
+#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
Index: sys/geom/mirror/g_mirror.h
===================================================================
--- sys/geom/mirror/g_mirror.h
+++ sys/geom/mirror/g_mirror.h
@@ -34,6 +34,10 @@
#include <sys/endian.h>
#include <sys/md5.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
+
#define G_MIRROR_CLASS_NAME "MIRROR"
#define G_MIRROR_MAGIC "GEOM::MIRROR"
@@ -86,28 +90,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
Index: sys/geom/mountver/g_mountver.h
===================================================================
--- sys/geom/mountver/g_mountver.h
+++ sys/geom/mountver/g_mountver.h
@@ -38,25 +38,12 @@
#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)
+#include <geom/geom_int.h>
+
+#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;
Index: sys/geom/nop/g_nop.h
===================================================================
--- sys/geom/nop/g_nop.h
+++ sys/geom/nop/g_nop.h
@@ -31,6 +31,10 @@
#ifndef _G_NOP_H_
#define _G_NOP_H_
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
+
#define G_NOP_CLASS_NAME "NOP"
#define G_NOP_VERSION 4
#define G_NOP_SUFFIX ".nop"
@@ -41,26 +45,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_softc {
int sc_error;
Index: sys/geom/raid/g_raid.h
===================================================================
--- sys/geom/raid/g_raid.h
+++ sys/geom/raid/g_raid.h
@@ -37,6 +37,7 @@
#include <sys/time.h>
#ifdef _KERNEL
#include <sys/sysctl.h>
+#include <geom/geom_int.h>
#endif
#define G_RAID_CLASS_NAME "RAID"
@@ -61,39 +62,13 @@
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
Index: sys/geom/raid3/g_raid3.h
===================================================================
--- sys/geom/raid3/g_raid3.h
+++ sys/geom/raid3/g_raid3.h
@@ -33,6 +33,9 @@
#include <sys/endian.h>
#include <sys/md5.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
#define G_RAID3_CLASS_NAME "RAID3"
@@ -69,28 +72,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
Index: sys/geom/sched/g_sched.h
===================================================================
--- sys/geom/sched/g_sched.h
+++ sys/geom/sched/g_sched.h
@@ -30,6 +30,10 @@
#ifndef _G_SCHED_H_
#define _G_SCHED_H_
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
+
/*
* $Id$
* $FreeBSD$
@@ -44,26 +48,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);
Index: sys/geom/shsec/g_shsec.h
===================================================================
--- sys/geom/shsec/g_shsec.h
+++ sys/geom/shsec/g_shsec.h
@@ -32,6 +32,9 @@
#define _G_SHSEC_H_
#include <sys/endian.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
#define G_SHSEC_CLASS_NAME "SHSEC"
@@ -46,28 +49,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 */
Index: sys/geom/stripe/g_stripe.h
===================================================================
--- sys/geom/stripe/g_stripe.h
+++ sys/geom/stripe/g_stripe.h
@@ -32,6 +32,9 @@
#define _G_STRIPE_H_
#include <sys/endian.h>
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
#define G_STRIPE_CLASS_NAME "STRIPE"
@@ -49,25 +52,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 */
Index: sys/geom/vinum/geom_vinum.h
===================================================================
--- sys/geom/vinum/geom_vinum.h
+++ sys/geom/vinum/geom_vinum.h
@@ -31,6 +31,10 @@
#ifndef _GEOM_VINUM_H_
#define _GEOM_VINUM_H_
+#ifdef _KERNEL
+#include <geom/geom_int.h>
+#endif
+
/* geom_vinum_create.c */
void gv_concat(struct g_geom *gp, struct gctl_req *);
void gv_mirror(struct g_geom *gp, struct gctl_req *);
@@ -157,28 +161,9 @@
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_ */

File Metadata

Mime Type
text/plain
Expires
Sat, May 23, 9:53 PM (49 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33455396
Default Alt Text
D21165.id60491.diff (23 KB)

Event Timeline