sys/vfs/hammer: Adjust hammer_debug_general
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 20 Aug 2015 14:46:56 +0000 (23:46 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 22 Aug 2015 15:48:30 +0000 (00:48 +0900)
Change hammer_debug_general in hammer_blockmap_getfree()
to 0x4000 which is the same value as those in
sys/vfs/hammer/hammer_reblock.c.

This is better since hammer_blockmap_getfree() is made
for reblock and only used by reblock (0x0800 picks up
other debug kprintfs that aren't related to reblock).

Also note that hammer_debug_general values are randomly
picked based on use cases rather than fixed value for
each file/etc.

Add some comments on the conditionals that are used to
start data/node reblock since this part is not too easy
to understand.

sys/vfs/hammer/hammer_blockmap.c
sys/vfs/hammer/hammer_reblock.c
sys/vfs/hammer/hammer_volume.c

index d537da5..ee7a91a 100644 (file)
@@ -1387,15 +1387,19 @@ hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t zone_offset,
 
        bytes = layer2->bytes_free;
 
+       /*
+        * *curp becomes 1 only when no error and,
+        * next_offset and zone_offset are in the same big-block.
+        */
        if ((blockmap->next_offset ^ zone_offset) & ~HAMMER_BIGBLOCK_MASK64)
-               *curp = 0;
+               *curp = 0;  /* not same */
        else
                *curp = 1;
 failed:
        if (buffer)
                hammer_rel_buffer(buffer, 0);
        hammer_rel_volume(root_volume, 0);
-       if (hammer_debug_general & 0x0800) {
+       if (hammer_debug_general & 0x4000) {
                kprintf("hammer_blockmap_getfree: %016llx -> %d\n",
                        (long long)zone_offset, bytes);
        }
index e696880..de4f856 100644 (file)
@@ -306,6 +306,15 @@ hammer_reblock_helper(struct hammer_ioc_reblock *reblock,
                bytes = hammer_blockmap_getfree(hmp, tmp_offset, &cur, &error);
                if (hammer_debug_general & 0x4000)
                        kprintf("D %6d/%d\n", bytes, reblock->free_level);
+               /*
+                * Start data reblock if
+                * 1. there is no error
+                * 2. the data and allocator offset are not in the same
+                *    big-block, or free level threshold is 0
+                * 3. free bytes in the data's big-block is larger than
+                *    free level threshold (means if threshold is 0 then
+                *    do reblock no matter what).
+                */
                if (error == 0 && (cur == 0 || reblock->free_level == 0) &&
                    bytes >= reblock->free_level) {
                        /*
@@ -371,6 +380,15 @@ skip:
                bytes = hammer_blockmap_getfree(hmp, tmp_offset, &cur, &error);
                if (hammer_debug_general & 0x4000)
                        kprintf("B %6d/%d\n", bytes, reblock->free_level);
+               /*
+                * Start node reblock if
+                * 1. there is no error
+                * 2. the node and allocator offset are not in the same
+                *    big-block, or free level threshold is 0
+                * 3. free bytes in the node's big-block is larger than
+                *    free level threshold (means if threshold is 0 then
+                *    do reblock no matter what).
+                */
                if (error == 0 && (cur == 0 || reblock->free_level == 0) &&
                    bytes >= reblock->free_level) {
                        error = hammer_cursor_upgrade(cursor);
index 2d1add9..c452b36 100644 (file)
@@ -323,8 +323,8 @@ hammer_do_reblock(hammer_transaction_t trans, hammer_inode_t ip)
        reblock.key_end.localization = HAMMER_MAX_LOCALIZATION;
        reblock.key_end.obj_id = HAMMER_MAX_OBJID;
        reblock.head.flags = HAMMER_IOC_DO_FLAGS;
-       reblock.free_level = 0;
-       reblock.allpfs = 1;
+       reblock.free_level = 0; /* reblock all big-blocks */
+       reblock.allpfs = 1;     /* reblock all PFS */
 
        kprintf("reblock started\n");
        error = hammer_ioc_reblock(trans, ip, &reblock);