Fixed explicit trunks messing with canonical checksums
Updating the canonical checksum should only depend on if the tag is a
trunkish tag (not a checksum tag), and not if the tag is in the current
trunk. The trunk parameter to lfsr_rbyd_fetch should have no effect on
the canonical checksum.
Fixed in boath lfsr_rbyd_fetch and scripts.
Curiously no code changes:
code stack
before: 36416 2616
after: 36416 (+0.0%) 2616 (+0.0%
This commit is contained in:
@@ -3066,9 +3066,9 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// found a trunk of a tree?
|
// found a trunk?
|
||||||
if (lfsr_tag_istrunk(tag)
|
if (lfsr_tag_istrunk(tag)) {
|
||||||
&& (!trunk || off <= trunk || trunk__)) {
|
if (!(trunk && off > trunk && !trunk__)) {
|
||||||
// start of trunk?
|
// start of trunk?
|
||||||
if (!trunk__) {
|
if (!trunk__) {
|
||||||
// keep track of trunk's entry point
|
// keep track of trunk's entry point
|
||||||
@@ -3087,12 +3087,6 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
|
|||||||
|
|
||||||
// end of trunk?
|
// end of trunk?
|
||||||
if (!lfsr_tag_isalt(tag)) {
|
if (!lfsr_tag_isalt(tag)) {
|
||||||
// update canonical checksum, xoring out any perturb
|
|
||||||
// state, we don't want erased-state affecting our
|
|
||||||
// canonical checksum
|
|
||||||
cksum = cksum_ ^ ((lfsr_rbyd_isperturb(rbyd))
|
|
||||||
? LFS_CRC32C_ODDZERO
|
|
||||||
: LFS_CRC32C_EVENZERO);
|
|
||||||
// update trunk and weight, unless we are a shrub trunk
|
// update trunk and weight, unless we are a shrub trunk
|
||||||
if (!lfsr_tag_isshrub(tag) || trunk__ == trunk) {
|
if (!lfsr_tag_isshrub(tag) || trunk__ == trunk) {
|
||||||
trunk_ = trunk__;
|
trunk_ = trunk__;
|
||||||
@@ -3102,6 +3096,14 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update canonical checksum, xoring out any perturb
|
||||||
|
// state, we don't want erased-state affecting our
|
||||||
|
// canonical checksum
|
||||||
|
cksum = cksum_ ^ ((lfsr_rbyd_isperturb(rbyd))
|
||||||
|
? LFS_CRC32C_ODDZERO
|
||||||
|
: LFS_CRC32C_EVENZERO);
|
||||||
|
}
|
||||||
|
|
||||||
// skip data
|
// skip data
|
||||||
if (!lfsr_tag_isalt(tag)) {
|
if (!lfsr_tag_isalt(tag)) {
|
||||||
off_ += size;
|
off_ += size;
|
||||||
|
|||||||
+5
-4
@@ -695,8 +695,8 @@ class Rbyd:
|
|||||||
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
# evaluate trunks
|
# evaluate trunks
|
||||||
if (tag & 0xf000) != TAG_CKSUM and (
|
if (tag & 0xf000) != TAG_CKSUM:
|
||||||
not trunk or j_-d <= trunk or trunk___):
|
if not (trunk and j_-d > trunk and not trunk___):
|
||||||
# new trunk?
|
# new trunk?
|
||||||
if not trunk___:
|
if not trunk___:
|
||||||
trunk___ = j_-d
|
trunk___ = j_-d
|
||||||
@@ -707,8 +707,6 @@ class Rbyd:
|
|||||||
|
|
||||||
# end of trunk?
|
# end of trunk?
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
# update canonical checksum, xoring out any perturb state
|
|
||||||
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
|
||||||
# update trunk/weight unless we found a shrub or an
|
# update trunk/weight unless we found a shrub or an
|
||||||
# explicit trunk (which may be a shrub) is requested
|
# explicit trunk (which may be a shrub) is requested
|
||||||
if not tag & TAG_SHRUB or trunk___ == trunk:
|
if not tag & TAG_SHRUB or trunk___ == trunk:
|
||||||
@@ -723,6 +721,9 @@ class Rbyd:
|
|||||||
weight = weight_
|
weight = weight_
|
||||||
trunk___ = 0
|
trunk___ = 0
|
||||||
|
|
||||||
|
# update canonical checksum, xoring out any perturb state
|
||||||
|
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
j_ += size
|
j_ += size
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -368,8 +368,8 @@ class Rbyd:
|
|||||||
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
# evaluate trunks
|
# evaluate trunks
|
||||||
if (tag & 0xf000) != TAG_CKSUM and (
|
if (tag & 0xf000) != TAG_CKSUM:
|
||||||
not trunk or j_-d <= trunk or trunk___):
|
if not (trunk and j_-d > trunk and not trunk___):
|
||||||
# new trunk?
|
# new trunk?
|
||||||
if not trunk___:
|
if not trunk___:
|
||||||
trunk___ = j_-d
|
trunk___ = j_-d
|
||||||
@@ -380,8 +380,6 @@ class Rbyd:
|
|||||||
|
|
||||||
# end of trunk?
|
# end of trunk?
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
# update canonical checksum, xoring out any perturb state
|
|
||||||
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
|
||||||
# update trunk/weight unless we found a shrub or an
|
# update trunk/weight unless we found a shrub or an
|
||||||
# explicit trunk (which may be a shrub) is requested
|
# explicit trunk (which may be a shrub) is requested
|
||||||
if not tag & TAG_SHRUB or trunk___ == trunk:
|
if not tag & TAG_SHRUB or trunk___ == trunk:
|
||||||
@@ -396,6 +394,9 @@ class Rbyd:
|
|||||||
weight = weight_
|
weight = weight_
|
||||||
trunk___ = 0
|
trunk___ = 0
|
||||||
|
|
||||||
|
# update canonical checksum, xoring out any perturb state
|
||||||
|
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
j_ += size
|
j_ += size
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -399,8 +399,8 @@ class Rbyd:
|
|||||||
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
# evaluate trunks
|
# evaluate trunks
|
||||||
if (tag & 0xf000) != TAG_CKSUM and (
|
if (tag & 0xf000) != TAG_CKSUM:
|
||||||
not trunk or j_-d <= trunk or trunk___):
|
if not (trunk and j_-d > trunk and not trunk___):
|
||||||
# new trunk?
|
# new trunk?
|
||||||
if not trunk___:
|
if not trunk___:
|
||||||
trunk___ = j_-d
|
trunk___ = j_-d
|
||||||
@@ -411,8 +411,6 @@ class Rbyd:
|
|||||||
|
|
||||||
# end of trunk?
|
# end of trunk?
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
# update canonical checksum, xoring out any perturb state
|
|
||||||
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
|
||||||
# update trunk/weight unless we found a shrub or an
|
# update trunk/weight unless we found a shrub or an
|
||||||
# explicit trunk (which may be a shrub) is requested
|
# explicit trunk (which may be a shrub) is requested
|
||||||
if not tag & TAG_SHRUB or trunk___ == trunk:
|
if not tag & TAG_SHRUB or trunk___ == trunk:
|
||||||
@@ -427,6 +425,9 @@ class Rbyd:
|
|||||||
weight = weight_
|
weight = weight_
|
||||||
trunk___ = 0
|
trunk___ = 0
|
||||||
|
|
||||||
|
# update canonical checksum, xoring out any perturb state
|
||||||
|
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
j_ += size
|
j_ += size
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -383,8 +383,8 @@ class Rbyd:
|
|||||||
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
# evaluate trunks
|
# evaluate trunks
|
||||||
if (tag & 0xf000) != TAG_CKSUM and (
|
if (tag & 0xf000) != TAG_CKSUM:
|
||||||
not trunk or j_-d <= trunk or trunk___):
|
if not (trunk and j_-d > trunk and not trunk___):
|
||||||
# new trunk?
|
# new trunk?
|
||||||
if not trunk___:
|
if not trunk___:
|
||||||
trunk___ = j_-d
|
trunk___ = j_-d
|
||||||
@@ -395,8 +395,6 @@ class Rbyd:
|
|||||||
|
|
||||||
# end of trunk?
|
# end of trunk?
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
# update canonical checksum, xoring out any perturb state
|
|
||||||
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
|
||||||
# update trunk/weight unless we found a shrub or an
|
# update trunk/weight unless we found a shrub or an
|
||||||
# explicit trunk (which may be a shrub) is requested
|
# explicit trunk (which may be a shrub) is requested
|
||||||
if not tag & TAG_SHRUB or trunk___ == trunk:
|
if not tag & TAG_SHRUB or trunk___ == trunk:
|
||||||
@@ -411,6 +409,9 @@ class Rbyd:
|
|||||||
weight = weight_
|
weight = weight_
|
||||||
trunk___ = 0
|
trunk___ = 0
|
||||||
|
|
||||||
|
# update canonical checksum, xoring out any perturb state
|
||||||
|
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
j_ += size
|
j_ += size
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -577,12 +577,13 @@ def dbg_log(data, block_size, rev, eoff, weight, *,
|
|||||||
|
|
||||||
# end of trunk?
|
# end of trunk?
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
# update canonical checksum, xoring out any perturb state
|
|
||||||
cksum = cksum_ ^ (0xfca42daf if perturb else 0)
|
|
||||||
# derive the current tag's rid from alt weights
|
# derive the current tag's rid from alt weights
|
||||||
rid = lower_ + w-1
|
rid = lower_ + w-1
|
||||||
trunk_ = 0
|
trunk_ = 0
|
||||||
|
|
||||||
|
# update canonical checksum, xoring out any perturb state
|
||||||
|
cksum = cksum_ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
# show human-readable tag representation
|
# show human-readable tag representation
|
||||||
print('%s%08x:%s %*s%s%*s %-*s%s%s%s' % (
|
print('%s%08x:%s %*s%s%*s %-*s%s%s%s' % (
|
||||||
'\x1b[90m' if color and j >= eoff else '',
|
'\x1b[90m' if color and j >= eoff else '',
|
||||||
@@ -976,8 +977,8 @@ def main(disk, blocks=None, *,
|
|||||||
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
cksum__ = cksum_ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
# evaluate trunks
|
# evaluate trunks
|
||||||
if (tag & 0xf000) != TAG_CKSUM and (
|
if (tag & 0xf000) != TAG_CKSUM:
|
||||||
not trunk or j_-d <= trunk or trunk___):
|
if not (trunk and j_-d > trunk and not trunk___):
|
||||||
# new trunk?
|
# new trunk?
|
||||||
if not trunk___:
|
if not trunk___:
|
||||||
trunk___ = j_-d
|
trunk___ = j_-d
|
||||||
@@ -988,8 +989,6 @@ def main(disk, blocks=None, *,
|
|||||||
|
|
||||||
# end of trunk?
|
# end of trunk?
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
# update canonical checksum, xoring out any perturb state
|
|
||||||
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
|
||||||
# update trunk/weight unless we found a shrub or an
|
# update trunk/weight unless we found a shrub or an
|
||||||
# explicit trunk (which may be a shrub) is requested
|
# explicit trunk (which may be a shrub) is requested
|
||||||
if not tag & TAG_SHRUB or trunk___ == trunk:
|
if not tag & TAG_SHRUB or trunk___ == trunk:
|
||||||
@@ -1004,6 +1003,9 @@ def main(disk, blocks=None, *,
|
|||||||
weight = weight_
|
weight = weight_
|
||||||
trunk___ = 0
|
trunk___ = 0
|
||||||
|
|
||||||
|
# update canonical checksum, xoring out any perturb state
|
||||||
|
cksum_ = cksum__ ^ (0xfca42daf if perturb else 0)
|
||||||
|
|
||||||
if not tag & TAG_ALT:
|
if not tag & TAG_ALT:
|
||||||
j_ += size
|
j_ += size
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user