HAMMER VFS - Expand vfs.hammer.debug_io capabilities
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 17 Aug 2010 06:18:09 +0000 (23:18 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 17 Aug 2010 06:18:09 +0000 (23:18 -0700)
* Add debugging capabilities which are able to distinguish IO requests
  which are cached from IO requests which have to go to the device.

* vfs.hammer.debug_io bit 0 (i.e. the value 1) will use the new feature.
  This is for debugging only.

sys/kern/vfs_bio.c
sys/kern/vfs_cluster.c
sys/sys/buf.h
sys/vfs/hammer/hammer_io.c
sys/vfs/hammer/hammer_ondisk.c
sys/vfs/hammer/hammer_vnops.c

index 0c79269..0c25b03 100644 (file)
@@ -3448,6 +3448,13 @@ vn_strategy(struct vnode *vp, struct bio *bio)
        KKASSERT(bp->b_cmd != BUF_CMD_DONE);
 
        /*
+        * Set when an I/O is issued on the bp.  Cleared by consumers
+        * (aka HAMMER), allowing the consumer to determine if I/O had
+        * actually occurred.
+        */
+       bp->b_flags |= B_IODEBUG;
+
+       /*
         * Handle the swap cache intercept.
         */
        if (vn_cache_strategy(vp, bio))
index 8eed32e..7fc6f8e 100644 (file)
@@ -611,11 +611,12 @@ cluster_callback(struct bio *bio)
        while ((tbp = bio->bio_caller_info1.cluster_head) != NULL) {
                bio->bio_caller_info1.cluster_head = tbp->b_cluster_next;
                if (error) {
-                       tbp->b_flags |= B_ERROR;
+                       tbp->b_flags |= B_ERROR | B_IODEBUG;
                        tbp->b_error = error;
                } else {
                        tbp->b_dirtyoff = tbp->b_dirtyend = 0;
                        tbp->b_flags &= ~(B_ERROR|B_INVAL);
+                       tbp->b_flags |= B_IODEBUG;
                        /*
                         * XXX the bdwrite()/bqrelse() issued during
                         * cluster building clears B_RELBUF (see bqrelse()
index 159aaca..23a9de3 100644 (file)
@@ -296,7 +296,7 @@ struct buf {
 #define        B_HASBOGUS      0x00000200      /* Contains bogus pages */
 #define        B_EINTR         0x00000400      /* I/O was interrupted */
 #define        B_ERROR         0x00000800      /* I/O error occurred. */
-#define        B_UNUSED12      0x00001000      /* Unused */
+#define        B_IODEBUG       0x00001000      /* (Debugging only bread) */
 #define        B_INVAL         0x00002000      /* Does not contain valid info. */
 #define        B_LOCKED        0x00004000      /* Locked in core (not reusable). */
 #define        B_NOCACHE       0x00008000      /* Destroy buffer AND backing store */
index 69a496d..0664346 100644 (file)
@@ -311,6 +311,45 @@ hammer_io_read(struct vnode *devvp, struct hammer_io *io, hammer_off_t limit)
                 * even if we error out here.
                 */
                bp = io->bp;
+               if ((hammer_debug_io & 0x0001) && (bp->b_flags & B_IODEBUG)) {
+                       const char *metatype;
+
+                       switch(io->type) {
+                       case HAMMER_STRUCTURE_VOLUME:
+                               metatype = "volume";
+                               break;
+                       case HAMMER_STRUCTURE_META_BUFFER:
+                               switch(((struct hammer_buffer *)io)->
+                                       zoneX_offset & HAMMER_OFF_ZONE_MASK) {
+                               case HAMMER_ZONE_BTREE:
+                                       metatype = "btree";
+                                       break;
+                               case HAMMER_ZONE_META:
+                                       metatype = "meta";
+                                       break;
+                               case HAMMER_ZONE_FREEMAP:
+                                       metatype = "freemap";
+                                       break;
+                               default:
+                                       metatype = "meta?";
+                                       break;
+                               }
+                               break;
+                       case HAMMER_STRUCTURE_DATA_BUFFER:
+                               metatype = "data";
+                               break;
+                       case HAMMER_STRUCTURE_UNDO_BUFFER:
+                               metatype = "undo";
+                               break;
+                       default:
+                               metatype = "unknown";
+                               break;
+                       }
+                       kprintf("doff %016jx %s\n",
+                               (intmax_t)bp->b_bio2.bio_offset,
+                               metatype);
+               }
+               bp->b_flags &= ~B_IODEBUG;
                bp->b_ops = &hammer_bioops;
                KKASSERT(LIST_FIRST(&bp->b_dep) == NULL);
                LIST_INSERT_HEAD(&bp->b_dep, &io->worklist, node);
index d71bdab..463e467 100644 (file)
@@ -793,7 +793,7 @@ hammer_load_buffer(hammer_buffer_t buffer, int isnew)
         */
        volume = buffer->io.volume;
 
-       if (hammer_debug_io & 0x0001) {
+       if (hammer_debug_io & 0x0004) {
                kprintf("load_buffer %016llx %016llx isnew=%d od=%p\n",
                        (long long)buffer->zoneX_offset,
                        (long long)buffer->zone2_offset,
index 7e2b805..d02b004 100644 (file)
@@ -417,6 +417,13 @@ hammer_vop_read(struct vop_read_args *ap)
                        break;
                }
 skip:
+               if ((hammer_debug_io & 0x0001) && (bp->b_flags & B_IODEBUG)) {
+                       kprintf("doff %016jx read file %016jx@%016jx\n",
+                               (intmax_t)bp->b_bio2.bio_offset,
+                               (intmax_t)ip->obj_id,
+                               (intmax_t)bp->b_loffset);
+               }
+               bp->b_flags &= ~B_IODEBUG;
 
                /* bp->b_flags |= B_CLUSTEROK; temporarily disabled */
                n = blksize - offset;