git: sys/vfs/hammer: Fix/rewrite hammer_format_freemap()
tkusumi at crater.dragonflybsd.org
Sat Mar 19 14:27:45 PDT 2016
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date: Fri Mar 11 23:45:16 2016 +0900
sys/vfs/hammer: Fix/rewrite hammer_format_freemap()
hammer volume-add allocates big-blocks that contain layer2 entries
in a different way from newfs_hammer.
0 8M 4T 8T 12T...
------------------|--------------------------> zone-2 address of non-root volume
L2L2L2L2.. L2L2.. <- newfs_hammer
L2L2L2L2.. L2L2.. L2L2.. L2L2.. <- hammer volume-add
This layout difference comes from where
hammer_iterate_l1l2_entries() uses the following code for layer2
layer2_off = phys_off + HAMMER_BLOCKMAP_LAYER2_OFFSET(block_off);
^^^^^^^^ not layer1->phys_offset
Although this works, there isn't really any reason to do it in
a different way from the original design. This commit changes the
layout to the newfs_hammer way by rewriting hammer_format_freemap().
(hammer_iterate_l1l2_entries() is tightly coupled with its callback
handlers that the above layout difference can't be fixed by just
changing phys_off to layer1->phys_offset. layer1->phys_offset
doesn't hold a valid offset at this point until all layer2 entries
are filled in, while doing layer2 stuff requires layer1->phys_offset.
This commit based on the previous 3 commits rewrites hammer_format
_freemap() without using hammer_iterate_l1l2_entries().)
This commit does not affect a volume that was previously added
by hammer volume-add. Also no need to advance HAMMER volume version.
Summary of changes:
sys/vfs/hammer/hammer_volume.c | 192 ++++++++++++++++++++++++-----------------
1 file changed, 111 insertions(+), 81 deletions(-)
DragonFly BSD source repository
More information about the Commits