From: Tomohiro Kusumi Date: Sat, 28 Feb 2015 20:06:01 +0000 (+0900) Subject: sbin/hammer: Don't show FLAG_BADMIRRORTID for root node in certain corner case situation X-Git-Tag: v4.2.0rc~701 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/44cd685c7ff64915c6067e9911cb9d6f03e2eaf8 sbin/hammer: Don't show FLAG_BADMIRRORTID for root node in certain corner case situation - Make hammer show command stop showwing an error flag regarding mirror tid that isn't actually an error. - newfs_hammer initializes the root node's mirror_tid with 0 along with its first two elements, but this mirror_tid is not updated till the third element is allocated (by creating a file, etc). Following result shows this situation. - In this situation the root node's node->mirror_tid (==0) being smaller than elm->base.create_tid or elm->base.delete_tid is not an error. This only happens on the root node because all the other nodes get updated when they split from existing ones. NODE 8000000020800000 cnt=02 p=0000000000000000 type=L depth=0 mirror 0000000000000000 fill=z8:65=1% { B-----M ELM 0 R lo=00000001 obj=0000000000000001 rt=01 key=0000000000000000 ot=01 tids 0000000100000001:0000000000000000 B-----M ELM 1 R lo=00000002 obj=0000000000000001 rt=15 key=0000000000000000 ot=00 tids 0000000100000001:0000000000000000 } --- diff --git a/sbin/hammer/cmd_show.c b/sbin/hammer/cmd_show.c index 40fd4fac93..fc860a8250 100644 --- a/sbin/hammer/cmd_show.c +++ b/sbin/hammer/cmd_show.c @@ -355,11 +355,15 @@ get_elm_flags(hammer_node_ondisk_t node, hammer_off_t node_offset, } break; case HAMMER_BTREE_TYPE_LEAF: - if (elm->base.create_tid && + if (node->mirror_tid == 0 && + !(node->parent == 0 && node->count == 2)) { + flags |= FLAG_BADMIRRORTID; + } + if (elm->base.create_tid && node->mirror_tid && elm->base.create_tid > node->mirror_tid) { flags |= FLAG_BADMIRRORTID; } - if (elm->base.delete_tid && + if (elm->base.delete_tid && node->mirror_tid && elm->base.delete_tid > node->mirror_tid) { flags |= FLAG_BADMIRRORTID; } diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index 6065baf35f..6bd72f3cd5 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -614,6 +614,9 @@ format_root(const char *label) hammer_btree_elm_t elm; u_int64_t xtime; + /* + * Allocate zero-filled root btree node and data + */ bnode = alloc_btree_element(&btree_off); idata = alloc_data_element(&data_off, sizeof(*idata), &data_buffer1); pfsd = alloc_data_element(&pfsd_off, sizeof(*pfsd), &data_buffer2);