Author: trasz
Date: Tue Jun 30 14:34:06 2009
New Revision: 195195
URL: http://svn.freebsd.org/changeset/base/195195

Log:
  Make gjournal work with kernel compiled with "options DIAGNOSTIC".
  Previously, it would panic immediately.
  
  Reviewed by:  pjd
  Approved by:  re (kib)

Modified:
  head/sys/geom/geom.h
  head/sys/geom/geom_io.c
  head/sys/geom/journal/g_journal.c

Modified: head/sys/geom/geom.h
==============================================================================
--- head/sys/geom/geom.h        Tue Jun 30 14:21:37 2009        (r195194)
+++ head/sys/geom/geom.h        Tue Jun 30 14:34:06 2009        (r195195)
@@ -134,6 +134,7 @@ struct g_geom {
        void                    *softc;
        unsigned                flags;
 #define        G_GEOM_WITHER           1
+#define        G_GEOM_VOLATILE_BIO     2
 };
 
 /*

Modified: head/sys/geom/geom_io.c
==============================================================================
--- head/sys/geom/geom_io.c     Tue Jun 30 14:21:37 2009        (r195194)
+++ head/sys/geom/geom_io.c     Tue Jun 30 14:34:06 2009        (r195195)
@@ -480,14 +480,6 @@ g_io_deliver(struct bio *bp, int error)
        KASSERT(bp != NULL, ("NULL bp in g_io_deliver"));
        pp = bp->bio_to;
        KASSERT(pp != NULL, ("NULL bio_to in g_io_deliver"));
-#ifdef DIAGNOSTIC
-       KASSERT(bp->bio_caller1 == bp->_bio_caller1,
-           ("bio_caller1 used by the provider %s", pp->name));
-       KASSERT(bp->bio_caller2 == bp->_bio_caller2,
-           ("bio_caller2 used by the provider %s", pp->name));
-       KASSERT(bp->bio_cflags == bp->_bio_cflags,
-           ("bio_cflags used by the provider %s", pp->name));
-#endif
        cp = bp->bio_from;
        if (cp == NULL) {
                bp->bio_error = error;
@@ -496,6 +488,21 @@ g_io_deliver(struct bio *bp, int error)
        }
        KASSERT(cp != NULL, ("NULL bio_from in g_io_deliver"));
        KASSERT(cp->geom != NULL, ("NULL bio_from->geom in g_io_deliver"));
+#ifdef DIAGNOSTIC
+       /*
+        * Some classes - GJournal in particular - can modify bio's
+        * private fields while the bio is in transit; G_GEOM_VOLATILE_BIO
+        * flag means it's an expected behaviour for that particular geom.
+        */
+       if ((cp->geom->flags & G_GEOM_VOLATILE_BIO) == 0) {
+               KASSERT(bp->bio_caller1 == bp->_bio_caller1,
+                   ("bio_caller1 used by the provider %s", pp->name));
+               KASSERT(bp->bio_caller2 == bp->_bio_caller2,
+                   ("bio_caller2 used by the provider %s", pp->name));
+               KASSERT(bp->bio_cflags == bp->_bio_cflags,
+                   ("bio_cflags used by the provider %s", pp->name));
+       }
+#endif
        KASSERT(bp->bio_completed >= 0, ("bio_completed can't be less than 0"));
        KASSERT(bp->bio_completed <= bp->bio_length,
            ("bio_completed can't be greater than bio_length"));

Modified: head/sys/geom/journal/g_journal.c
==============================================================================
--- head/sys/geom/journal/g_journal.c   Tue Jun 30 14:21:37 2009        
(r195194)
+++ head/sys/geom/journal/g_journal.c   Tue Jun 30 14:34:06 2009        
(r195195)
@@ -2292,6 +2292,7 @@ g_journal_create(struct g_class *mp, str
                gp->orphan = g_journal_orphan;
                gp->access = g_journal_access;
                gp->softc = sc;
+               gp->flags |= G_GEOM_VOLATILE_BIO;
                sc->sc_geom = gp;
 
                mtx_init(&sc->sc_mtx, "gjournal", NULL, MTX_DEF);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to