Project

General

Profile

Actions

Submit #2801

closed

sys/vfs/hammer: Properly set mirror_tid on root node split

Added by tkusumi about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
VFS subsystem
Target version:
-
Start date:
03/08/2015
Due date:
% Done:

0%

Estimated time:

Description

Matt,
Please review following diff.
I think this is the way it should be unless you made it that way
for some technical reason.

diff --git a/sys/vfs/hammer/hammer_btree.c b/sys/vfs/hammer/hammer_btree.c
index 49c5b48..8794536 100644
--- a/sys/vfs/hammer/hammer_btree.c
++ b/sys/vfs/hammer/hammer_btree.c
@ -1586,6 +1586,8 @ btree_split_internal(hammer_cursor_t cursor)
ondisk->elms0.base = hmp->root_btree_beg;
ondisk->elms0.base.btype = node->ondisk->type;
ondisk->elms0.internal.subtree_offset = node->node_offset;
ondisk->elms0.internal.mirror_tid = ondisk->mirror_tid;
+ /* the element at &elms1 is updated later as parent_elm /
ondisk->elms1.base = hmp->root_btree_end;
hammer_modify_node_done(parent);
/
ondisk->elms1.base.btype - not used /
@ -1834,6 +1836,8 @ btree_split_leaf(hammer_cursor_t cursor)
ondisk->elms0.base = hmp->root_btree_beg;
ondisk->elms0.base.btype = leaf->ondisk->type;
ondisk->elms0.internal.subtree_offset = leaf->node_offset;
+ ondisk->elms0.internal.mirror_tid = ondisk->mirror_tid;
+ /
the element at &elms1 is updated later as parent_elm /
ondisk->elms1.base = hmp->root_btree_end;
/
ondisk->elms1.base.btype = not used */
hammer_modify_node_done(parent);

Without above diff, root node split creates a new root whose
elms0 has 0 for mirror_tid. Mirroring still works because
elms1 and the node itself have the right mirror_tid from its children,
however hammer show command reports "BM" for the child node
because the root node's elms0.internal.mirror_tid (==0) is
smaller than that of child node.

Following
(A) is existing behavior right after root split, reporting "BM".
(B) is hammer with this diff applied, not reporting "BM".

(B) writes out different mirror_tid to storage compared to
the existing hammer (A), but I don't see (B) breaks anything in
existing storage, but is rather better in the sense that (B)
does not violate hammer's general design.

-------------
(A) - elms1 has 00000001000087a0 for mirror_tid, but elms0 has 0

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%
...

-------------
(B) - both elms0 and elms1 has 00000001000087a0 for mirror_tid

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% {
...
Actions #1

Updated by tkusumi about 9 years ago

  • Status changed from New to Closed

This diff was acked by Matt.
Pushing it to master later.

Actions

Also available in: Atom PDF