hammer2 - minor cleanups
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 9 Jan 2014 17:34:26 +0000 (09:34 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 9 Jan 2014 17:34:26 +0000 (09:34 -0800)
* Minor cleanups

sbin/hammer2/main.c
sys/vfs/hammer2/hammer2_chain.c
sys/vfs/hammer2/hammer2_disk.h
sys/vfs/hammer2/hammer2_freemap.c

index 77a5e99..be1a62c 100644 (file)
@@ -408,7 +408,7 @@ usage(int code)
                        "Create a PFS\n"
                "    pfs-delete <label>           "
                        "Destroy a PFS\n"
-               "    snapshot                     "
+               "    snapshot [<label>]           "
                        "Snapshot a PFS\n"
                "    service                      "
                        "Start service daemon\n"
index 548676d..ac0cc08 100644 (file)
@@ -96,8 +96,6 @@ static hammer2_chain_t *hammer2_combined_find(
 static void hammer2_chain_assert_not_present(hammer2_chain_core_t *above,
                                 hammer2_chain_t *chain);
 
-hammer2_chain_t *XXChain;
-int XXChainWhy;
 /*
  * Basic RBTree for chains.  Chains cannot overlap within any given
  * core->rbtree without recursing through chain->rbtree.  We effectively
@@ -1969,8 +1967,6 @@ hammer2_chain_lookup(hammer2_chain_t **parentp, hammer2_key_t *key_nextp,
        int generation;
        int maxloops = 300000;
        int wasdup;
-       hammer2_chain_t * volatile xxchain = NULL;
-       volatile int xxchainwhy;
 
        if (flags & HAMMER2_LOOKUP_ALWAYS) {
                how_maybe = how_always;
@@ -2125,8 +2121,6 @@ again:
                        goto again;
                }
                if (bcmp(&bcopy, bref, sizeof(bcopy))) {
-                       xxchain = chain;
-                       xxchainwhy = 1;
                        hammer2_chain_drop(chain);
                        goto again;
                }
@@ -2168,8 +2162,6 @@ again:
                        if (key_beg == 0 || key_beg > key_end)
                                return(NULL);
                }
-               xxchain = chain;
-                       xxchainwhy = 2;
                goto again;
        }
 
@@ -2193,16 +2185,12 @@ again:
            chain->bref.type == HAMMER2_BREF_TYPE_FREEMAP_NODE) {
                hammer2_chain_unlock(parent);
                *parentp = parent = chain;
-               xxchain = chain;
-                       xxchainwhy = 3;
                goto again;
        }
 done:
        /*
         * All done, return the chain
         */
-       XXChain = chain;
-       XXChainWhy = xxchainwhy;
        return (chain);
 }
 
@@ -2284,12 +2272,14 @@ hammer2_chain_next(hammer2_chain_t **parentp, hammer2_chain_t *chain,
 }
 
 /*
- * Raw scan functions are similar to lookup/next but do not seek the parent
- * chain and do not skip stale chains.  These functions are primarily used
- * by the recovery code.
+ * The raw scan function is similar to lookup/next but does not seek to a key.
+ * Blockrefs are iterated via first_chain = (parent, NULL) and
+ * next_chain = (parent, chain).
  *
- * Parent and chain are locked, parent's data must be resolved.  To acquire
- * the first sub-chain under parent pass chain == NULL.
+ * The passed-in parent must be locked and its data resolved.  The returned
+ * chain will be locked.  Pass chain == NULL to acquire the first sub-chain
+ * under parent and then iterate with the passed-in chain (which this
+ * function will unlock).
  */
 hammer2_chain_t *
 hammer2_chain_scan(hammer2_chain_t *parent, hammer2_chain_t *chain,
@@ -3311,7 +3301,6 @@ hammer2_chain_create_indirect(hammer2_trans_t *trans, hammer2_chain_t *parent,
        int maxloops = 300000;
        int retry_same;
        int wasdup;
-       hammer2_chain_t * volatile xxchain = NULL;
 
        /*
         * Calculate the base blockref pointer or NULL if the chain
@@ -3555,7 +3544,6 @@ hammer2_chain_create_indirect(hammer2_trans_t *trans, hammer2_chain_t *parent,
                        if ((chain->flags & HAMMER2_CHAIN_DUPLICATED) &&
                            wasdup == 0) {
                                retry_same = 1;
-                               xxchain = chain;
                        }
                        goto next_key;
                }
@@ -3643,7 +3631,6 @@ next_key_spinlocked:
                 */
                parent = ichain;
        }
-       XXChain = xxchain;
 
        return(parent);
 }
index 4153148..ec62c81 100644 (file)
  * 2MB of storage (x1024 elements = 2GB).  2 bits per chunk:
  *
  *     00      Free
- *     01      Possibly fragmented
+ *     01      (reserved)
  *     10      Possibly free
  *     11      Allocated
  *
@@ -611,7 +611,7 @@ typedef struct hammer2_blockset hammer2_blockset_t;
  *          storage.  Bit patterns are as follows:
  *
  *          00 Unallocated
- *          01 Armed for bulk free scan
+ *          01 (reserved)
  *          10 Possibly free
  *           11 Allocated
  */
@@ -923,7 +923,8 @@ struct hammer2_volume_data {
        hammer2_tid_t   alloc_tid;              /* 0080 Alloctable modify tid */
        hammer2_tid_t   inode_tid;              /* 0088 Inode allocator tid */
        hammer2_tid_t   freemap_tid;            /* 0090 committed tid (fmap) */
-       hammer2_tid_t   reserved0090[6];        /* 0098-00C7 */
+       hammer2_tid_t   bulkfree_tid;           /* 0098 bulkfree incremental */
+       hammer2_tid_t   reserved00A0[5];        /* 00A0-00C7 */
 
        /*
         * Copyids are allocated dynamically from the copyexists bitmap.
index 8d8876c..d10bf9e 100644 (file)
@@ -256,7 +256,11 @@ hammer2_freemap_alloc(hammer2_trans_t *trans, hammer2_chain_t *chain,
                return (hammer2_freemap_reserve(trans, chain, radix));
        }
 
+#if 0
        /*
+        * (this mechanic is no longer used, DOMAYFREE is used only by
+        * the bulk freemap scan now).
+        *
         * Mark previously allocated block as possibly freeable.  There might
         * be snapshots and other races so we can't just mark it fully free.
         * (XXX optimize this for the current-transaction create+delete case)
@@ -265,6 +269,7 @@ hammer2_freemap_alloc(hammer2_trans_t *trans, hammer2_chain_t *chain,
                hammer2_freemap_adjust(trans, hmp, bref,
                                       HAMMER2_FREEMAP_DOMAYFREE);
        }
+#endif
 
        /*
         * Setting ISALLOCATING ensures correct operation even when the
@@ -771,13 +776,10 @@ hammer2_freemap_iterate(hammer2_trans_t *trans, hammer2_chain_t **parentp,
 }
 
 /*
- * Free the specified blockref.  This code is only able to fully free
- * blocks when (how) is non-zero, otherwise the block is marked for
- * the bulk freeing pass to check.
- *
- * Normal use is to only mark inodes as possibly being free.  The underlying
- * file blocks are not necessarily marked.  The bulk freescan can
- * theoretically handle the case.
+ * Adjust the bit-pattern for data in the freemap bitmap according to
+ * (how).  This code is called from on-mount recovery to fixup (mark
+ * as allocated) blocks whos freemap upates might not have been committed
+ * in the last crash and is used by the bulk freemap scan to stage frees.
  *
  * XXX currently disabled when how == 0 (the normal real-time case).  At
  * the moment we depend on the bulk freescan to actually free blocks.  It