hammer2 - Refactor reserved block selection in freemap code (2)
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 11 Dec 2013 04:45:06 +0000 (20:45 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 11 Dec 2013 04:45:06 +0000 (20:45 -0800)
* Fix off-by-1 bug in last commit when calculating the new offset
  in the freemap code.

* Remove some debugging.

sys/vfs/hammer2/hammer2_flush.c
sys/vfs/hammer2/hammer2_freemap.c

index 2c2c559..da2e7c3 100644 (file)
@@ -899,12 +899,14 @@ retry:
         * resulting in a parent which effectively needs no modification.
         */
        if ((chain->flags & HAMMER2_CHAIN_MODIFIED) == 0) {
+#if 0
                kprintf("chain %p.%d %08x recursed but wasn't "
                        "modified mirr=%016jx "
                        "update_lo=%016jx synctid=%016jx\n",
                        chain, chain->bref.type, chain->flags,
                        chain->bref.mirror_tid,
                        core->update_lo, info->sync_tid);
+#endif
 #if 0
                if ((chain->flags & HAMMER2_CHAIN_MOVED) == 0) {
                        hammer2_chain_ref(chain);
index 9a55506..8d8876c 100644 (file)
@@ -172,25 +172,29 @@ hammer2_freemap_reserve(hammer2_trans_t *trans, hammer2_chain_t *chain,
                KKASSERT(bref->type == HAMMER2_BREF_TYPE_FREEMAP_NODE);
                KKASSERT(bytes == HAMMER2_FREEMAP_LEVELN_PSIZE);
                off = H2FMBASE(bref->key, HAMMER2_FREEMAP_LEVEL4_RADIX) +
-                     (index * 4 + HAMMER2_ZONEFM_LEVEL4) * HAMMER2_PBUFSIZE;
+                     (index * 4 + HAMMER2_ZONE_FREEMAP_00 +
+                      HAMMER2_ZONEFM_LEVEL4) * HAMMER2_PBUFSIZE;
                break;
        case HAMMER2_FREEMAP_LEVEL3_RADIX:      /* 2PB */
                KKASSERT(bref->type == HAMMER2_BREF_TYPE_FREEMAP_NODE);
                KKASSERT(bytes == HAMMER2_FREEMAP_LEVELN_PSIZE);
                off = H2FMBASE(bref->key, HAMMER2_FREEMAP_LEVEL3_RADIX) +
-                     (index * 4 + HAMMER2_ZONEFM_LEVEL3) * HAMMER2_PBUFSIZE;
+                     (index * 4 + HAMMER2_ZONE_FREEMAP_00 +
+                      HAMMER2_ZONEFM_LEVEL3) * HAMMER2_PBUFSIZE;
                break;
        case HAMMER2_FREEMAP_LEVEL2_RADIX:      /* 2TB */
                KKASSERT(bref->type == HAMMER2_BREF_TYPE_FREEMAP_NODE);
                KKASSERT(bytes == HAMMER2_FREEMAP_LEVELN_PSIZE);
                off = H2FMBASE(bref->key, HAMMER2_FREEMAP_LEVEL2_RADIX) +
-                     (index * 4 + HAMMER2_ZONEFM_LEVEL2) * HAMMER2_PBUFSIZE;
+                     (index * 4 + HAMMER2_ZONE_FREEMAP_00 +
+                      HAMMER2_ZONEFM_LEVEL2) * HAMMER2_PBUFSIZE;
                break;
        case HAMMER2_FREEMAP_LEVEL1_RADIX:      /* 2GB */
                KKASSERT(bref->type == HAMMER2_BREF_TYPE_FREEMAP_LEAF);
                KKASSERT(bytes == HAMMER2_FREEMAP_LEVELN_PSIZE);
                off = H2FMBASE(bref->key, HAMMER2_FREEMAP_LEVEL1_RADIX) +
-                     (index * 4 + HAMMER2_ZONEFM_LEVEL1) * HAMMER2_PBUFSIZE;
+                     (index * 4 + HAMMER2_ZONE_FREEMAP_00 +
+                      HAMMER2_ZONEFM_LEVEL1) * HAMMER2_PBUFSIZE;
                break;
        default:
                panic("freemap: bad radix(2) %p %d\n", bref, bref->keybits);