HAMMER VFS - Add debugging for overlapping buffer issue
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 21 Aug 2010 21:15:41 +0000 (14:15 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 21 Aug 2010 21:15:41 +0000 (14:15 -0700)
* Add debug flags to display information that may be useful when
  diagnosing overlapping buffers.

  Set vfs.hammer.debug_general=163840 (0x28000) to generate
  the debug data.

sys/vfs/hammer/hammer_blockmap.c
sys/vfs/hammer/hammer_ondisk.c

index a657355..e75615e 100644 (file)
@@ -655,11 +655,19 @@ hammer_blockmap_reserve_complete(hammer_mount_t hmp, hammer_reserve_t resv)
                error = hammer_del_buffers(hmp, base_offset,
                                           resv->zone_offset,
                                           HAMMER_LARGEBLOCK_SIZE,
-                                          0);
+                                          1);
+               if (hammer_debug_general & 0x20000) {
+                       kprintf("hammer: dellgblk %016jx error %d\n",
+                               (intmax_t)base_offset, error);
+               }
                if (error)
                        hammer_reserve_setdelay(hmp, resv);
        }
        if (--resv->refs == 0) {
+               if (hammer_debug_general & 0x20000) {
+                       kprintf("hammer: delresvr %016jx zone %02x\n",
+                               (intmax_t)resv->zone_offset, resv->zone);
+               }
                KKASSERT((resv->flags & HAMMER_RESF_ONDELAY) == 0);
                RB_REMOVE(hammer_res_rb_tree, &hmp->rb_resv_root, resv);
                kfree(resv, hmp->m_misc);
@@ -733,6 +741,11 @@ hammer_reserve_setdelay(hammer_mount_t hmp, hammer_reserve_t resv)
        }
 }
 
+/*
+ * Reserve has reached its flush point, remove it from the delay list
+ * and finish it off.  hammer_blockmap_reserve_complete() inherits
+ * the ondelay reference.
+ */
 void
 hammer_reserve_clrdelay(hammer_mount_t hmp, hammer_reserve_t resv)
 {
index 463e467..71b916d 100644 (file)
@@ -742,6 +742,13 @@ hammer_del_buffers(hammer_mount_t hmp, hammer_off_t base_offset,
                                   base_offset);
                if (buffer) {
                        error = hammer_ref_buffer(buffer);
+                       if (hammer_debug_general & 0x20000) {
+                               kprintf("hammer: delbufr %016jx "
+                                       "rerr=%d 1ref=%d\n",
+                                       (intmax_t)buffer->zoneX_offset,
+                                       error,
+                                       hammer_oneref(&buffer->io.lock));
+                       }
                        if (error == 0 && !hammer_oneref(&buffer->io.lock)) {
                                error = EAGAIN;
                                hammer_rel_buffer(buffer, 0);