Index: head/sys/geom/mirror/g_mirror.c =================================================================== --- head/sys/geom/mirror/g_mirror.c (revision 221756) +++ head/sys/geom/mirror/g_mirror.c (working copy) @@ -132,6 +132,7 @@ g_mirror_disk_state2str(int state) } } +#ifndef GEOM_NODEBUG static const char * g_mirror_device_state2str(int state) { @@ -145,6 +146,7 @@ g_mirror_device_state2str(int state) return ("INVALID"); } } +#endif /* !GEOM_NODEBUG */ static const char * g_mirror_get_diskname(struct g_mirror_disk *disk) @@ -402,7 +404,7 @@ g_mirror_connect_disk(struct g_mirror_disk *disk, g_detach(cp); g_destroy_consumer(cp); g_topology_unlock(); - G_MIRROR_DEBUG(0, "Cannot open consumer %s (error=%d).", + G_MIRROR_MSG("Cannot open consumer %s (error=%d).", pp->name, error); return (error); } @@ -543,7 +545,7 @@ g_mirror_destroy_device(struct g_mirror_softc *sc) g_mirror_disconnect_consumer(sc, cp); } g_wither_geom(sc->sc_sync.ds_geom, ENXIO); - G_MIRROR_DEBUG(0, "Device %s destroyed.", gp->name); + G_MIRROR_MSG("Device %s destroyed.", gp->name); g_wither_geom(gp, ENXIO); g_topology_unlock(); mtx_destroy(&sc->sc_queue_mtx); @@ -639,7 +641,7 @@ g_mirror_write_metadata(struct g_mirror_disk *disk if (error != 0) { if ((disk->d_flags & G_MIRROR_DISK_FLAG_BROKEN) == 0) { disk->d_flags |= G_MIRROR_DISK_FLAG_BROKEN; - G_MIRROR_DEBUG(0, "Cannot write metadata on %s " + G_MIRROR_MSG("Cannot write metadata on %s " "(device=%s, error=%d).", g_mirror_get_diskname(disk), sc->sc_name, error); } else { @@ -671,7 +673,7 @@ g_mirror_clear_metadata(struct g_mirror_disk *disk G_MIRROR_DEBUG(2, "Metadata on %s cleared.", g_mirror_get_diskname(disk)); } else { - G_MIRROR_DEBUG(0, + G_MIRROR_MSG( "Cannot clear metadata on disk %s (error=%d).", g_mirror_get_diskname(disk), error); } @@ -737,7 +739,7 @@ g_mirror_update_metadata(struct g_mirror_disk *dis G_MIRROR_DEBUG(2, "Metadata on %s updated.", g_mirror_get_diskname(disk)); } else { - G_MIRROR_DEBUG(0, + G_MIRROR_MSG( "Cannot update metadata on disk %s (error=%d).", g_mirror_get_diskname(disk), error); } @@ -1914,7 +1916,7 @@ g_mirror_sync_start(struct g_mirror_disk *disk) g_topology_unlock(); sx_xlock(&sc->sc_lock); - G_MIRROR_DEBUG(0, "Device %s: rebuilding provider %s.", sc->sc_name, + G_MIRROR_MSG("Device %s: rebuilding provider %s.", sc->sc_name, g_mirror_get_diskname(disk)); if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOFAILSYNC) == 0) disk->d_flags |= G_MIRROR_DISK_FLAG_DIRTY; @@ -1991,10 +1993,10 @@ g_mirror_sync_stop(struct g_mirror_disk *disk, int return; if (type == 0) { - G_MIRROR_DEBUG(0, "Device %s: rebuilding provider %s finished.", + G_MIRROR_MSG("Device %s: rebuilding provider %s finished.", sc->sc_name, g_mirror_get_diskname(disk)); } else /* if (type == 1) */ { - G_MIRROR_DEBUG(0, "Device %s: rebuilding provider %s stopped.", + G_MIRROR_MSG("Device %s: rebuilding provider %s stopped.", sc->sc_name, g_mirror_get_diskname(disk)); } free(disk->d_sync.ds_bios, M_MIRROR); @@ -2034,7 +2036,7 @@ g_mirror_launch_provider(struct g_mirror_softc *sc sc->sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); - G_MIRROR_DEBUG(0, "Device %s launched (%u/%u).", pp->name, + G_MIRROR_MSG("Device %s launched (%u/%u).", pp->name, g_mirror_ndisks(sc, G_MIRROR_DISK_STATE_ACTIVE), sc->sc_ndisks); LIST_FOREACH(disk, &sc->sc_disks, d_next) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) @@ -2060,7 +2062,7 @@ g_mirror_destroy_provider(struct g_mirror_softc *s g_io_deliver(bp, ENXIO); } mtx_unlock(&sc->sc_queue_mtx); - G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name, + G_MIRROR_MSG("Device %s: provider %s destroyed.", sc->sc_name, sc->sc_provider->name); sc->sc_provider->flags |= G_PF_WITHER; g_orphan_provider(sc->sc_provider, ENXIO); @@ -2078,7 +2080,7 @@ g_mirror_go(void *arg) struct g_mirror_softc *sc; sc = arg; - G_MIRROR_DEBUG(0, "Force device %s start due to timeout.", sc->sc_name); + G_MIRROR_MSG("Force device %s start due to timeout.", sc->sc_name); g_mirror_event_send(sc, 0, G_MIRROR_EVENT_DONTWAIT | G_MIRROR_EVENT_DEVICE); } @@ -2134,7 +2136,7 @@ g_mirror_determine_state(struct g_mirror_disk *dis * I think the best choice here is don't touch * this disk and inform the user loudly. */ - G_MIRROR_DEBUG(0, "Device %s was started before the freshest " + G_MIRROR_MSG("Device %s was started before the freshest " "disk (%s) arrives!! It will not be connected to the " "running device.", sc->sc_name, g_mirror_get_diskname(disk)); @@ -2233,7 +2235,7 @@ g_mirror_update_device(struct g_mirror_softc *sc, */ LIST_FOREACH_SAFE(disk, &sc->sc_disks, d_next, tdisk) { if (disk->d_genid < genid) { - G_MIRROR_DEBUG(0, + G_MIRROR_MSG( "Component %s (device %s) broken, skipping.", g_mirror_get_diskname(disk), sc->sc_name); g_mirror_destroy_disk(disk); @@ -2509,7 +2511,7 @@ again: disk->d_flags &= ~G_MIRROR_DISK_FLAG_DIRTY; disk->d_state = state; g_mirror_update_metadata(disk); - G_MIRROR_DEBUG(0, "Device %s: provider %s is stale.", + G_MIRROR_MSG("Device %s: provider %s is stale.", sc->sc_name, g_mirror_get_diskname(disk)); break; case G_MIRROR_DISK_STATE_SYNCHRONIZING: @@ -2576,7 +2578,7 @@ again: #endif } DISK_STATE_CHANGED(); - G_MIRROR_DEBUG(0, "Device %s: provider %s disconnected.", + G_MIRROR_MSG("Device %s: provider %s disconnected.", sc->sc_name, g_mirror_get_diskname(disk)); g_mirror_destroy_disk(disk); @@ -2589,7 +2591,7 @@ again: if (error != 0) return (error); DISK_STATE_CHANGED(); - G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", + G_MIRROR_MSG("Device %s: provider %s destroyed.", sc->sc_name, g_mirror_get_diskname(disk)); g_mirror_destroy_disk(disk); @@ -2638,7 +2640,7 @@ g_mirror_read_metadata(struct g_consumer *cp, stru if (strcmp(md->md_magic, G_MIRROR_MAGIC) != 0) return (EINVAL); if (md->md_version > G_MIRROR_VERSION) { - G_MIRROR_DEBUG(0, + G_MIRROR_MSG( "Kernel module is too old to handle metadata from %s.", cp->provider->name); return (EINVAL); @@ -2734,7 +2736,7 @@ g_mirror_add_disk(struct g_mirror_softc *sc, struc return (error); if (sc->sc_state == G_MIRROR_DEVICE_STATE_RUNNING && md->md_genid < sc->sc_genid) { - G_MIRROR_DEBUG(0, "Component %s (device %s) broken, skipping.", + G_MIRROR_MSG("Component %s (device %s) broken, skipping.", pp->name, sc->sc_name); return (EINVAL); } @@ -2746,7 +2748,7 @@ g_mirror_add_disk(struct g_mirror_softc *sc, struc if (error != 0) return (error); if (md->md_version < G_MIRROR_VERSION) { - G_MIRROR_DEBUG(0, "Upgrading metadata on %s (v%d->v%d).", + G_MIRROR_MSG("Upgrading metadata on %s (v%d->v%d).", pp->name, md->md_version, G_MIRROR_VERSION); g_mirror_update_metadata(disk); } @@ -2773,7 +2775,7 @@ g_mirror_destroy_delayed(void *arg, int flag) G_MIRROR_DEBUG(1, "Destroying %s (delayed).", sc->sc_name); error = g_mirror_destroy(sc, G_MIRROR_DESTROY_SOFT); if (error != 0) { - G_MIRROR_DEBUG(0, "Cannot destroy %s.", sc->sc_name); + G_MIRROR_MSG("Cannot destroy %s.", sc->sc_name); sx_xunlock(&sc->sc_lock); } g_topology_lock(); @@ -2989,7 +2991,7 @@ g_mirror_taste(struct g_class *mp, struct g_provid int error; g_topology_assert(); - g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name); + G_MIRROR_TRACE(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name); G_MIRROR_DEBUG(2, "Tasting %s.", pp->name); gp = g_new_geomf(mp, "mirror:taste"); @@ -3013,7 +3015,7 @@ g_mirror_taste(struct g_class *mp, struct g_provid if (md.md_provsize != 0 && md.md_provsize != pp->mediasize) return (NULL); if ((md.md_dflags & G_MIRROR_DISK_FLAG_INACTIVE) != 0) { - G_MIRROR_DEBUG(0, + G_MIRROR_MSG( "Device %s: provider %s marked as inactive, skipping.", md.md_name, pp->name); return (NULL); @@ -3034,7 +3036,7 @@ g_mirror_taste(struct g_class *mp, struct g_provid if (strcmp(md.md_name, sc->sc_name) != 0) continue; if (md.md_mid != sc->sc_id) { - G_MIRROR_DEBUG(0, "Device %s already configured.", + G_MIRROR_MSG("Device %s already configured.", sc->sc_name); return (NULL); } @@ -3043,7 +3045,7 @@ g_mirror_taste(struct g_class *mp, struct g_provid if (gp == NULL) { gp = g_mirror_create(mp, &md); if (gp == NULL) { - G_MIRROR_DEBUG(0, "Cannot create device %s.", + G_MIRROR_MSG("Cannot create device %s.", md.md_name); return (NULL); } @@ -3054,7 +3056,7 @@ g_mirror_taste(struct g_class *mp, struct g_provid sx_xlock(&sc->sc_lock); error = g_mirror_add_disk(sc, pp, &md); if (error != 0) { - G_MIRROR_DEBUG(0, "Cannot add disk %s to %s (error=%d).", + G_MIRROR_MSG("Cannot add disk %s to %s (error=%d).", pp->name, gp->name, error); if (LIST_EMPTY(&sc->sc_disks)) { g_cancel_event(sc); @@ -3240,7 +3242,7 @@ g_mirror_init(struct g_class *mp) g_mirror_pre_sync = EVENTHANDLER_REGISTER(shutdown_pre_sync, g_mirror_shutdown_pre_sync, mp, SHUTDOWN_PRI_FIRST); if (g_mirror_pre_sync == NULL) - G_MIRROR_DEBUG(0, "Warning! Cannot register shutdown event."); + G_MIRROR_MSG("Warning! Cannot register shutdown event."); } static void Index: head/sys/geom/mirror/g_mirror.h =================================================================== --- head/sys/geom/mirror/g_mirror.h (revision 221756) +++ head/sys/geom/mirror/g_mirror.h (working copy) @@ -72,28 +72,14 @@ #ifdef _KERNEL extern u_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_MSG(...) \ + G_MSG(G_MIRROR_CLASS_NAME, __VA_ARGS__) +#define G_MIRROR_DEBUG(lvl, ...) \ + G_DEBUG(G_MIRROR_CLASS_NAME, g_mirror_debug, (lvl), __VA_ARGS__) +#define G_MIRROR_LOGREQ(lvl, bp, ...) \ + G_LOGREQ(G_MIRROR_CLASS_NAME, g_mirror_debug, (lvl), (bp), __VA_ARGS__) +#define G_MIRROR_TRACE(lvl, ...) \ + G_TRACE((G_MIRROR_CLASS_NAME), (lvl), __VA_ARGS__) #define G_MIRROR_BIO_FLAG_REGULAR 0x01 #define G_MIRROR_BIO_FLAG_SYNC 0x02