Heavily reworked lfsr_mdir_commit, split into more mid-level functions
Originally, the intention of this rework was to make it possible to
shrub the mtree, i.e. allow an mshrub, i.e. inline the root rbyd of the
mtree to be inlined in the mroot.
This would allow small mtrees, 2, 3, etc mdirs, to save a block that
would be needed for the mtree's root.
But as the mshrub was progressing, minor problems kept unfolding, and
ultimately I've decided to shelve the idea of mshrubs for now. They add
quite a bit of complexity for relatively little gain:
- bshrubs are just complicated to update. They require a call to
lfsr_mdir_commit to update the inlined-root, which is a bit of a
problem when your mshrub needs to be updated inside lfsr_mdir_commit,
and your system disallows recursion...
Recursion _can_ be avoided by separate bshrub commit variants that go
through either lfsr_mdir_commit or lfsr_mdir_commit_, but this
complicates things and requires some code duplication, weakening the
value of reusing the bshrub data-structure.
- It's not always possible to compact the mshrub's backing mroot when
we need to modify the mshrub.
If an mroot becomes full and needs to split, for example, we need to
allocate the new mdirs, update the (new) mshrub, and then commit
everything into the mroot when we compact. But the "update the (new)
mshrub" step can't be done until after we compact, because the mroot
is by definition full.
This _can_ also be worked around, by building an attr list containing
all of the mshrub changes, and committing the mshrub/mroot changes in
the same transaction, but this complicates things and increases the
stack cost for the current hot-path.
- Every shrub needs a configurable shrub size, and the mshrub is no
exception. This adds another config option and complicates shared
shrub eviction code.
- The value for mshrubs is not actually that great.
Unlike file bshrubs, there's only one mshrub in the filesystem, and
I'm not sure there's a situation where a filesystem has >1 mdirs and
the exact number of allocated blocks is critical.
And this complexity is reflected in code cost and robustness, not to
mention developer time. I think for littlefs this is just not worth
doing. At least not now.
We can always introduce mshrubs in a backwards compatible manner if
needed.
---
But this rework did lead to better code organization around mdir commits
and how they update the mtree/mroot, so I'm keeping those changes.
In general lfsr_mdir_commit has been broken up into mtree/mroot specific
functions that _do_ propagate in-device changes. Any commit to the mroot
changes the on-disk state of the filesystem anyways, so the mroot commit
_must_ be the last thing lfsr_mdir_commit does.
This leads to some duplicated updates, but that's not really a problem.
Here's the new call graph inside lfsr_mdir_commit:
lfsr_mdir_commit
.---------' | | | '-----------------.
v | | '-----------------. |
lfsr_mtree_commit | '--------. | |
'---------. | | | |
v v | | |
lfsr_mroot_commit | | |
| '--------. | | |
| v v | |
| lfsr_mdir_commit_ | |
| .--------' '--------. | |
| | .-----------------|-' |
v v v v v
lfsr_mdir_commit__ lfsr_mdir_compact__
This rework didn't really impact code/stack that much. It added a bit of
code, but saved a bit of RAM. The real value is that the narrower-scoped
functions contain more focused logic:
code stack
before: 30780 2504
after: 31096 (+1.0%) 2480 (-1.0%)
This commit is contained in:
+70
-70
@@ -81,7 +81,7 @@ code = '''
|
||||
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(i), 0, BUF(&alphas[i % 26], 1)))) => 0;
|
||||
@@ -178,7 +178,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -251,7 +251,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdirs were unininlined and split
|
||||
@@ -324,7 +324,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -342,7 +342,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was split correctly
|
||||
@@ -633,7 +633,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -702,7 +702,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -716,7 +716,7 @@ code = '''
|
||||
assert(mdir.u.m.weight == 1);
|
||||
|
||||
// force mdir to compact while we're removing
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
LFSR_ATTR(0, RM, -1, NULL))) => 0;
|
||||
@@ -774,7 +774,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
|
||||
// remove the entry as we compact, forcing the mdir to be dropped
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
@@ -833,7 +833,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
|
||||
// remove the left entry as we compact, forcing the left
|
||||
// mdir to be dropped
|
||||
@@ -900,7 +900,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
|
||||
// remove the right entry as we compact, forcing the right mdir
|
||||
// to be dropped
|
||||
@@ -967,7 +967,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
|
||||
// remove both entries as we compact, forcing both mdirs to be dropped
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
@@ -1017,7 +1017,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -1035,7 +1035,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
|
||||
// remove the left entry as we compact, forcing the left
|
||||
// mdir to be dropped
|
||||
@@ -1112,7 +1112,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -1130,7 +1130,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
|
||||
// remove the right entry as we compact, forcing the right
|
||||
// mdir to be dropped
|
||||
@@ -1206,7 +1206,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -1224,7 +1224,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
|
||||
// remove both entries as we compact, forcing both mdirs to be dropped
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
@@ -1667,7 +1667,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mtree has one mdir
|
||||
@@ -1682,9 +1682,9 @@ code = '''
|
||||
|
||||
lfsr_mdir_t old_mdir = mdir;
|
||||
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'c', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
LFSR_ATTR(mdir.mid, REG, 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -1761,7 +1761,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdirs were unininlined and split
|
||||
@@ -1776,9 +1776,9 @@ code = '''
|
||||
|
||||
lfsr_mdir_t old_mdir = mdir;
|
||||
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'c', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
LFSR_ATTR(mdir.mid, REG, 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -1855,7 +1855,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdirs were unininlined and split
|
||||
@@ -1870,9 +1870,9 @@ code = '''
|
||||
|
||||
lfsr_mdir_t old_mdir = mdir;
|
||||
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'c', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
LFSR_ATTR(mdir.mid, REG, 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -1947,9 +1947,9 @@ code = '''
|
||||
// force mroot to compact twice, this should extend the mroot
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -2007,10 +2007,10 @@ code = '''
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
}
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -2064,9 +2064,9 @@ code = '''
|
||||
// force mroot to compact twice, this should extend the mroot
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert we relocated
|
||||
@@ -2075,9 +2075,9 @@ code = '''
|
||||
// force mroot to compact twice again, this should relocate the mroot
|
||||
old_mroot = lfs.mroot;
|
||||
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -2134,7 +2134,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mtree has one mdir
|
||||
@@ -2144,7 +2144,7 @@ code = '''
|
||||
|
||||
// setup mroot to need to compact, this should trigger a relocation when
|
||||
// we relocate the mdir below
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
// force mdir to compact twice, this should relocate
|
||||
@@ -2154,9 +2154,9 @@ code = '''
|
||||
|
||||
lfsr_mdir_t old_mdir = mdir;
|
||||
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'c', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
LFSR_ATTR(mdir.mid, REG, 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -2239,7 +2239,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -2249,7 +2249,7 @@ code = '''
|
||||
|
||||
// setup mroot to need to compact, this should trigger a relocation when
|
||||
// we relocate the mdir below
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
// now add another large entry to the mdir, forcing a split
|
||||
@@ -2262,7 +2262,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was split correctly
|
||||
@@ -2352,7 +2352,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -2362,7 +2362,7 @@ code = '''
|
||||
|
||||
// setup mroot to need to compact, this should trigger a relocation when
|
||||
// we relocate the mdir below
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
// remove the entry, forcing the mdir to be dropped
|
||||
@@ -2425,7 +2425,7 @@ code = '''
|
||||
|
||||
// force mroot to compact once, so the second compact below will trigger
|
||||
// a relocation
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// prepare mroot with a large attr so the next entry can not fit
|
||||
@@ -2441,7 +2441,7 @@ code = '''
|
||||
|
||||
// force mroot to compact, this should trigger a relocation
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -2513,7 +2513,7 @@ code = '''
|
||||
|
||||
// force mroot to compact once, so the second compact below will trigger
|
||||
// a relocation
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// create 2 large entries that needs to be uninlined and split
|
||||
@@ -2528,7 +2528,7 @@ code = '''
|
||||
|
||||
// force mroot to compact, this should trigger a relocation
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdirs were unininlined and split
|
||||
@@ -2913,7 +2913,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -2992,7 +2992,7 @@ code = '''
|
||||
LFSR_ATTR(2, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdirs were unininlined and split
|
||||
@@ -3053,7 +3053,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -3090,7 +3090,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was split correctly
|
||||
@@ -3169,9 +3169,9 @@ code = '''
|
||||
// force mroot to compact twice, this should extend the mroot
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -3223,7 +3223,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -3256,9 +3256,9 @@ code = '''
|
||||
// force mdir to compact twice, this should relocate
|
||||
lfsr_mdir_t old_mdir = mdir;
|
||||
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'e', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &mdir, LFSR_ATTRS(
|
||||
LFSR_ATTR(1, REG, 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -3317,7 +3317,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// we should now have 2 mdirs
|
||||
@@ -3332,7 +3332,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
|
||||
// we should now have 3 mdirs
|
||||
@@ -3363,7 +3363,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
|
||||
// we should now have 4 mdirs
|
||||
@@ -3410,7 +3410,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// we should now have 2 mdirs
|
||||
@@ -3425,7 +3425,7 @@ code = '''
|
||||
LFSR_ATTR(mdir.mid, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mdir to compact
|
||||
mdir.u.rbyd.eoff = BLOCK_SIZE;
|
||||
mdir.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &mdir, NULL, 0) => 0;
|
||||
|
||||
// we should now have 3 mdirs
|
||||
@@ -3591,7 +3591,7 @@ code = '''
|
||||
LFSR_ATTR(0, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdir was unininlined correctly
|
||||
@@ -3715,7 +3715,7 @@ code = '''
|
||||
LFSR_ATTR(1, REG, +1, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
// force mroot to compact
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
|
||||
// assert mdirs were unininlined and split
|
||||
@@ -3842,9 +3842,9 @@ code = '''
|
||||
// force mroot to compact twice, this should extend the mroot
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -4325,9 +4325,9 @@ code = '''
|
||||
// force mroot to compact twice, this should extend the mroot
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
@@ -4380,10 +4380,10 @@ code = '''
|
||||
lfsr_mdir_t old_mroot = lfs.mroot;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, NULL, 0) => 0;
|
||||
}
|
||||
lfs.mroot.u.rbyd.eoff = BLOCK_SIZE;
|
||||
lfs.mroot.u.rbyd.eoff = -1;
|
||||
memset(buffer, 'b', SIZE);
|
||||
lfsr_mdir_commit(&lfs, &lfs.mroot, LFSR_ATTRS(
|
||||
LFSR_ATTR(-1, UATTR(1), 0, BUF(buffer, SIZE)))) => 0;
|
||||
|
||||
Reference in New Issue
Block a user