Renamed fcksum -> ecksum

This checksum is used to keep track of if we have erased, and not yet
touched, the unused bytes trailing our current commit in the rbyd.

The working theory is that if any prog attempt is made, it will, most
likely, change the checksum of the contents, allowing littlefs to
determine if trailing erased-state is safe to use, even under powerloss.
littlefs can also perturb future data by a single bit, to force this
checksum to always be invalidated during normal operation.

The original name, "forward erased-state checksums (fcksum)", came from the
idea that the checksum "looks forward" into the next commit.

But after using them for a bit, I think the name is unnecessarily
confusing. It, uh, also looks a lot like a swear word. I think
shortening the name to just "erased-state checksums (ecksum)", even
though the previous name is already in use in  a release, is reasonable.

---

It's probably hard to believe but the name change from fcrc -> ecrc
really was unrelated to the crc -> cksum change. But boy is it
convenient for avoiding an awkward name. A lot of these name changes
involved sed scripts, so I didn't notice how awkward fcksum would be to
use until writing this commit message.
This commit is contained in:
Christopher Haster
2023-08-07 13:43:07 -05:00
parent 7031d6e1b3
commit d2f2b53262
8 changed files with 447 additions and 447 deletions
+107 -107
View File
@@ -630,7 +630,7 @@ enum lfsr_tag_type {
LFSR_TAG_ALTRGT = 0x7000, LFSR_TAG_ALTRGT = 0x7000,
LFSR_TAG_CKSUM = 0x2000, LFSR_TAG_CKSUM = 0x2000,
LFSR_TAG_FCKSUM = 0x2100, LFSR_TAG_ECKSUM = 0x2100,
// in-device only // in-device only
LFSR_TAG_MOVE = 0x0800, LFSR_TAG_MOVE = 0x0800,
@@ -1429,24 +1429,24 @@ typedef struct lfsr_attr {
//#endif //#endif
// fcksum on-disk encoding // erased-state checksum on-disk encoding
typedef struct lfsr_fcksum { typedef struct lfsr_ecksum {
uint32_t cksum; uint32_t cksum;
lfs_size_t size; lfs_size_t size;
} lfsr_fcksum_t; } lfsr_ecksum_t;
// 1 leb128 + 1 crc32c => 9 bytes (worst case) // 1 leb128 + 1 crc32c => 9 bytes (worst case)
#define LFSR_FCKSUM_DSIZE (5+4) #define LFSR_ECKSUM_DSIZE (5+4)
static lfs_ssize_t lfsr_fcksum_todisk(lfs_t *lfs, const lfsr_fcksum_t *fcksum, static lfs_ssize_t lfsr_ecksum_todisk(lfs_t *lfs, const lfsr_ecksum_t *ecksum,
uint8_t buffer[static LFSR_FCKSUM_DSIZE]) { uint8_t buffer[static LFSR_ECKSUM_DSIZE]) {
(void)lfs; (void)lfs;
lfs_ssize_t d = 0; lfs_ssize_t d = 0;
lfs_tole32_(fcksum->cksum, &buffer[d]); lfs_tole32_(ecksum->cksum, &buffer[d]);
d += 4; d += 4;
lfs_ssize_t d_ = lfs_toleb128(fcksum->size, &buffer[d], 5); lfs_ssize_t d_ = lfs_toleb128(ecksum->size, &buffer[d], 5);
if (d_ < 0) { if (d_ < 0) {
return d_; return d_;
} }
@@ -1455,16 +1455,16 @@ static lfs_ssize_t lfsr_fcksum_todisk(lfs_t *lfs, const lfsr_fcksum_t *fcksum,
return d; return d;
} }
static lfs_ssize_t lfsr_fcksum_fromdisk(lfs_t *lfs, lfsr_fcksum_t *fcksum, static lfs_ssize_t lfsr_ecksum_fromdisk(lfs_t *lfs, lfsr_ecksum_t *ecksum,
lfsr_data_t data) { lfsr_data_t data) {
lfs_ssize_t d = 0; lfs_ssize_t d = 0;
lfs_ssize_t d_ = lfsr_data_readle32(lfs, data, d, &fcksum->cksum); lfs_ssize_t d_ = lfsr_data_readle32(lfs, data, d, &ecksum->cksum);
if (d_ < 0) { if (d_ < 0) {
return d_; return d_;
} }
d += d_; d += d_;
d_ = lfsr_data_readleb128(lfs, data, d, &fcksum->size); d_ = lfsr_data_readleb128(lfs, data, d, &ecksum->size);
if (d_ < 0) { if (d_ < 0) {
return d_; return d_;
} }
@@ -1770,13 +1770,13 @@ static int lfsr_fs_fixgrm(lfs_t *lfs);
// helper functions // helper functions
static bool lfsr_rbyd_isfetched(const lfsr_rbyd_t *rbyd) { static bool lfsr_rbyd_isfetched(const lfsr_rbyd_t *rbyd) {
return !(rbyd->off == 0 && rbyd->trunk > 0); return !(rbyd->eoff == 0 && rbyd->trunk > 0);
} }
// allocate an rbyd block // allocate an rbyd block
static int lfsr_rbyd_alloc(lfs_t *lfs, lfsr_rbyd_t *rbyd) { static int lfsr_rbyd_alloc(lfs_t *lfs, lfsr_rbyd_t *rbyd) {
*rbyd = (lfsr_rbyd_t){.weight=0, .trunk=0, .off=0, .cksum=0}; *rbyd = (lfsr_rbyd_t){.weight=0, .trunk=0, .eoff=0, .cksum=0};
int err = lfs_alloc(lfs, &rbyd->block); int err = lfs_alloc(lfs, &rbyd->block);
if (err) { if (err) {
return err; return err;
@@ -1801,7 +1801,7 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
} }
rbyd->block = block; rbyd->block = block;
rbyd->off = 0; rbyd->eoff = 0;
rbyd->trunk = 0; rbyd->trunk = 0;
// temporary state until we validate a cksum // temporary state until we validate a cksum
@@ -1812,12 +1812,12 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
lfs_size_t weight_ = 0; lfs_size_t weight_ = 0;
// assume unerased until proven otherwise // assume unerased until proven otherwise
lfsr_fcksum_t fcksum; lfsr_ecksum_t ecksum;
bool hasfcksum = false; bool hasecksum = false;
bool maybeerased = false; bool maybeerased = false;
// scan tags, checking valid bits, cksums, etc // scan tags, checking valid bits, cksums, etc
while (off < lfs->cfg->block_size && (!trunk || rbyd->off <= trunk)) { while (off < lfs->cfg->block_size && (!trunk || rbyd->eoff <= trunk)) {
lfsr_tag_t tag; lfsr_tag_t tag;
lfs_size_t weight__; lfs_size_t weight__;
lfs_size_t size; lfs_size_t size;
@@ -1850,11 +1850,11 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
return err; return err;
} }
// found an fcksum? save for later // found an ecksum? save for later
if (tag == LFSR_TAG_FCKSUM) { if (tag == LFSR_TAG_ECKSUM) {
uint8_t fcksum_buf[LFSR_FCKSUM_DSIZE]; uint8_t ecksum_buf[LFSR_ECKSUM_DSIZE];
err = lfsr_bd_read(lfs, block, off, lfs->cfg->block_size, err = lfsr_bd_read(lfs, block, off, lfs->cfg->block_size,
fcksum_buf, lfs_min32(size, LFSR_FCKSUM_DSIZE)); ecksum_buf, lfs_min32(size, LFSR_ECKSUM_DSIZE));
if (err) { if (err) {
if (err == LFS_ERR_CORRUPT) { if (err == LFS_ERR_CORRUPT) {
break; break;
@@ -1862,15 +1862,15 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
return err; return err;
} }
lfs_ssize_t fcksum_dsize = lfsr_fcksum_fromdisk(lfs, &fcksum, lfs_ssize_t ecksum_dsize = lfsr_ecksum_fromdisk(lfs, &ecksum,
LFSR_DATA_BUF(fcksum_buf, LFSR_DATA_BUF(ecksum_buf,
lfs_min32(size, LFSR_FCKSUM_DSIZE))); lfs_min32(size, LFSR_ECKSUM_DSIZE)));
if (fcksum_dsize < 0 && fcksum_dsize != LFS_ERR_CORRUPT) { if (ecksum_dsize < 0 && ecksum_dsize != LFS_ERR_CORRUPT) {
return fcksum_dsize; return ecksum_dsize;
} }
// ignore malformed fcksums // ignore malformed ecksums
hasfcksum = (fcksum_dsize != LFS_ERR_CORRUPT); hasecksum = (ecksum_dsize != LFS_ERR_CORRUPT);
} }
// is an end-of-commit cksum // is an end-of-commit cksum
@@ -1897,12 +1897,12 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// random and convenient // random and convenient
lfs->seed = lfs_crc32c(lfs->seed, &cksum, sizeof(uint32_t)); lfs->seed = lfs_crc32c(lfs->seed, &cksum, sizeof(uint32_t));
// fcksum appears valid so far // ecksum appears valid so far
maybeerased = hasfcksum; maybeerased = hasecksum;
hasfcksum = false; hasecksum = false;
// save what we've found so far // save what we've found so far
rbyd->off = off + size; rbyd->eoff = off + size;
rbyd->cksum = cksum; rbyd->cksum = cksum;
rbyd->trunk = trunk_; rbyd->trunk = trunk_;
rbyd->weight = weight; rbyd->weight = weight;
@@ -1948,23 +1948,23 @@ static int lfsr_rbyd_fetch(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// did we end on a valid commit? we may have an erased block // did we end on a valid commit? we may have an erased block
bool erased = false; bool erased = false;
if (maybeerased && rbyd->off % lfs->cfg->prog_size == 0) { if (maybeerased && rbyd->eoff % lfs->cfg->prog_size == 0) {
// check for an fcksum matching the next prog's erased state, if // check for an ecksum matching the next prog's erased state, if
// this failed most likely a previous prog was interrupted, we // this failed most likely a previous prog was interrupted, we
// need a new erase // need a new erase
uint32_t fcksum_ = 0; uint32_t ecksum_ = 0;
int err = lfsr_bd_cksum(lfs, rbyd->block, rbyd->off, 0, fcksum.size, int err = lfsr_bd_cksum(lfs, rbyd->block, rbyd->eoff, 0, ecksum.size,
&fcksum_); &ecksum_);
if (err && err != LFS_ERR_CORRUPT) { if (err && err != LFS_ERR_CORRUPT) {
return err; return err;
} }
// found beginning of erased part? // found beginning of erased part?
erased = (fcksum_ == fcksum.cksum); erased = (ecksum_ == ecksum.cksum);
} }
if (!erased) { if (!erased) {
rbyd->off = -1; rbyd->eoff = -1;
} }
return 0; return 0;
@@ -2097,25 +2097,25 @@ static lfs_ssize_t lfsr_rbyd_get(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
// this is optional, if not called revision count defaults to 0 (for btrees) // this is optional, if not called revision count defaults to 0 (for btrees)
static int lfsr_rbyd_appendrev(lfs_t *lfs, lfsr_rbyd_t *rbyd, uint32_t rev) { static int lfsr_rbyd_appendrev(lfs_t *lfs, lfsr_rbyd_t *rbyd, uint32_t rev) {
// should only be called before any tags are written // should only be called before any tags are written
LFS_ASSERT(rbyd->off == 0); LFS_ASSERT(rbyd->eoff == 0);
// revision count stored as le32, we don't use a leb128 encoding as we // revision count stored as le32, we don't use a leb128 encoding as we
// intentionally allow the revision count to overflow // intentionally allow the revision count to overflow
uint8_t rev_buf[sizeof(uint32_t)]; uint8_t rev_buf[sizeof(uint32_t)];
lfs_tole32_(rev, &rev_buf); lfs_tole32_(rev, &rev_buf);
int err = lfsr_bd_prog(lfs, rbyd->block, rbyd->off, int err = lfsr_bd_prog(lfs, rbyd->block, rbyd->eoff,
&rev_buf, sizeof(uint32_t), &rbyd->cksum); &rev_buf, sizeof(uint32_t), &rbyd->cksum);
if (err) { if (err) {
goto failed; goto failed;
} }
rbyd->off += sizeof(uint32_t); rbyd->eoff += sizeof(uint32_t);
return 0; return 0;
failed: failed:
// if we fail mark the rbyd as unerased and release the pcache // if we fail mark the rbyd as unerased and release the pcache
lfs_cache_zero(lfs, &lfs->pcache); lfs_cache_zero(lfs, &lfs->pcache);
rbyd->off = -1; rbyd->eoff = -1;
return err; return err;
} }
@@ -2131,15 +2131,15 @@ static int lfsr_rbyd_p_flush(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// change to a relative jump at the last minute // change to a relative jump at the last minute
lfsr_tag_t alt = p_alts[3-1-i]; lfsr_tag_t alt = p_alts[3-1-i];
lfs_size_t weight = p_weights[3-1-i]; lfs_size_t weight = p_weights[3-1-i];
lfs_off_t jump = rbyd->off - p_jumps[3-1-i]; lfs_off_t jump = rbyd->eoff - p_jumps[3-1-i];
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->off, lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
alt, weight, jump, alt, weight, jump,
&rbyd->cksum); &rbyd->cksum);
if (d < 0) { if (d < 0) {
return d; return d;
} }
rbyd->off += d; rbyd->eoff += d;
} }
} }
@@ -2238,7 +2238,7 @@ static int lfsr_rbyd_append(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// we can't do anything if we're not erased // we can't do anything if we're not erased
int err; int err;
if (rbyd->off >= lfs->cfg->block_size) { if (rbyd->eoff >= lfs->cfg->block_size) {
err = LFS_ERR_RANGE; err = LFS_ERR_RANGE;
goto failed; goto failed;
} }
@@ -2250,7 +2250,7 @@ static int lfsr_rbyd_append(lfs_t *lfs, lfsr_rbyd_t *rbyd,
} }
// make sure every rbyd starts with a revision count // make sure every rbyd starts with a revision count
if (rbyd->off == 0) { if (rbyd->eoff == 0) {
err = lfsr_rbyd_appendrev(lfs, rbyd, 0); err = lfsr_rbyd_appendrev(lfs, rbyd, 0);
if (err) { if (err) {
goto failed; goto failed;
@@ -2343,7 +2343,7 @@ static int lfsr_rbyd_append(lfs_t *lfs, lfsr_rbyd_t *rbyd,
rbyd->weight += delta; rbyd->weight += delta;
// assume we'll update our trunk // assume we'll update our trunk
rbyd->trunk = rbyd->off; rbyd->trunk = rbyd->eoff;
// no trunk yet? // no trunk yet?
if (!branch) { if (!branch) {
@@ -2702,7 +2702,7 @@ leaf:;
// //
// note we always need a non-alt to terminate the trunk, otherwise we // note we always need a non-alt to terminate the trunk, otherwise we
// can't find trunks during fetch // can't find trunks during fetch
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->off, lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
// rm => null, otherwise strip off control bits // rm => null, otherwise strip off control bits
(lfsr_tag_isrm(tag) ? LFSR_TAG_NULL : lfsr_tag_key(tag)), (lfsr_tag_isrm(tag) ? LFSR_TAG_NULL : lfsr_tag_key(tag)),
upper_rid - lower_rid - 1 + delta, upper_rid - lower_rid - 1 + delta,
@@ -2712,22 +2712,22 @@ leaf:;
err = d; err = d;
goto failed; goto failed;
} }
rbyd->off += d; rbyd->eoff += d;
// don't forget the data! // don't forget the data!
err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->off, data, err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->eoff, data,
&rbyd->cksum); &rbyd->cksum);
if (err) { if (err) {
goto failed; goto failed;
} }
rbyd->off += lfsr_data_size(data); rbyd->eoff += lfsr_data_size(data);
return 0; return 0;
failed:; failed:;
// if we fail mark the rbyd as unerased and release the pcache // if we fail mark the rbyd as unerased and release the pcache
lfs_cache_zero(lfs, &lfs->pcache); lfs_cache_zero(lfs, &lfs->pcache);
rbyd->off = -1; rbyd->eoff = -1;
return err; return err;
} }
@@ -2858,13 +2858,13 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// we can't do anything if we're not erased // we can't do anything if we're not erased
int err; int err;
if (rbyd->off >= lfs->cfg->block_size) { if (rbyd->eoff >= lfs->cfg->block_size) {
err = LFS_ERR_RANGE; err = LFS_ERR_RANGE;
goto failed; goto failed;
} }
// make sure every rbyd starts with a revision count // make sure every rbyd starts with a revision count
if (rbyd->off == 0) { if (rbyd->eoff == 0) {
err = lfsr_rbyd_appendrev(lfs, rbyd, 0); err = lfsr_rbyd_appendrev(lfs, rbyd, 0);
if (err) { if (err) {
goto failed; goto failed;
@@ -2876,7 +2876,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
lfs_size_t layer_weight = 0; lfs_size_t layer_weight = 0;
// first copy over raw tags, note this doesn't create a tree // first copy over raw tags, note this doesn't create a tree
lfs_off_t layer_start = rbyd->off; lfs_off_t layer_start = rbyd->eoff;
lfs_ssize_t rid = start_rid; lfs_ssize_t rid = start_rid;
lfsr_tag_t tag = 0; lfsr_tag_t tag = 0;
while (true) { while (true) {
@@ -2899,28 +2899,28 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
} }
// write the tag // write the tag
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->off, lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
tag, weight, lfsr_data_size(data), tag, weight, lfsr_data_size(data),
&rbyd->cksum); &rbyd->cksum);
if (d < 0) { if (d < 0) {
err = d; err = d;
goto failed; goto failed;
} }
rbyd->off += d; rbyd->eoff += d;
// and the data // and the data
err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->off, data, err = lfsr_bd_progdata(lfs, rbyd->block, rbyd->eoff, data,
&rbyd->cksum); &rbyd->cksum);
if (err) { if (err) {
goto failed; goto failed;
} }
rbyd->off += lfsr_data_size(data); rbyd->eoff += lfsr_data_size(data);
// keep track of the layer weight/trunks // keep track of the layer weight/trunks
layer_trunks += 1; layer_trunks += 1;
layer_weight += weight; layer_weight += weight;
} }
lfs_off_t layer_end = rbyd->off; lfs_off_t layer_end = rbyd->eoff;
// connect every other trunk together, building layers of a perfectly // connect every other trunk together, building layers of a perfectly
// balanced binary tree upwards until we have a single trunk // balanced binary tree upwards until we have a single trunk
@@ -2930,7 +2930,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
layer_weight = 0; layer_weight = 0;
lfs_off_t off = layer_start; lfs_off_t off = layer_start;
layer_start = rbyd->off; layer_start = rbyd->eoff;
while (off < layer_end) { while (off < layer_end) {
// connect two trunks together with a new binary trunk // connect two trunks together with a new binary trunk
for (int i = 0; i < 2 && off < layer_end; i++) { for (int i = 0; i < 2 && off < layer_end; i++) {
@@ -2972,32 +2972,32 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
} }
// connect with an altle // connect with an altle
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->off, lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
LFSR_TAG_ALTLE(false, lfsr_tag_key(trunk_tag)), LFSR_TAG_ALTLE(false, lfsr_tag_key(trunk_tag)),
trunk_weight, trunk_weight,
rbyd->off - trunk_off, rbyd->eoff - trunk_off,
&rbyd->cksum); &rbyd->cksum);
if (d < 0) { if (d < 0) {
err = d; err = d;
goto failed; goto failed;
} }
rbyd->off += d; rbyd->eoff += d;
} }
// terminate with a null tag // terminate with a null tag
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->off, lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd->block, rbyd->eoff,
LFSR_TAG_NULL, 0, 0, LFSR_TAG_NULL, 0, 0,
&rbyd->cksum); &rbyd->cksum);
if (d < 0) { if (d < 0) {
err = d; err = d;
goto failed; goto failed;
} }
rbyd->off += d; rbyd->eoff += d;
// keep track of the number of trunks // keep track of the number of trunks
layer_trunks += 1; layer_trunks += 1;
} }
layer_end = rbyd->off; layer_end = rbyd->eoff;
} }
// done! just need to update our trunk/weight, note we could have // done! just need to update our trunk/weight, note we could have
@@ -3013,7 +3013,7 @@ static int lfsr_rbyd_compact(lfs_t *lfs, lfsr_rbyd_t *rbyd,
failed:; failed:;
// if we fail mark the rbyd as unerased and release the pcache // if we fail mark the rbyd as unerased and release the pcache
lfs_cache_zero(lfs, &lfs->pcache); lfs_cache_zero(lfs, &lfs->pcache);
rbyd->off = -1; rbyd->eoff = -1;
return err; return err;
#else #else
@@ -3056,7 +3056,7 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// we can't do anything if we're not erased // we can't do anything if we're not erased
int err; int err;
if (rbyd->off >= lfs->cfg->block_size) { if (rbyd->eoff >= lfs->cfg->block_size) {
err = LFS_ERR_RANGE; err = LFS_ERR_RANGE;
goto failed; goto failed;
} }
@@ -3066,7 +3066,7 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
lfsr_rbyd_t rbyd_ = *rbyd; lfsr_rbyd_t rbyd_ = *rbyd;
// make sure every rbyd starts with its revision count // make sure every rbyd starts with its revision count
if (rbyd_.off == 0) { if (rbyd_.eoff == 0) {
err = lfsr_rbyd_appendrev(lfs, &rbyd_, 0); err = lfsr_rbyd_appendrev(lfs, &rbyd_, 0);
if (err) { if (err) {
goto failed; goto failed;
@@ -3084,12 +3084,12 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// //
// this gets a bit complicated as we have two types of cksums: // this gets a bit complicated as we have two types of cksums:
// //
// - 9-word cksum with fcksum to check following prog (middle of block) // - 9-word cksum with ecksum to check following prog (middle of block)
// - fcksum tag type => 2 byte le16 // - ecksum tag type => 2 byte le16
// - fcksum tag rid => 1 byte leb128 // - ecksum tag rid => 1 byte leb128
// - fcksum tag size => 1 byte leb128 (worst case) // - ecksum tag size => 1 byte leb128 (worst case)
// - fcksum crc32c => 4 byte le32 // - ecksum crc32c => 4 byte le32
// - fcksum size => 5 byte leb128 (worst case) // - ecksum size => 5 byte leb128 (worst case)
// - cksum tag type => 2 byte le16 // - cksum tag type => 2 byte le16
// - cksum tag rid => 1 byte leb128 // - cksum tag rid => 1 byte leb128
// - cksum tag size => 5 byte leb128 (worst case) // - cksum tag size => 5 byte leb128 (worst case)
@@ -3104,10 +3104,10 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// => 12 bytes total // => 12 bytes total
// //
lfs_off_t aligned = lfs_alignup( lfs_off_t aligned = lfs_alignup(
rbyd_.off + 2+1+1+4+5 + 2+1+5+4, rbyd_.eoff + 2+1+1+4+5 + 2+1+5+4,
lfs->cfg->prog_size); lfs->cfg->prog_size);
// space for fcksum? // space for ecksum?
uint8_t perturb = 0; uint8_t perturb = 0;
if (aligned < lfs->cfg->block_size) { if (aligned < lfs->cfg->block_size) {
// read the leading byte in case we need to change the expected // read the leading byte in case we need to change the expected
@@ -3115,40 +3115,40 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
int err = lfsr_bd_read(lfs, rbyd_.block, aligned, lfs->cfg->prog_size, int err = lfsr_bd_read(lfs, rbyd_.block, aligned, lfs->cfg->prog_size,
&perturb, 1); &perturb, 1);
if (err && err != LFS_ERR_CORRUPT) { if (err && err != LFS_ERR_CORRUPT) {
rbyd->off = -1; rbyd->eoff = -1;
return err; return err;
} }
// find the expected fcksum, don't bother avoiding a reread of the // find the expected ecksum, don't bother avoiding a reread of the
// perturb byte, as it should still be in our cache // perturb byte, as it should still be in our cache
lfsr_fcksum_t fcksum = {.cksum=0, .size=lfs->cfg->prog_size}; lfsr_ecksum_t ecksum = {.cksum=0, .size=lfs->cfg->prog_size};
err = lfsr_bd_cksum(lfs, rbyd_.block, aligned, lfs->cfg->prog_size, err = lfsr_bd_cksum(lfs, rbyd_.block, aligned, lfs->cfg->prog_size,
lfs->cfg->prog_size, lfs->cfg->prog_size,
&fcksum.cksum); &ecksum.cksum);
if (err && err != LFS_ERR_CORRUPT) { if (err && err != LFS_ERR_CORRUPT) {
goto failed; goto failed;
} }
uint8_t fcksum_buf[LFSR_FCKSUM_DSIZE]; uint8_t ecksum_buf[LFSR_ECKSUM_DSIZE];
lfs_size_t fcksum_dsize = lfsr_fcksum_todisk(lfs, &fcksum, fcksum_buf); lfs_size_t ecksum_dsize = lfsr_ecksum_todisk(lfs, &ecksum, ecksum_buf);
lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd_.block, rbyd_.off, lfs_ssize_t d = lfsr_bd_progtag(lfs, rbyd_.block, rbyd_.eoff,
LFSR_TAG_FCKSUM, 0, fcksum_dsize, LFSR_TAG_ECKSUM, 0, ecksum_dsize,
&rbyd_.cksum); &rbyd_.cksum);
if (d < 0) { if (d < 0) {
err = d; err = d;
goto failed; goto failed;
} }
rbyd_.off += d; rbyd_.eoff += d;
err = lfsr_bd_prog(lfs, rbyd_.block, rbyd_.off, err = lfsr_bd_prog(lfs, rbyd_.block, rbyd_.eoff,
fcksum_buf, fcksum_dsize, &rbyd_.cksum); ecksum_buf, ecksum_dsize, &rbyd_.cksum);
if (err) { if (err) {
goto failed; goto failed;
} }
rbyd_.off += fcksum_dsize; rbyd_.eoff += ecksum_dsize;
// at least space for a cksum? // at least space for a cksum?
} else if (rbyd_.off + 2+1+5+4 <= lfs->cfg->block_size) { } else if (rbyd_.eoff + 2+1+5+4 <= lfs->cfg->block_size) {
// note this implicitly marks the rbyd as unerased // note this implicitly marks the rbyd as unerased
aligned = lfs->cfg->block_size; aligned = lfs->cfg->block_size;
@@ -3168,7 +3168,7 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
cksum_buf[1] = 0; cksum_buf[1] = 0;
cksum_buf[2] = 0; cksum_buf[2] = 0;
lfs_off_t padding = aligned - (rbyd_.off + 2+1+5); lfs_off_t padding = aligned - (rbyd_.eoff + 2+1+5);
cksum_buf[3] = 0x80 | (0x7f & (padding >> 0)); cksum_buf[3] = 0x80 | (0x7f & (padding >> 0));
cksum_buf[4] = 0x80 | (0x7f & (padding >> 7)); cksum_buf[4] = 0x80 | (0x7f & (padding >> 7));
cksum_buf[5] = 0x80 | (0x7f & (padding >> 14)); cksum_buf[5] = 0x80 | (0x7f & (padding >> 14));
@@ -3186,11 +3186,11 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
} }
lfs_tole32_(rbyd_.cksum, &cksum_buf[2+1+5]); lfs_tole32_(rbyd_.cksum, &cksum_buf[2+1+5]);
err = lfsr_bd_prog(lfs, rbyd_.block, rbyd_.off, cksum_buf, 2+1+5+4, NULL); err = lfsr_bd_prog(lfs, rbyd_.block, rbyd_.eoff, cksum_buf, 2+1+5+4, NULL);
if (err) { if (err) {
goto failed; goto failed;
} }
rbyd_.off += 2+1+5+4; rbyd_.eoff += 2+1+5+4;
// flush our caches, finalizing the commit on-disk // flush our caches, finalizing the commit on-disk
err = lfsr_bd_sync(lfs); err = lfsr_bd_sync(lfs);
@@ -3200,8 +3200,8 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
// succesful commit, check checksum to make sure // succesful commit, check checksum to make sure
uint32_t cksum_ = rbyd->cksum; uint32_t cksum_ = rbyd->cksum;
err = lfsr_bd_cksum(lfs, rbyd_.block, rbyd->off, 0, err = lfsr_bd_cksum(lfs, rbyd_.block, rbyd->eoff, 0,
rbyd_.off-4 - rbyd->off, rbyd_.eoff-4 - rbyd->eoff,
&cksum_); &cksum_);
if (err) { if (err) {
goto failed; goto failed;
@@ -3217,14 +3217,14 @@ static int lfsr_rbyd_commit(lfs_t *lfs, lfsr_rbyd_t *rbyd,
} }
// ok, everything is good, save what we've committed // ok, everything is good, save what we've committed
rbyd_.off = aligned; rbyd_.eoff = aligned;
*rbyd = rbyd_; *rbyd = rbyd_;
return 0; return 0;
failed:; failed:;
// if we fail mark the rbyd as unerased and release the pcache // if we fail mark the rbyd as unerased and release the pcache
lfs_cache_zero(lfs, &lfs->pcache); lfs_cache_zero(lfs, &lfs->pcache);
rbyd->off = -1; rbyd->eoff = -1;
return err; return err;
} }
@@ -3557,7 +3557,7 @@ static lfs_ssize_t lfsr_branch_fromdisk(lfs_t *lfs, lfsr_rbyd_t *branch,
lfsr_data_t data) { lfsr_data_t data) {
// setting off to 0 here will trigger asserts if we try to append // setting off to 0 here will trigger asserts if we try to append
// without fetching first // without fetching first
branch->off = 0; branch->eoff = 0;
lfs_ssize_t d = 0; lfs_ssize_t d = 0;
lfs_ssize_t d_ = lfsr_data_readle32(lfs, data, d, &branch->cksum); lfs_ssize_t d_ = lfsr_data_readle32(lfs, data, d, &branch->cksum);
@@ -4017,7 +4017,7 @@ static int lfsr_btree_commit(lfs_t *lfs,
// TODO we should have a benchmark for how removes affect tree size // TODO we should have a benchmark for how removes affect tree size
// is our compacted size too small? try to merge with one of // is our compacted size too small? try to merge with one of
// our siblings // our siblings
if (rbyd_.off < lfs->cfg->block_size/4) { if (rbyd_.eoff < lfs->cfg->block_size/4) {
goto merge; goto merge;
merge_abort:; merge_abort:;
} }
@@ -4326,7 +4326,7 @@ static int lfsr_btree_commit(lfs_t *lfs,
// if we exceed our compaction threshold our merge has failed, // if we exceed our compaction threshold our merge has failed,
// clean up ids and return to merge_abort // clean up ids and return to merge_abort
if (rbyd_.off > lfs->cfg->block_size/2) { if (rbyd_.eoff > lfs->cfg->block_size/2) {
err = lfsr_rbyd_append(lfs, &rbyd_, err = lfsr_rbyd_append(lfs, &rbyd_,
sdelta+(rbyd_.weight-rweight_)-1, sdelta+(rbyd_.weight-rweight_)-1,
LFSR_TAG_UNR, -(rbyd_.weight-rweight_), LFSR_TAG_UNR, -(rbyd_.weight-rweight_),
@@ -5364,7 +5364,7 @@ static int lfsr_mdir_compact_(lfs_t *lfs, lfsr_mdir_t *mdir_,
lfs_swap32(&mdir_->u.r.rbyd.block, &mdir_->u.r.redund_block); lfs_swap32(&mdir_->u.r.rbyd.block, &mdir_->u.r.redund_block);
mdir_->u.r.rbyd.weight = 0; mdir_->u.r.rbyd.weight = 0;
mdir_->u.r.rbyd.trunk = 0; mdir_->u.r.rbyd.trunk = 0;
mdir_->u.r.rbyd.off = 0; mdir_->u.r.rbyd.eoff = 0;
mdir_->u.r.rbyd.cksum = 0; mdir_->u.r.rbyd.cksum = 0;
// erase, preparing for compact // erase, preparing for compact
@@ -5465,7 +5465,7 @@ static int lfsr_mdir_commit_(lfs_t *lfs, lfsr_mdir_t *mdir,
// TODO handle this differently? // TODO handle this differently?
// TODO let the lower rbyd layer handle this somehow? // TODO let the lower rbyd layer handle this somehow?
// mark mdir as unerased in case we fail // mark mdir as unerased in case we fail
mdir->u.r.rbyd.off = lfs->cfg->block_size; mdir->u.r.rbyd.eoff = lfs->cfg->block_size;
int err = lfsr_rbyd_appendall(lfs, &mdir_.u.r.rbyd, start_rid, end_rid, int err = lfsr_rbyd_appendall(lfs, &mdir_.u.r.rbyd, start_rid, end_rid,
attrs, attr_count); attrs, attr_count);
if (err && err != LFS_ERR_RANGE) { if (err && err != LFS_ERR_RANGE) {
@@ -7004,7 +7004,7 @@ static int lfsr_formatinited(lfs_t *lfs) {
for (uint32_t i = 0; i < 2; i++) { for (uint32_t i = 0; i < 2; i++) {
// write superblock to both rbyds in the root mroot to hopefully // write superblock to both rbyds in the root mroot to hopefully
// avoid mounting an older filesystem on disk // avoid mounting an older filesystem on disk
lfsr_rbyd_t rbyd = {.block=i, .off=0, .trunk=0}; lfsr_rbyd_t rbyd = {.block=i, .eoff=0, .trunk=0};
int err = lfsr_bd_erase(lfs, rbyd.block); int err = lfsr_bd_erase(lfs, rbyd.block);
if (err) { if (err) {
+4 -4
View File
@@ -348,11 +348,11 @@ typedef struct lfs_cache {
typedef struct lfsr_rbyd { typedef struct lfsr_rbyd {
// note this lines up with weight in lfsr_btree_t // note this lines up with weight in lfsr_btree_t
lfs_size_t weight; lfs_size_t weight;
// off=0, trunk=0 => not yet committed // eoff=0, trunk=0 => not yet committed
// off=0, trunk>0 => not yet fetched // eoff=0, trunk>0 => not yet fetched
// off>=block_size => rbyd not erased/needs compaction // eoff>=block_size => rbyd not erased/needs compaction
lfs_off_t trunk; lfs_off_t trunk;
lfs_off_t off; lfs_off_t eoff;
uint32_t cksum; uint32_t cksum;
// note this lines up with arrays of redundant blocks in lfsr_mdir_t // note this lines up with arrays of redundant blocks in lfsr_mdir_t
lfs_block_t block; lfs_block_t block;
+3 -3
View File
@@ -30,7 +30,7 @@ TAG_UATTR = 0x0400
TAG_SATTR = 0x0500 TAG_SATTR = 0x0500
TAG_ALT = 0x4000 TAG_ALT = 0x4000
TAG_CKSUM = 0x2000 TAG_CKSUM = 0x2000
TAG_FCKSUM = 0x2100 TAG_ECKSUM = 0x2100
@@ -172,8 +172,8 @@ def tagrepr(tag, w, size, off=None):
1 if tag & 0x1 else 0, 1 if tag & 0x1 else 0,
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag == TAG_FCKSUM: elif tag == TAG_ECKSUM:
return 'fcksum%s %d' % ( return 'ecksum%s %d' % (
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag & 0x4000: elif tag & 0x4000:
+3 -3
View File
@@ -31,7 +31,7 @@ TAG_UATTR = 0x0400
TAG_SATTR = 0x0500 TAG_SATTR = 0x0500
TAG_ALT = 0x4000 TAG_ALT = 0x4000
TAG_CKSUM = 0x2000 TAG_CKSUM = 0x2000
TAG_FCKSUM = 0x2100 TAG_ECKSUM = 0x2100
# parse some rbyd addr encodings # parse some rbyd addr encodings
@@ -181,8 +181,8 @@ def tagrepr(tag, w, size, off=None):
1 if tag & 0x1 else 0, 1 if tag & 0x1 else 0,
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag == TAG_FCKSUM: elif tag == TAG_ECKSUM:
return 'fcksum%s %d' % ( return 'ecksum%s %d' % (
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag & 0x4000: elif tag & 0x4000:
+3 -3
View File
@@ -30,7 +30,7 @@ TAG_UATTR = 0x0400
TAG_SATTR = 0x0500 TAG_SATTR = 0x0500
TAG_ALT = 0x4000 TAG_ALT = 0x4000
TAG_CKSUM = 0x2000 TAG_CKSUM = 0x2000
TAG_FCKSUM = 0x2100 TAG_ECKSUM = 0x2100
# parse some rbyd addr encodings # parse some rbyd addr encodings
@@ -180,8 +180,8 @@ def tagrepr(tag, w, size, off=None):
1 if tag & 0x1 else 0, 1 if tag & 0x1 else 0,
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag == TAG_FCKSUM: elif tag == TAG_ECKSUM:
return 'fcksum%s %d' % ( return 'ecksum%s %d' % (
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag & 0x4000: elif tag & 0x4000:
+3 -3
View File
@@ -39,7 +39,7 @@ TAG_UATTR = 0x0400
TAG_SATTR = 0x0500 TAG_SATTR = 0x0500
TAG_ALT = 0x4000 TAG_ALT = 0x4000
TAG_CKSUM = 0x2000 TAG_CKSUM = 0x2000
TAG_FCKSUM = 0x2100 TAG_ECKSUM = 0x2100
@@ -174,8 +174,8 @@ def tagrepr(tag, w, size, off=None):
1 if tag & 0x1 else 0, 1 if tag & 0x1 else 0,
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag == TAG_FCKSUM: elif tag == TAG_ECKSUM:
return 'fcksum%s %d' % ( return 'ecksum%s %d' % (
' 0x%x' % w if w > 0 else '', ' 0x%x' % w if w > 0 else '',
size) size)
elif tag & 0x4000: elif tag & 0x4000:
+86 -86
View File
@@ -66,7 +66,7 @@ code = '''
for (lfs_size_t i = 0; i < N; i++) { for (lfs_size_t i = 0; i < N; i++) {
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(i), 0, &alphas[i % 26], 1))) => 0; LFSR_ATTR(-1, UATTR(i), 0, &alphas[i % 26], 1))) => 0;
@@ -164,7 +164,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -238,7 +238,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdirs were unininlined and split // assert mdirs were unininlined and split
@@ -312,7 +312,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -330,7 +330,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
// assert mdir was split correctly // assert mdir was split correctly
@@ -412,8 +412,8 @@ code = '''
for (lfs_size_t i = 0; i < N; i++) { for (lfs_size_t i = 0; i < N; i++) {
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
@@ -508,8 +508,8 @@ code = '''
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
// add to rbyd, potentially splitting the mdir // add to rbyd, potentially splitting the mdir
@@ -609,7 +609,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -679,7 +679,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -693,7 +693,7 @@ code = '''
assert(mdir.u.m.weight == 1); assert(mdir.u.m.weight == 1);
// force mdir to compact while we're removing // force mdir to compact while we're removing
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(0, UNR, -1, NULL, 0))) => 0; LFSR_ATTR(0, UNR, -1, NULL, 0))) => 0;
@@ -752,7 +752,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
// remove the entry as we compact, forcing the mdir to be dropped // remove the entry as we compact, forcing the mdir to be dropped
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
@@ -812,7 +812,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
// remove the left entry as we compact, forcing the left // remove the left entry as we compact, forcing the left
// mdir to be dropped // mdir to be dropped
@@ -880,7 +880,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
// remove the right entry as we compact, forcing the right mdir // remove the right entry as we compact, forcing the right mdir
// to be dropped // to be dropped
@@ -948,7 +948,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
// remove both entries as we compact, forcing both mdirs to be dropped // remove both entries as we compact, forcing both mdirs to be dropped
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
@@ -999,7 +999,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -1017,7 +1017,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
// remove the left entry as we compact, forcing the left // remove the left entry as we compact, forcing the left
// mdir to be dropped // mdir to be dropped
@@ -1094,7 +1094,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -1112,7 +1112,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
// remove the right entry as we compact, forcing the right // remove the right entry as we compact, forcing the right
// mdir to be dropped // mdir to be dropped
@@ -1189,7 +1189,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -1207,7 +1207,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
// remove both entries as we compact, forcing both mdirs to be dropped // remove both entries as we compact, forcing both mdirs to be dropped
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
@@ -1289,8 +1289,8 @@ code = '''
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
@@ -1410,8 +1410,8 @@ code = '''
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
@@ -1471,8 +1471,8 @@ code = '''
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
// create // create
@@ -1594,7 +1594,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mtree has one mdir // assert mtree has one mdir
@@ -1609,9 +1609,9 @@ code = '''
lfsr_mdir_t old_mdir = mdir; lfsr_mdir_t old_mdir = mdir;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[2 % 26], SIZE); memset(buffer, alphas[2 % 26], SIZE);
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
@@ -1689,7 +1689,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdirs were unininlined and split // assert mdirs were unininlined and split
@@ -1704,9 +1704,9 @@ code = '''
lfsr_mdir_t old_mdir = mdir; lfsr_mdir_t old_mdir = mdir;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[2 % 26], SIZE); memset(buffer, alphas[2 % 26], SIZE);
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
@@ -1784,7 +1784,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdirs were unininlined and split // assert mdirs were unininlined and split
@@ -1799,9 +1799,9 @@ code = '''
lfsr_mdir_t old_mdir = mdir; lfsr_mdir_t old_mdir = mdir;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[2 % 26], SIZE); memset(buffer, alphas[2 % 26], SIZE);
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
@@ -1877,9 +1877,9 @@ code = '''
// force mroot to compact twice, this should extend the mroot // force mroot to compact twice, this should extend the mroot
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
@@ -1938,10 +1938,10 @@ code = '''
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
} }
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
@@ -1996,9 +1996,9 @@ code = '''
// force mroot to compact twice, this should extend the mroot // force mroot to compact twice, this should extend the mroot
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert we relocated // assert we relocated
@@ -2007,9 +2007,9 @@ code = '''
// force mroot to compact twice again, this should relocate the mroot // force mroot to compact twice again, this should relocate the mroot
old_mroot = lfs.mroot; old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
@@ -2067,7 +2067,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mtree has one mdir // assert mtree has one mdir
@@ -2077,7 +2077,7 @@ code = '''
// setup mroot to need to compact, this should trigger a relocation when // setup mroot to need to compact, this should trigger a relocation when
// we relocate the mdir below // we relocate the mdir below
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
// force mdir to compact twice, this should relocate // force mdir to compact twice, this should relocate
@@ -2087,9 +2087,9 @@ code = '''
lfsr_mdir_t old_mdir = mdir; lfsr_mdir_t old_mdir = mdir;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[2 % 26], SIZE); memset(buffer, alphas[2 % 26], SIZE);
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
@@ -2173,7 +2173,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -2183,7 +2183,7 @@ code = '''
// setup mroot to need to compact, this should trigger a relocation when // setup mroot to need to compact, this should trigger a relocation when
// we relocate the mdir below // we relocate the mdir below
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
// now add another large entry to the mdir, forcing a split // now add another large entry to the mdir, forcing a split
@@ -2196,7 +2196,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
// assert mdir was split correctly // assert mdir was split correctly
@@ -2287,7 +2287,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -2297,7 +2297,7 @@ code = '''
// setup mroot to need to compact, this should trigger a relocation when // setup mroot to need to compact, this should trigger a relocation when
// we relocate the mdir below // we relocate the mdir below
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
// remove the entry, forcing the mdir to be dropped // remove the entry, forcing the mdir to be dropped
@@ -2361,7 +2361,7 @@ code = '''
// force mroot to compact once, so the second compact below will trigger // force mroot to compact once, so the second compact below will trigger
// a relocation // a relocation
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// prepare mroot with a large attr so the next entry can not fit // prepare mroot with a large attr so the next entry can not fit
@@ -2377,7 +2377,7 @@ code = '''
// force mroot to compact, this should trigger a relocation // force mroot to compact, this should trigger a relocation
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -2450,7 +2450,7 @@ code = '''
// force mroot to compact once, so the second compact below will trigger // force mroot to compact once, so the second compact below will trigger
// a relocation // a relocation
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
@@ -2465,7 +2465,7 @@ code = '''
// force mroot to compact, this should trigger a relocation // force mroot to compact, this should trigger a relocation
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdirs were unininlined and split // assert mdirs were unininlined and split
@@ -2559,8 +2559,8 @@ code = '''
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
// create // create
@@ -2853,7 +2853,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -2936,7 +2936,7 @@ code = '''
LFSR_ATTR(2, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(2, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdirs were unininlined and split // assert mdirs were unininlined and split
@@ -3001,7 +3001,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -3037,7 +3037,7 @@ code = '''
LFSR_ATTR(2, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(2, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
// assert mdir was split correctly // assert mdir was split correctly
@@ -3120,9 +3120,9 @@ code = '''
// force mroot to compact twice, this should extend the mroot // force mroot to compact twice, this should extend the mroot
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
@@ -3179,7 +3179,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -3212,9 +3212,9 @@ code = '''
// force mdir to compact twice, this should relocate // force mdir to compact twice, this should relocate
lfsr_mdir_t old_mdir = mdir; lfsr_mdir_t old_mdir = mdir;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[4 % 26], SIZE); memset(buffer, alphas[4 % 26], SIZE);
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(1, INLINED, 0, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, 0, buffer, SIZE))) => 0;
@@ -3278,7 +3278,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// we should now have 2 mdirs // we should now have 2 mdirs
@@ -3293,7 +3293,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
// we should now have 3 mdirs // we should now have 3 mdirs
@@ -3324,7 +3324,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
// we should now have 4 mdirs // we should now have 4 mdirs
@@ -3375,7 +3375,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// we should now have 2 mdirs // we should now have 2 mdirs
@@ -3390,7 +3390,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mdir to compact // force mdir to compact
mdir.u.r.rbyd.off = BLOCK_SIZE; mdir.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
// we should now have 3 mdirs // we should now have 3 mdirs
@@ -3572,7 +3572,7 @@ code = '''
LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(0, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdir was unininlined correctly // assert mdir was unininlined correctly
@@ -3707,7 +3707,7 @@ code = '''
LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0; LFSR_ATTR(1, INLINED, +1, buffer, SIZE))) => 0;
// force mroot to compact // force mroot to compact
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
// assert mdirs were unininlined and split // assert mdirs were unininlined and split
@@ -3843,9 +3843,9 @@ code = '''
// force mroot to compact twice, this should extend the mroot // force mroot to compact twice, this should extend the mroot
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
@@ -3960,8 +3960,8 @@ code = '''
for (lfs_size_t i = 0; i < N; i++) { for (lfs_size_t i = 0; i < N; i++) {
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
@@ -4116,8 +4116,8 @@ code = '''
// force a compaction? // force a compaction?
if (FORCE_COMPACTION) { if (FORCE_COMPACTION) {
mdir.u.r.rbyd.off = CFG->block_size; mdir.u.r.rbyd.eoff = CFG->block_size;
lfs.mroot.u.r.rbyd.off = CFG->block_size; lfs.mroot.u.r.rbyd.eoff = CFG->block_size;
} }
// add to rbyd, potentially splitting the mdir // add to rbyd, potentially splitting the mdir
@@ -4358,9 +4358,9 @@ code = '''
// force mroot to compact twice, this should extend the mroot // force mroot to compact twice, this should extend the mroot
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
@@ -4414,10 +4414,10 @@ code = '''
lfsr_mdir_t old_mroot = lfs.mroot; lfsr_mdir_t old_mroot = lfs.mroot;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0; lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
} }
lfs.mroot.u.r.rbyd.off = BLOCK_SIZE; lfs.mroot.u.r.rbyd.eoff = BLOCK_SIZE;
memset(buffer, alphas[1 % 26], SIZE); memset(buffer, alphas[1 % 26], SIZE);
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS( lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0; LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
+238 -238
View File
File diff suppressed because it is too large Load Diff