sys/vfs/hammer: Properly set mirror_tid on root node split
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 10 Mar 2015 11:09:36 +0000 (20:09 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 10 Mar 2015 13:12:17 +0000 (22:12 +0900)
- Set elms[0].internal.mirror_tid of the new root node
  after root split.

- Without this commit elms[0].internal.mirror_tid of the new root
  node is 0 which is not appropriate given that its children have
  non-zero mirror_tid.

- Submit #2801

- Following hammer show results shows difference.

  /* the root node right after root split without this commit */
       NODE 8000000020801000 cnt=02 p=0000000000000000 type=I depth=0 mirror 00000001000087a0 fill=z8:65=1% {
  G------ ELM  0 L lo=00000000 obj=8000000000000000 rt=00 key=8000000000000000 ot=00
                 d tids 0000000000000001:0000000000000001 suboff=8000000020800000 mirror 0000000000000000
  G------ ELM  1 L lo=00000001 obj=0000000080000209 rt=01 key=0000000000000000 ot=00
                   tids 0000000100008420:0000000000000000 suboff=8000000020802000 mirror 00000001000087a0
  G------ RBN  2 ? lo=ffffffff obj=7fffffffffffffff rt=ffff key=7fffffffffffffff ot=00
                   tids ffffffffffffffff:0000000000000000 suboff=0000000000000000 mirror 0000000000000000
       }
  BM   NODE 8000000020800000 cnt=32 p=8000000020801000 type=L depth=1 mirror 00000001000087a0 fill=z8:65=1%
  ...

  /* the root node right after root split with this commit */
       NODE 8000000020801000 cnt=02 p=0000000000000000 type=I depth=0 mirror 00000001000087a0 fill=z8:65=1% {
  G------ ELM  0 L lo=00000000 obj=8000000000000000 rt=00 key=8000000000000000 ot=00
                 d tids 0000000000000001:0000000000000001 suboff=8000000020800000 mirror 00000001000087a0
  G------ ELM  1 L lo=00000001 obj=0000000080000209 rt=01 key=0000000000000000 ot=00
                   tids 0000000100008420:0000000000000000 suboff=8000000020802000 mirror 00000001000087a0
  G------ RBN  2 ? lo=ffffffff obj=7fffffffffffffff rt=ffff key=7fffffffffffffff ot=00
                   tids ffffffffffffffff:0000000000000000 suboff=0000000000000000 mirror 0000000000000000
       }
       NODE 8000000020800000 cnt=32 p=8000000020801000 type=L depth=1 mirror 00000001000087a0 fill=z8:65=1% {
  ...

sys/vfs/hammer/hammer_btree.c

index 49c5b48..aeb724f 100644 (file)
@@ -1586,6 +1586,7 @@ btree_split_internal(hammer_cursor_t cursor)
                ondisk->elms[0].base = hmp->root_btree_beg;
                ondisk->elms[0].base.btype = node->ondisk->type;
                ondisk->elms[0].internal.subtree_offset = node->node_offset;
+               ondisk->elms[0].internal.mirror_tid = ondisk->mirror_tid;
                ondisk->elms[1].base = hmp->root_btree_end;
                hammer_modify_node_done(parent);
                /* ondisk->elms[1].base.btype - not used */
@@ -1834,6 +1835,7 @@ btree_split_leaf(hammer_cursor_t cursor)
                ondisk->elms[0].base = hmp->root_btree_beg;
                ondisk->elms[0].base.btype = leaf->ondisk->type;
                ondisk->elms[0].internal.subtree_offset = leaf->node_offset;
+               ondisk->elms[0].internal.mirror_tid = ondisk->mirror_tid;
                ondisk->elms[1].base = hmp->root_btree_end;
                /* ondisk->elms[1].base.btype = not used */
                hammer_modify_node_done(parent);