From: Tomohiro Kusumi Date: Thu, 20 Aug 2015 14:46:56 +0000 (+0900) Subject: sys/vfs/hammer: Adjust hammer_debug_general X-Git-Tag: v4.5.0~748 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/4af7f53747c5cfc504b9ec89242b7a195fbfb933 sys/vfs/hammer: Adjust hammer_debug_general 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. --- diff --git a/sys/vfs/hammer/hammer_blockmap.c b/sys/vfs/hammer/hammer_blockmap.c index d537da57ce..ee7a91a93b 100644 --- a/sys/vfs/hammer/hammer_blockmap.c +++ b/sys/vfs/hammer/hammer_blockmap.c @@ -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); } diff --git a/sys/vfs/hammer/hammer_reblock.c b/sys/vfs/hammer/hammer_reblock.c index e6968805c8..de4f85641d 100644 --- a/sys/vfs/hammer/hammer_reblock.c +++ b/sys/vfs/hammer/hammer_reblock.c @@ -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); diff --git a/sys/vfs/hammer/hammer_volume.c b/sys/vfs/hammer/hammer_volume.c index 2d1add95fb..c452b369dc 100644 --- a/sys/vfs/hammer/hammer_volume.c +++ b/sys/vfs/hammer/hammer_volume.c @@ -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);