Pad B*-tree files to the alloc block size
This bug was corrupting all volumes over 32 MB (i.e. with a block size exceeding 512 bytes). Oops!
This commit is contained in:
parent
925fd13cd3
commit
829d3a5189
|
@ -103,7 +103,9 @@ def dump_btree(buf):
|
||||||
this_leaf = ndFLink
|
this_leaf = ndFLink
|
||||||
|
|
||||||
|
|
||||||
def make_btree(records, bthKeyLen):
|
def make_btree(records, bthKeyLen, blksize):
|
||||||
|
nodemult = blksize // 512
|
||||||
|
|
||||||
nodelist = [] # append to this as we go
|
nodelist = [] # append to this as we go
|
||||||
|
|
||||||
# pointers per index node, range 2-11
|
# pointers per index node, range 2-11
|
||||||
|
@ -156,7 +158,7 @@ def make_btree(records, bthKeyLen):
|
||||||
# Add map nodes with 3952-bit bitmap recs to cover every node
|
# Add map nodes with 3952-bit bitmap recs to cover every node
|
||||||
bits_covered = 2048
|
bits_covered = 2048
|
||||||
mapnodes = []
|
mapnodes = []
|
||||||
while bits_covered < len(nodelist):
|
while bits_covered < bitmanip.pad_up(len(nodelist), nodemult):
|
||||||
mapnode = _Node(ndType=2, ndNHeight=1)
|
mapnode = _Node(ndType=2, ndNHeight=1)
|
||||||
nodelist.append(mapnode)
|
nodelist.append(mapnode)
|
||||||
mapnodes.append(mapnode)
|
mapnodes.append(mapnode)
|
||||||
|
@ -188,4 +190,7 @@ def make_btree(records, bthKeyLen):
|
||||||
bthDepth, bthRoot, bthNRecs, bthFNode, bthLNode,
|
bthDepth, bthRoot, bthNRecs, bthFNode, bthLNode,
|
||||||
bthNodeSize, bthKeyLen, bthNNodes, bthFree)
|
bthNodeSize, bthKeyLen, bthNNodes, bthFree)
|
||||||
|
|
||||||
|
slop_nodes = bitmanip.pad_up(len(nodelist), nodemult) - len(nodelist)
|
||||||
|
nodelist.append(512 * slop_nodes)
|
||||||
|
|
||||||
return b''.join(bytes(node) for node in nodelist)
|
return b''.join(bytes(node) for node in nodelist)
|
||||||
|
|
|
@ -243,7 +243,7 @@ class Volume(directory.AbstractFolder):
|
||||||
blkaccum = []
|
blkaccum = []
|
||||||
|
|
||||||
# <<< put the empty extents overflow file in here >>>
|
# <<< put the empty extents overflow file in here >>>
|
||||||
extoflowfile = btree.make_btree([], bthKeyLen=7)
|
extoflowfile = btree.make_btree([], bthKeyLen=7, blksize=drAlBlkSiz)
|
||||||
# also need to do some cleverness to ensure that this gets picked up...
|
# also need to do some cleverness to ensure that this gets picked up...
|
||||||
drXTFlSize = len(extoflowfile)
|
drXTFlSize = len(extoflowfile)
|
||||||
drXTExtRec_Start = len(blkaccum)
|
drXTExtRec_Start = len(blkaccum)
|
||||||
|
@ -344,7 +344,7 @@ class Volume(directory.AbstractFolder):
|
||||||
|
|
||||||
# now it is time to sort these records! fuck that shit...
|
# now it is time to sort these records! fuck that shit...
|
||||||
catalog.sort(key=_catalog_rec_sort)
|
catalog.sort(key=_catalog_rec_sort)
|
||||||
catalogfile = btree.make_btree(catalog, bthKeyLen=37)
|
catalogfile = btree.make_btree(catalog, bthKeyLen=37, blksize=drAlBlkSiz)
|
||||||
# also need to do some cleverness to ensure that this gets picked up...
|
# also need to do some cleverness to ensure that this gets picked up...
|
||||||
drCTFlSize = len(catalogfile)
|
drCTFlSize = len(catalogfile)
|
||||||
drCTExtRec_Start = len(blkaccum)
|
drCTExtRec_Start = len(blkaccum)
|
||||||
|
|
Loading…
Reference in New Issue