Attempted alternate redund block layout in lfsr_mdir_t

The idea here is to revert moving redund blocks into lfsr_rbyd_t, and
instead just keep a redundant copy of the rbyd blocks in the redund
blocks in lfsr_mdir_t.

Surprisingly, extra overhead in lfsr_mdir_t ended up with worse stack
usage than extra overhead in lfsr_rbyd_t. I guess we end up allocated
more mdirs than rbyds, which makes a bit of sense given how complicated
lfsr_mdir_commit is:

                    code          stack          structs
  redund union:    30976           2496             1072
  redund in rbyd:  30948 (-0.1%)   2528 (+1.3%)     1100 (+2.6%)
  redund in mdir:  31000 (+0.1%)   2536 (+1.6%)     1092 (+1.8%)

The mdir option does seem to improve struct overhead, but this hasn't
been a reliable measurement since it doesn't take into account how many
of each struct is allocated.

Given that the mdir option is inferior in both code and stack cost, and
requires more care to keep the rbyd/redund blocks in sync, I think I'm
going to revert this for now but keep the commit in the commit history
since it's an interesting comparison.
This commit is contained in:
Christopher Haster
2023-11-26 11:39:13 -06:00
parent becbc0c2ad
commit 9d182c2055
6 changed files with 847 additions and 810 deletions
+99 -85
View File
@@ -2044,8 +2044,8 @@ static inline bool lfsr_rbyd_isfetched(const lfsr_rbyd_t *rbyd) {
static inline int lfsr_rbyd_cmp(
const lfsr_rbyd_t *a,
const lfsr_rbyd_t *b) {
if (a->blocks[0] != b->blocks[0]) {
return a->blocks[0] - b->blocks[0];
if (a->block != b->block) {
return a->block - b->block;
} else {
return a->trunk - b->trunk;
}
@@ -2055,13 +2055,13 @@ static inline int lfsr_rbyd_cmp(
// allocate an rbyd block
static int lfsr_rbyd_alloc(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
*rbyd = (lfsr_rbyd_t){.weight=0, .trunk=0, .eoff=0, .cksum=0};
int err = lfs_alloc(lfs, &rbyd->blocks[0]);
int err = lfs_alloc(lfs, &rbyd->block);
if (err) {
return err;
}
// TODO should erase be implicit in alloc eventually?
err = lfsr_bd_erase(lfs, rbyd->blocks[0]);
err = lfsr_bd_erase(lfs, rbyd->block);
if (err) {
return err;
}
@@ -2079,7 +2079,7 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
return err;
}
rbyd->blocks[0] = block;
rbyd->block = block;
rbyd->eoff = 0;
rbyd->trunk = 0;
@@ -2231,7 +2231,7 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// this failed most likely a previous prog was interrupted, we
// need a new erase
uint32_t ecksum_ = 0;
err = lfsr_bd_cksum(lfs, rbyd->blocks[0], rbyd->eoff, 0, ecksum.size,
err = lfsr_bd_cksum(lfs, rbyd->block, rbyd->eoff, 0, ecksum.size,
&ecksum_);
if (err && err != LFS_ERR_CORRUPT) {
return err;
@@ -2270,7 +2270,7 @@ static int lfsr_rbyd_fetchvalidate(lfs_t *lfs, lfsr_rbyd_t *rbyd,
if (rbyd->cksum != cksum) {
LFS_ERROR("Found rbyd cksum mismatch rbyd 0x%"PRIx32".%"PRIx32", "
"cksum 0x%08"PRIx32" (!= 0x%08"PRIx32")",
rbyd->blocks[0], rbyd->trunk, rbyd->cksum, cksum);
rbyd->block, rbyd->trunk, rbyd->cksum, cksum);
return LFS_ERR_CORRUPT;
}
@@ -2310,7 +2310,7 @@ static int lfsr_rbyd_lookupnext(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
lfsr_rid_t weight;
lfs_size_t jump;
lfs_ssize_t d = lfsr_bd_readtag(lfs,
rbyd->blocks[0], branch, 0,
rbyd->block, branch, 0,
&alt, &weight, &jump, NULL);
if (d < 0) {
return d;
@@ -2353,7 +2353,7 @@ static int lfsr_rbyd_lookupnext(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
*weight_ = upper - lower;
}
if (data_) {
*data_ = LFSR_DATA_DISK(rbyd->blocks[0], branch + d, jump);
*data_ = LFSR_DATA_DISK(rbyd->block, branch + d, jump);
}
return 0;
}
@@ -2401,7 +2401,7 @@ static int lfsr_rbyd_appendrev(lfs_t *lfs, lfsr_rbyd_t *rbyd, uint32_t rev) {
// intentionally allow the revision count to overflow
uint8_t rev_buf[sizeof(uint32_t)];
lfs_tole32_(rev, &rev_buf);
int err = lfsr_bd_prog(lfs, rbyd->blocks[0], rbyd->eoff,
int err = lfsr_bd_prog(lfs, rbyd->block, rbyd->eoff,
&rev_buf, sizeof(uint32_t), &rbyd->cksum);
if (err) {
return err;
@@ -2426,7 +2426,7 @@ static int lfsr_rbyd_p_flush(lfs_t *lfs, lfsr_rbyd_t *rbyd,
lfsr_rid_t weight = p_weights[3-1-i];
lfs_size_t jump = rbyd->eoff - p_jumps[3-1-i];
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
alt, weight, jump,
&rbyd->cksum);
if (d < 0) {
@@ -2652,7 +2652,7 @@ static int lfsr_rbyd_appendattr(lfs_t *lfs, lfsr_rbyd_t *rbyd,
lfsr_rid_t weight;
lfs_size_t jump;
lfs_ssize_t d = lfsr_bd_readtag(lfs,
rbyd->blocks[0], branch, 0,
rbyd->block, branch, 0,
&alt, &weight, &jump, NULL);
if (d < 0) {
return d;
@@ -2990,7 +2990,7 @@ leaf:;
//
// note we always need a non-alt to terminate the trunk, otherwise we
// can't find trunks during fetch
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
// rm => null or shrubnull, otherwise strip off control bits
(lfsr_tag_isrm(tag)
? lfsr_tag_mode(lfsr_tag_shrubkey(tag))
@@ -3004,7 +3004,7 @@ leaf:;
rbyd->eoff += d;
// don't forget the data!
err = lfsr_bd_progdata(lfs, rbyd->blocks[0], rbyd->eoff, data,
err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->eoff, data,
&rbyd->cksum);
if (err) {
return err;
@@ -3064,7 +3064,7 @@ static int lfsr_rbyd_appendcksum(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
// read the leading byte in case we need to change the expected
// value of the next tag's valid bit
int err = lfsr_bd_read(lfs,
rbyd->blocks[0], aligned_eoff, lfs->cfg->prog_size,
rbyd->block, aligned_eoff, lfs->cfg->prog_size,
&perturb, 1);
if (err && err != LFS_ERR_CORRUPT) {
return err;
@@ -3073,8 +3073,7 @@ static int lfsr_rbyd_appendcksum(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
// find the expected ecksum, don't bother avoiding a reread of the
// perturb byte, as it should still be in our cache
lfsr_ecksum_t ecksum = {.size=lfs->cfg->prog_size, .cksum=0};
err = lfsr_bd_cksum(lfs,
rbyd->blocks[0], aligned_eoff, lfs->cfg->prog_size,
err = lfsr_bd_cksum(lfs, rbyd->block, aligned_eoff, lfs->cfg->prog_size,
lfs->cfg->prog_size,
&ecksum.cksum);
if (err && err != LFS_ERR_CORRUPT) {
@@ -3083,7 +3082,7 @@ static int lfsr_rbyd_appendcksum(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
uint8_t ecksum_buf[LFSR_ECKSUM_DSIZE];
lfsr_data_t ecksum_data = lfsr_data_fromecksum(&ecksum, ecksum_buf);
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
LFSR_TAG_ECKSUM, 0, lfsr_data_size(&ecksum_data),
&rbyd->cksum);
if (d < 0) {
@@ -3091,7 +3090,7 @@ static int lfsr_rbyd_appendcksum(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
}
rbyd->eoff += d;
err = lfsr_bd_progdata(lfs, rbyd->blocks[0], rbyd->eoff, ecksum_data,
err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->eoff, ecksum_data,
&rbyd->cksum);
if (err) {
return err;
@@ -3136,7 +3135,7 @@ static int lfsr_rbyd_appendcksum(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
}
lfs_tole32_(rbyd->cksum, &cksum_buf[2+1+5]);
int err = lfsr_bd_prog(lfs, rbyd->blocks[0], rbyd->eoff,
int err = lfsr_bd_prog(lfs, rbyd->block, rbyd->eoff,
cksum_buf, 2+1+5+4,
NULL);
if (err) {
@@ -3235,7 +3234,7 @@ static int lfsr_rbyd_appendcompactattr(lfs_t *lfs, lfsr_rbyd_t *rbyd,
}
// write the tag
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
tag, weight, lfsr_data_size(&data),
&rbyd->cksum);
if (d < 0) {
@@ -3244,7 +3243,7 @@ static int lfsr_rbyd_appendcompactattr(lfs_t *lfs, lfsr_rbyd_t *rbyd,
rbyd->eoff += d;
// and the data
int err = lfsr_bd_progdata(lfs, rbyd->blocks[0], rbyd->eoff, data,
int err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->eoff, data,
&rbyd->cksum);
if (err) {
return err;
@@ -3313,7 +3312,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// empty rbyd? write a null tag so our trunk can still point to something
if (rbyd->eoff == off) {
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
shrub ? LFSR_TAG_SHRUB(NULL) : LFSR_TAG_NULL, 0, 0,
&rbyd->cksum);
if (d < 0) {
@@ -3344,7 +3343,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
lfsr_rid_t weight__;
lfs_size_t size__;
lfs_ssize_t d = lfsr_bd_readtag(lfs,
rbyd->blocks[0], off, layer_ - off,
rbyd->block, off, layer_ - off,
&tag__, &weight__, &size__, NULL);
if (d < 0) {
return d;
@@ -3387,8 +3386,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
}
// connect with an altle
lfs_ssize_t d = lfsr_bd_progtag(lfs,
rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
LFSR_TAG_ALT(LE, B, lfsr_tag_key(tag)),
weight,
rbyd->eoff - trunk,
@@ -3400,7 +3398,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
}
// terminate with a null tag
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->blocks[0], rbyd->eoff,
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
shrub ? LFSR_TAG_SHRUB(NULL) : LFSR_TAG_NULL, 0, 0,
&rbyd->cksum);
if (d < 0) {
@@ -3713,7 +3711,7 @@ static lfsr_data_t lfsr_data_frombranch(const lfsr_rbyd_t *branch,
uint8_t buffer[static LFSR_BRANCH_DSIZE]) {
lfs_ssize_t d = 0;
lfs_ssize_t d_ = lfs_toleb128(branch->blocks[0], &buffer[d], 5);
lfs_ssize_t d_ = lfs_toleb128(branch->block, &buffer[d], 5);
LFS_ASSERT(d_ >= 0);
d += d_;
@@ -3735,7 +3733,7 @@ static int lfsr_data_readbranch(lfs_t *lfs, lfsr_data_t *data,
branch->eoff = 0;
branch->weight = weight;
int err = lfsr_data_readleb128(lfs, data, (int32_t*)&branch->blocks[0]);
int err = lfsr_data_readleb128(lfs, data, (int32_t*)&branch->block);
if (err) {
return err;
}
@@ -3942,8 +3940,7 @@ static int lfsr_btree_parent(lfs_t *lfs, const lfsr_btree_t *btree,
}
// found our child?
if (branch_.blocks[0] == child->blocks[0]
&& branch_.trunk == child->trunk) {
if (branch_.block == child->block && branch_.trunk == child->trunk) {
// TODO how many of these should be conditional?
if (rbyd_) {
*rbyd_ = branch;
@@ -4001,7 +3998,7 @@ static lfs_ssize_t lfsr_btree_commit_(lfs_t *lfs,
lfsr_rbyd_t parent = {.trunk=0, .weight=0};
lfsr_srid_t rid;
// are we root?
if (rbyd.blocks[0] == btree->blocks[0] || rbyd.trunk == 0) {
if (rbyd.block == btree->block || rbyd.trunk == 0) {
// new root? shrub root? yield creation of new roots to
// higher-level bshrub/btree logic
if (shrub || rbyd.trunk == 0) {
@@ -4037,7 +4034,7 @@ static lfs_ssize_t lfsr_btree_commit_(lfs_t *lfs,
// a funny benefit is we cache the root of our btree this way
if (!lfsr_rbyd_isfetched(&rbyd)) {
int err = lfsr_rbyd_fetchvalidate(lfs, &rbyd,
rbyd.blocks[0], rbyd.trunk, rbyd.weight, rbyd.cksum);
rbyd.block, rbyd.trunk, rbyd.weight, rbyd.cksum);
if (err) {
return err;
}
@@ -4731,12 +4728,12 @@ static int lfsr_btree_traverse(lfs_t *lfs, const lfsr_btree_t *btree,
static inline bool lfsr_bshrub_isbshrub(
const lfsr_mdir_t *mdir, const lfsr_bshrub_t *bshrub) {
return mdir->rbyd.blocks[0] == bshrub->rbyd.blocks[0];
return mdir->blocks[0] == bshrub->rbyd.block;
}
static inline bool lfsr_bshrub_isbtree(
const lfsr_mdir_t *mdir, const lfsr_bshrub_t *bshrub) {
return mdir->rbyd.blocks[0] != bshrub->rbyd.blocks[0];
return mdir->blocks[0] != bshrub->rbyd.block;
}
static inline int lfsr_bshrub_cmp(
@@ -4750,7 +4747,7 @@ static inline int lfsr_bshrub_cmp(
static int lfsr_bshrub_alloc(lfs_t *lfs,
const lfsr_mdir_t *mdir, lfsr_bshrub_t *bshrub) {
(void)lfs;
bshrub->rbyd.blocks[0] = mdir->rbyd.blocks[0];
bshrub->rbyd.block = mdir->rbyd.block;
bshrub->rbyd.trunk = 0;
bshrub->rbyd.weight = 0;
bshrub->progged = 0;
@@ -4762,7 +4759,7 @@ static int lfsr_bshrub_alloc(lfs_t *lfs,
static int lfsr_bshrub_fetch(lfs_t *lfs,
const lfsr_mdir_t *mdir, lfsr_bshrub_t *bshrub,
lfs_size_t trunk, lfsr_rid_t weight) {
bshrub->rbyd.blocks[0] = mdir->rbyd.blocks[0];
bshrub->rbyd.block = mdir->rbyd.block;
bshrub->rbyd.trunk = trunk;
bshrub->rbyd.weight = weight;
@@ -5009,7 +5006,7 @@ static int lfsr_data_readmptr(lfs_t *lfs, lfsr_data_t *data,
// mdir convenience functions
static inline const lfsr_mptr_t *lfsr_mdir_mptr(const lfsr_mdir_t *mdir) {
return (const lfsr_mptr_t*)mdir->rbyd.blocks;
return (const lfsr_mptr_t*)mdir->blocks;
}
static inline int lfsr_mdir_cmp(const lfsr_mdir_t *a, const lfsr_mdir_t *b) {
@@ -5032,6 +5029,14 @@ static inline bool lfsr_mdir_isroot(const lfsr_mdir_t *mdir) {
return lfsr_mid_isroot(mdir->mid);
}
// sync on-disk state, note this does not touch the mid
static inline void lfsr_mdir_sync(lfsr_mdir_t *mdir,
const lfsr_mdir_t *mdir_) {
mdir->blocks[0] = mdir_->blocks[0];
mdir->blocks[1] = mdir_->blocks[1];
mdir->rbyd = mdir_->rbyd;
}
// track opened mdirs that may need to by updated
static void lfsr_mdir_addopened(lfs_t *lfs, int type,
lfsr_openedmdir_t *opened) {
@@ -5099,9 +5104,10 @@ static int lfsr_mdir_fetch(lfs_t *lfs, lfsr_mdir_t *mdir,
}
if (err != LFS_ERR_CORRUPT) {
// keep track of redund blocks for compactions
mdir->mid = mid;
// keep track of other block for compactions
mdir->rbyd.blocks[1] = blocks_[1];
mdir->blocks[0] = blocks_[0];
mdir->blocks[1] = blocks_[1];
return 0;
}
@@ -5116,6 +5122,8 @@ static int lfsr_mdir_fetch(lfs_t *lfs, lfsr_mdir_t *mdir,
static int lfsr_mdir_lookupnext(lfs_t *lfs, const lfsr_mdir_t *mdir,
lfsr_smid_t mid, lfsr_tag_t tag,
lfsr_tag_t *tag_, lfsr_data_t *data_) {
LFS_ASSERT(mdir->blocks[0] == mdir->rbyd.block);
lfsr_smid_t mid_;
lfsr_tag_t tag__;
int err = lfsr_rbyd_lookupnext(lfs, &mdir->rbyd,
@@ -5203,6 +5211,8 @@ static int lfsr_mtree_lookup(lfs_t *lfs, lfsr_smid_t mid,
LFS_ASSERT(mid >= 0);
LFS_ASSERT(mid < (lfsr_smid_t)lfsr_mweight(lfs));
mdir_->mid = mid;
mdir_->blocks[0] = lfs->mroot.blocks[0];
mdir_->blocks[1] = lfs->mroot.blocks[1];
mdir_->rbyd = lfs->mroot.rbyd;
return 0;
@@ -5287,12 +5297,13 @@ static int lfsr_mdir_alloc(lfs_t *lfs, lfsr_mdir_t *mdir, lfsr_smid_t mid) {
// allocate two blocks
for (int i = 0; i < 2; i++) {
int err = lfs_alloc(lfs, &mdir->rbyd.blocks[i]);
int err = lfs_alloc(lfs, &mdir->blocks[i]);
if (err) {
return err;
}
}
mdir->rbyd.block = mdir->blocks[0];
mdir->rbyd.weight = 0;
mdir->rbyd.trunk = 0;
mdir->rbyd.eoff = 0;
@@ -5303,7 +5314,7 @@ static int lfsr_mdir_alloc(lfs_t *lfs, lfsr_mdir_t *mdir, lfsr_smid_t mid) {
// we use whatever is on-disk to avoid needing to rewrite the
// redund block
uint32_t rev;
int err = lfsr_bd_read(lfs, mdir->rbyd.blocks[1], 0, sizeof(uint32_t),
int err = lfsr_bd_read(lfs, mdir->blocks[1], 0, sizeof(uint32_t),
&rev, sizeof(uint32_t));
if (err && err != LFS_ERR_CORRUPT) {
return err;
@@ -5318,7 +5329,7 @@ static int lfsr_mdir_alloc(lfs_t *lfs, lfsr_mdir_t *mdir, lfsr_smid_t mid) {
}
// erase, preparing for compact
err = lfsr_bd_erase(lfs, mdir->rbyd.blocks[0]);
err = lfsr_bd_erase(lfs, mdir->blocks[0]);
if (err) {
return err;
}
@@ -5340,7 +5351,7 @@ static int lfsr_mdir_swap(lfs_t *lfs, lfsr_mdir_t *mdir_,
// first thing we need to do is read our current revision count
uint32_t rev;
int err = lfsr_bd_read(lfs, mdir->rbyd.blocks[0], 0, sizeof(uint32_t),
int err = lfsr_bd_read(lfs, mdir->blocks[0], 0, sizeof(uint32_t),
&rev, sizeof(uint32_t));
if (err && err != LFS_ERR_CORRUPT) {
return err;
@@ -5358,15 +5369,16 @@ static int lfsr_mdir_swap(lfs_t *lfs, lfsr_mdir_t *mdir_,
}
// swap our blocks
mdir_->rbyd.blocks[0] = mdir->rbyd.blocks[1];
mdir_->rbyd.blocks[1] = mdir->rbyd.blocks[0];
mdir_->blocks[0] = mdir->blocks[1];
mdir_->blocks[1] = mdir->blocks[0];
mdir_->rbyd.block = mdir_->blocks[0];
mdir_->rbyd.weight = 0;
mdir_->rbyd.trunk = 0;
mdir_->rbyd.eoff = 0;
mdir_->rbyd.cksum = 0;
// erase, preparing for compact
err = lfsr_bd_erase(lfs, mdir_->rbyd.blocks[0]);
err = lfsr_bd_erase(lfs, mdir_->blocks[0]);
if (err) {
return err;
}
@@ -5396,6 +5408,7 @@ static inline bool lfsr_file_isunsynced(const lfsr_file_t *file);
static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir,
lfsr_srid_t start_rid, lfsr_srid_t end_rid,
const lfsr_attr_t *attrs, lfs_size_t attr_count) {
LFS_ASSERT(mdir->blocks[0] == mdir->rbyd.block);
// try to append a commit
lfsr_mdir_t mdir_ = *mdir;
// mark as erased in case of failure
@@ -5565,6 +5578,7 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir,
static int lfsr_mdir_compact__(lfs_t *lfs, lfsr_mdir_t *mdir_,
lfsr_srid_t start_rid, lfsr_srid_t end_rid,
const lfsr_mdir_t *mdir) {
LFS_ASSERT(mdir_->blocks[0] == mdir_->rbyd.block);
// this is basically the same as lfsr_rbyd_appendcompactrbyd +
// lfsr_rbyd_compact, but with special handling for inlined trees.
//
@@ -5624,7 +5638,7 @@ static int lfsr_mdir_compact__(lfs_t *lfs, lfsr_mdir_t *mdir_,
// this is a bit tricky since we don't know the tag size,
// but we have just enough info
file->u.bsprout.data = LFSR_DATA_DISK(
mdir_->rbyd.blocks[0],
mdir_->rbyd.block,
mdir_->rbyd.eoff - lfsr_data_size(&data),
lfsr_data_size(&data));
}
@@ -5727,7 +5741,7 @@ static int lfsr_mdir_compact__(lfs_t *lfs, lfsr_mdir_t *mdir_,
// this is a bit tricky since we don't know the tag size,
// but we have just enough info
file->u.bsprout.data_ = LFSR_DATA_DISK(
mdir_->rbyd.blocks[0],
mdir_->rbyd.block,
mdir_->rbyd.eoff
- lfsr_data_size(&file->u.bsprout.data),
lfsr_data_size(&file->u.bsprout.data));
@@ -6061,8 +6075,8 @@ static int lfsr_mroot_commit(lfs_t *lfs,
LFS_DEBUG("Relocating mroot 0x{%"PRIx32",%"PRIx32"} "
"-> 0x{%"PRIx32",%"PRIx32"}",
mrootchild.rbyd.blocks[0], mrootchild.rbyd.blocks[1],
mrootchild_.rbyd.blocks[0], mrootchild_.rbyd.blocks[1]);
mrootchild.blocks[0], mrootchild.blocks[1],
mrootchild_.blocks[0], mrootchild_.blocks[1]);
mrootchild = mrootparent_;
@@ -6088,9 +6102,9 @@ static int lfsr_mroot_commit(lfs_t *lfs,
LFS_DEBUG("Extending mroot 0x{%"PRIx32",%"PRIx32"}"
" -> 0x{%"PRIx32",%"PRIx32"}"
", 0x{%"PRIx32",%"PRIx32"}",
mrootchild.rbyd.blocks[0], mrootchild.rbyd.blocks[1],
mrootchild.rbyd.blocks[0], mrootchild.rbyd.blocks[1],
mrootchild_.rbyd.blocks[0], mrootchild_.rbyd.blocks[1]);
mrootchild.blocks[0], mrootchild.blocks[1],
mrootchild.blocks[0], mrootchild.blocks[1],
mrootchild_.blocks[0], mrootchild_.blocks[1]);
// compact into the new mroot anchor
lfsr_mdir_t mrootanchor_;
@@ -6166,7 +6180,7 @@ static int lfsr_mroot_commit(lfs_t *lfs,
}
// update any opened mdirs in our mroot
opened->mdir.rbyd = mroot_.rbyd;
lfsr_mdir_sync(&opened->mdir, &mroot_);
}
}
}
@@ -6302,7 +6316,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
}
// keep mdir_ in sync with mroot
mdir_.rbyd = lfs->mroot.rbyd;
lfsr_mdir_sync(&mdir_, &lfs->mroot);
// otherwise commit normally
} else {
@@ -6383,9 +6397,9 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
"-> 0x{%"PRIx32",%"PRIx32"}, "
"0x{%"PRIx32",%"PRIx32"}",
mdir->mid >> lfs->mbits,
mdir->rbyd.blocks[0], mdir->rbyd.blocks[1],
mdir_.rbyd.blocks[0], mdir_.rbyd.blocks[1],
msibling_.rbyd.blocks[0], msibling_.rbyd.blocks[1]);
mdir->blocks[0], mdir->blocks[1],
mdir_.blocks[0], mdir_.blocks[1],
msibling_.blocks[0], msibling_.blocks[1]);
// because of defered commits, both children can still be reduced
// to zero, need to catch this here
@@ -6395,11 +6409,11 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
LFS_DEBUG("Dropping mdir %"PRId32" "
"0x{%"PRIx32",%"PRIx32"}",
mdir_.mid >> lfs->mbits,
mdir_.rbyd.blocks[0], mdir_.rbyd.blocks[1]);
mdir_.blocks[0], mdir_.blocks[1]);
LFS_DEBUG("Dropping mdir %"PRId32" "
"0x{%"PRIx32",%"PRIx32"}",
msibling_.mid >> lfs->mbits,
msibling_.rbyd.blocks[0], msibling_.rbyd.blocks[1]);
msibling_.blocks[0], msibling_.blocks[1]);
goto drop;
// one sibling reduced to zero
@@ -6407,7 +6421,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
LFS_DEBUG("Dropping mdir %"PRId32" "
"0x{%"PRIx32",%"PRIx32"}",
msibling_.mid >> lfs->mbits,
msibling_.rbyd.blocks[0], msibling_.rbyd.blocks[1]);
msibling_.blocks[0], msibling_.blocks[1]);
goto relocate;
// other sibling reduced to zero
@@ -6415,8 +6429,8 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
LFS_DEBUG("Dropping mdir %"PRId32" "
"0x{%"PRIx32",%"PRIx32"}",
mdir_.mid >> lfs->mbits,
mdir_.rbyd.blocks[0], mdir_.rbyd.blocks[1]);
mdir_.rbyd = msibling_.rbyd;
mdir_.blocks[0], mdir_.blocks[1]);
lfsr_mdir_sync(&mdir_, &msibling_);
goto relocate;
}
@@ -6515,7 +6529,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
LFS_DEBUG("Dropping mdir %"PRId32" "
"0x{%"PRIx32",%"PRIx32"}",
mdir->mid >> lfs->mbits,
mdir->rbyd.blocks[0], mdir->rbyd.blocks[1]);
mdir->blocks[0], mdir->blocks[1]);
// consume gstate so we don't lose any info
err = lfsr_fs_consumegdelta(lfs, mdir);
@@ -6587,8 +6601,8 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
LFS_DEBUG("Relocating mdir %"PRId32" "
"0x{%"PRIx32",%"PRIx32"} -> 0x{%"PRIx32",%"PRIx32"}",
mdir->mid >> lfs->mbits,
mdir->rbyd.blocks[0], mdir->rbyd.blocks[1],
mdir_.rbyd.blocks[0], mdir_.rbyd.blocks[1]);
mdir->blocks[0], mdir->blocks[1],
mdir_.blocks[0], mdir_.blocks[1]);
relocate:;
// new mtree?
@@ -6691,9 +6705,9 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
>= mdir_.rbyd.weight) {
opened->mdir.mid += lfsr_mweight(lfs)
- mdir_.rbyd.weight;
opened->mdir.rbyd = msibling_.rbyd;
lfsr_mdir_sync(&opened->mdir, &msibling_);
} else {
opened->mdir.rbyd = mdir_.rbyd;
lfsr_mdir_sync(&opened->mdir, &mdir_);
}
} else if (opened->mdir.mid > mdir->mid) {
opened->mdir.mid += mdelta;
@@ -6744,13 +6758,13 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
// update mdir to follow requested rid
if (mdir->mid == -1) {
mdir->rbyd = lfs->mroot.rbyd;
lfsr_mdir_sync(mdir, &lfs->mroot);
} else if (mdelta > 0
&& lfsr_mdir_rid(lfs, mdir) >= mdir_.rbyd.weight) {
mdir->mid += lfsr_mweight(lfs) - mdir_.rbyd.weight;
mdir->rbyd = msibling_.rbyd;
lfsr_mdir_sync(mdir, &msibling_);
} else {
mdir->rbyd = mdir_.rbyd;
lfsr_mdir_sync(mdir, &mdir_);
}
return 0;
@@ -7190,7 +7204,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal,
// match
if (lfsr_traversal_isvalidate(traversal)) {
err = lfsr_rbyd_fetchvalidate(lfs, &tinfo->u.rbyd,
tinfo->u.rbyd.blocks[0], tinfo->u.rbyd.trunk,
tinfo->u.rbyd.block, tinfo->u.rbyd.trunk,
tinfo->u.rbyd.weight,
tinfo->u.rbyd.cksum);
if (err) {
@@ -7240,7 +7254,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal,
// uninitialized in mountinited and 2. stack really matters since
// we're at the bottom of lfs_alloc)
if (binfo.tag == LFSR_TAG_BRANCH
&& binfo.u.rbyd.blocks[0] == lfs->mtree.u.btree.blocks[0]) {
&& binfo.u.rbyd.block == lfs->mtree.u.btree.block) {
continue;
}
@@ -7251,7 +7265,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal,
// match
if (lfsr_traversal_isvalidate(traversal)) {
err = lfsr_rbyd_fetchvalidate(lfs, &binfo.u.rbyd,
binfo.u.rbyd.blocks[0], binfo.u.rbyd.trunk,
binfo.u.rbyd.block, binfo.u.rbyd.trunk,
binfo.u.rbyd.weight,
binfo.u.rbyd.cksum);
if (err) {
@@ -7428,7 +7442,7 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal,
// match
if (lfsr_traversal_isvalidate(traversal)) {
err = lfsr_rbyd_fetchvalidate(lfs, &binfo.u.rbyd,
binfo.u.rbyd.blocks[0], binfo.u.rbyd.trunk,
binfo.u.rbyd.block, binfo.u.rbyd.trunk,
binfo.u.rbyd.weight,
binfo.u.rbyd.cksum);
if (err) {
@@ -8070,9 +8084,9 @@ static int lfsr_formatinited(lfs_t *lfs) {
for (int i = 0; i < 2; i++) {
// write superblock to both rbyds in the root mroot to hopefully
// avoid mounting an older filesystem on disk
lfsr_rbyd_t rbyd = {.blocks[0]=i, .eoff=0, .trunk=0};
lfsr_rbyd_t rbyd = {.block=i, .eoff=0, .trunk=0};
int err = lfsr_bd_erase(lfs, rbyd.blocks[0]);
int err = lfsr_bd_erase(lfs, rbyd.block);
if (err) {
return err;
}
@@ -8139,8 +8153,8 @@ int lfsr_mount(lfs_t *lfs, const struct lfs_config *cfg) {
"bd %"PRId32"x%"PRId32,
LFS_DISK_VERSION_MAJOR,
LFS_DISK_VERSION_MINOR,
lfs->mroot.rbyd.blocks[0],
lfs->mroot.rbyd.blocks[1],
lfs->mroot.blocks[0],
lfs->mroot.blocks[1],
lfs->mroot.rbyd.trunk,
lfsr_mtree_weight(lfs) / lfsr_mweight(lfs),
lfsr_mweight(lfs),
@@ -8270,11 +8284,11 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
// mark any blocks we see at in-use, including any btree/mdir blocks
if (tinfo.tag == LFSR_TAG_MDIR) {
lfs_alloc_setinuse(lfs, tinfo.u.mdir.rbyd.blocks[1]);
lfs_alloc_setinuse(lfs, tinfo.u.mdir.rbyd.blocks[0]);
lfs_alloc_setinuse(lfs, tinfo.u.mdir.blocks[1]);
lfs_alloc_setinuse(lfs, tinfo.u.mdir.blocks[0]);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
lfs_alloc_setinuse(lfs, tinfo.u.rbyd.blocks[0]);
lfs_alloc_setinuse(lfs, tinfo.u.rbyd.block);
} else if (tinfo.tag == LFSR_TAG_BLOCK) {
lfs_alloc_setinuse(lfs, tinfo.u.bptr.block);
@@ -9011,14 +9025,14 @@ static inline bool lfsr_file_isbsprout(const lfsr_file_t *file) {
return (lfs_size_t)file->u.bsprout.data.u.disk.size
> (LFSR_FILE_ISDIRECT | 0)
&& file->u.bsprout.data.u.disk.block
== file->mdir.rbyd.blocks[0];
== file->mdir.blocks[0];
}
static inline bool lfsr_file_isbptr(const lfsr_file_t *file) {
return (lfs_size_t)file->u.bsprout.data.u.disk.size
> (LFSR_FILE_ISDIRECT | 0)
&& file->u.bsprout.data.u.disk.block
!= file->mdir.rbyd.blocks[0];
!= file->mdir.blocks[0];
}
static inline bool lfsr_file_isbshrub(const lfsr_file_t *file) {
+3 -1
View File
@@ -363,7 +363,7 @@ typedef struct lfs_cache {
typedef struct lfsr_rbyd {
// note this lines up with weight in lfsr_btree_t
lfsr_srid_t weight;
lfs_block_t blocks[2];
lfs_block_t block;
// eoff=0, trunk=0 => not yet committed
// eoff=0, trunk>0 => not yet fetched
// eoff>=block_size => rbyd not erased/needs compaction
@@ -388,6 +388,8 @@ typedef struct lfsr_mptr {
typedef struct lfsr_mdir {
lfsr_smid_t mid;
// block[0] should always be the active block, block[0]=rbyd.block
lfs_block_t blocks[2];
lfsr_rbyd_t rbyd;
} lfsr_mdir_t;
+24 -27
View File
@@ -176,23 +176,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -333,23 +332,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else if (tinfo.tag == LFSR_TAG_BLOCK) {
printf("traversal: 0x%x block 0x%x\n",
@@ -480,23 +478,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else if (tinfo.tag == LFSR_TAG_BLOCK) {
printf("traversal: 0x%x block 0x%x\n",
+73 -75
View File
@@ -120,7 +120,7 @@ code = '''
lfsr_btree_alloc(&lfs, &btree) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 0);
@@ -154,7 +154,7 @@ code = '''
LFSR_DATA_BUF("a", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -196,7 +196,7 @@ code = '''
LFSR_DATA_BUF("b", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -243,7 +243,7 @@ code = '''
LFSR_DATA_BUF("a", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -293,7 +293,7 @@ code = '''
LFSR_DATA_BUF("c", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 3);
@@ -348,7 +348,7 @@ code = '''
LFSR_DATA_BUF("a", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 3);
@@ -412,7 +412,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n);
@@ -465,7 +465,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n);
@@ -549,7 +549,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -605,7 +605,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n*W);
@@ -727,7 +727,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -810,7 +810,7 @@ code = '''
LFSR_DATA_BUF("A", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -856,7 +856,7 @@ code = '''
LFSR_DATA_BUF("B", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -912,7 +912,7 @@ code = '''
LFSR_DATA_BUF("C", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 3);
@@ -969,7 +969,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -983,7 +983,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -991,7 +991,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == N);
@@ -1042,7 +1042,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1089,7 +1089,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == N);
@@ -1139,7 +1139,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1153,7 +1153,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1161,7 +1161,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == N*W);
@@ -1228,7 +1228,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1294,7 +1294,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -1377,7 +1377,7 @@ code = '''
lfsr_btree_pop(&lfs, &btree, 0) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 0);
@@ -1394,7 +1394,7 @@ code = '''
LFSR_DATA_BUF("A", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -1433,7 +1433,7 @@ code = '''
lfsr_btree_pop(&lfs, &btree, 1) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -1456,7 +1456,7 @@ code = '''
LFSR_DATA_BUF("B", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -1501,7 +1501,7 @@ code = '''
lfsr_btree_pop(&lfs, &btree, 0) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -1524,7 +1524,7 @@ code = '''
LFSR_DATA_BUF("A", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -1571,7 +1571,7 @@ code = '''
lfsr_btree_pop(&lfs, &btree, 2) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -1600,7 +1600,7 @@ code = '''
LFSR_DATA_BUF("C", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 3);
@@ -1654,7 +1654,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1667,7 +1667,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1676,7 +1676,7 @@ code = '''
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == REMAINING);
@@ -1746,7 +1746,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1759,7 +1759,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1767,7 +1767,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == REMAINING);
@@ -1839,7 +1839,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1887,7 +1887,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -1938,7 +1938,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1951,7 +1951,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -1959,7 +1959,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == REMAINING*W);
@@ -2079,7 +2079,7 @@ code = '''
if (err == LFS_ERR_NOSPC) {
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
return;
}
@@ -2136,7 +2136,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -2228,7 +2228,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n);
@@ -2318,7 +2318,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -2377,7 +2377,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n*W);
@@ -2518,7 +2518,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -2621,7 +2621,7 @@ code = '''
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -2687,7 +2687,7 @@ code = '''
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -2748,7 +2748,7 @@ code = '''
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -2818,7 +2818,7 @@ code = '''
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -2932,7 +2932,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -3074,7 +3074,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -3150,7 +3150,7 @@ code = '''
lfsr_btree_alloc(&lfs, &btree) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 0);
@@ -3188,7 +3188,7 @@ code = '''
LFSR_ATTR(0, DATA, 0, BUF("0", 1)))) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 1);
@@ -3244,7 +3244,7 @@ code = '''
LFSR_TAG_DATA, 1, LFSR_DATA_BUF("1", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 2);
@@ -3312,7 +3312,7 @@ code = '''
LFSR_TAG_DATA, 1, LFSR_DATA_BUF("2", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 3);
@@ -3388,7 +3388,7 @@ code = '''
LFSR_TAG_DATA, 1, LFSR_DATA_BUF("1", 1)) => 0;
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == 3);
@@ -3478,7 +3478,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n);
@@ -3593,7 +3593,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -3665,7 +3665,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n*W);
@@ -3808,7 +3808,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -3991,7 +3991,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -4193,7 +4193,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
lfs_size_t total_weight = 0;
@@ -4264,7 +4264,7 @@ code = '''
}
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == n);
@@ -4306,11 +4306,10 @@ code = '''
binfo.bid,
binfo.tag,
binfo.weight,
binfo.u.rbyd.blocks[0], binfo.u.rbyd.trunk);
binfo.u.rbyd.block, binfo.u.rbyd.trunk);
// keep track of seen blocks
seen[binfo.u.rbyd.blocks[0] / 8]
|= 1 << (binfo.u.rbyd.blocks[0] % 8);
seen[binfo.u.rbyd.block / 8] |= 1 << (binfo.u.rbyd.block % 8);
} else if (binfo.tag == LFSR_TAG_DATA) {
printf("traversal: %d 0x%x w%d data %d\n",
@@ -4418,7 +4417,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
@@ -4459,11 +4458,10 @@ code = '''
binfo.bid,
binfo.tag,
binfo.weight,
binfo.u.rbyd.blocks[0], binfo.u.rbyd.trunk);
binfo.u.rbyd.block, binfo.u.rbyd.trunk);
// keep track of seen blocks
seen[binfo.u.rbyd.blocks[0] / 8]
|= 1 << (binfo.u.rbyd.blocks[0] % 8);
seen[binfo.u.rbyd.block / 8] |= 1 << (binfo.u.rbyd.block % 8);
} else if (binfo.tag == LFSR_TAG_DATA) {
printf("traversal: %d 0x%x w%d data %d\n",
@@ -4508,7 +4506,7 @@ code = '''
printf("]\n");
printf("btree: w%d 0x%x.%x\n",
btree.weight,
btree.blocks[0],
btree.block,
btree.trunk);
assert(btree.weight == sim_size);
+115 -89
View File
@@ -2741,10 +2741,14 @@ code = '''
// this test only works if these all fit in the mroot
assert(lfsr_mtree_ismptr(&lfs));
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=0, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=1, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=0,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=1,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -2791,10 +2795,14 @@ code = '''
// this test only works if these all fit in the mroot
assert(lfsr_mtree_ismptr(&lfs));
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=0, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=1, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=0,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=1,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -2834,10 +2842,14 @@ code = '''
// this test only works if these all fit in the mroot
assert(lfsr_mtree_ismptr(&lfs));
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=0, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=1, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=0,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=1,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -2879,10 +2891,14 @@ code = '''
// this test only works if these all fit in the mroot
assert(lfsr_mtree_ismptr(&lfs));
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=0, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=1, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=0,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=1,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -2959,10 +2975,14 @@ code = '''
// this test only works if these all fit in the mroot
assert(lfsr_mtree_ismptr(&lfs));
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=0, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=1, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=0,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=1,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -3061,10 +3081,14 @@ code = '''
assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs));
assert(mdir.rbyd.weight == 3);
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=mdir.mid+0, .rbyd=mdir.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=mdir.mid+2, .rbyd=mdir.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=mdir.mid+0,
.blocks={mdir.blocks[0], mdir.blocks[1]},
.rbyd=mdir.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=mdir.mid+2,
.blocks={mdir.blocks[0], mdir.blocks[1]},
.rbyd=mdir.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -3138,10 +3162,14 @@ code = '''
// this test only works if these all fit in the mroot
assert(lfsr_mtree_ismptr(&lfs));
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=0, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=1, .rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=0,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=1,
.blocks={lfs.mroot.blocks[0], lfs.mroot.blocks[1]},
.rbyd=lfs.mroot.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -3231,10 +3259,14 @@ code = '''
assert(lfsr_mtree_weight(&lfs) == 1*lfsr_mweight(&lfs));
assert(mdir.rbyd.weight == 3);
lfsr_openedmdir_t left_neighbor = {
.mdir={.mid=mdir.mid+0, .rbyd=mdir.rbyd}};
lfsr_openedmdir_t right_neighbor = {
.mdir={.mid=mdir.mid+2, .rbyd=mdir.rbyd}};
lfsr_openedmdir_t left_neighbor = {.mdir={
.mid=mdir.mid+0,
.blocks={mdir.blocks[0], mdir.blocks[1]},
.rbyd=mdir.rbyd}};
lfsr_openedmdir_t right_neighbor = {.mdir={
.mid=mdir.mid+2,
.blocks={mdir.blocks[0], mdir.blocks[1]},
.rbyd=mdir.rbyd}};
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &left_neighbor);
lfsr_mdir_addopened(&lfs, LFS_TYPE_INTERNAL, &right_neighbor);
@@ -3510,23 +3542,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -3626,23 +3657,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -3754,23 +3784,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -3874,23 +3903,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -4005,23 +4033,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -4165,23 +4192,22 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
// keep track of seen blocks
seen[tinfo.u.mdir.rbyd.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[1] % 8);
seen[tinfo.u.mdir.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.rbyd.blocks[0] % 8);
seen[tinfo.u.mdir.blocks[1] / 8]
|= 1 << (tinfo.u.mdir.blocks[1] % 8);
seen[tinfo.u.mdir.blocks[0] / 8]
|= 1 << (tinfo.u.mdir.blocks[0] % 8);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
// keep track of seen blocks
seen[tinfo.u.rbyd.blocks[0] / 8]
|= 1 << (tinfo.u.rbyd.blocks[0] % 8);
seen[tinfo.u.rbyd.block / 8] |= 1 << (tinfo.u.rbyd.block % 8);
} else {
// this shouldn't happen
@@ -4263,13 +4289,13 @@ code = '''
if (tinfo.tag == LFSR_TAG_MDIR) {
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tinfo.tag,
tinfo.u.mdir.rbyd.blocks[0],
tinfo.u.mdir.rbyd.blocks[1]);
tinfo.u.mdir.blocks[0],
tinfo.u.mdir.blocks[1]);
} else if (tinfo.tag == LFSR_TAG_BRANCH) {
printf("traversal: 0x%x btree 0x%x.%x\n",
tinfo.tag,
tinfo.u.rbyd.blocks[0], tinfo.u.rbyd.trunk);
tinfo.u.rbyd.block, tinfo.u.rbyd.trunk);
} else {
// this shouldn't happen
+533 -533
View File
File diff suppressed because it is too large Load Diff