t: Moved some stuff around in lfsr_mtree_gc
Nothing consequential.
One interesting question is if we should swap our dirty bits during the
call to lfsr_mtree_traverse. At the moment I think limiting this to just
our lfsr_mtree_gc logic will create the least surprise in the future.
Code changes minimal:
code stack
before: 36288 2704
after: 36284 (-0.0%) 2704 (+0.0%)
This commit is contained in:
@@ -8680,9 +8680,6 @@ static void lfs_alloc_markfree(lfs_t *lfs);
|
||||
// mutation here, upper layers should call lfs_alloc_ckpoint as needed
|
||||
static int lfsr_mtree_gc(lfs_t *lfs, lfsr_traversal_t *t,
|
||||
lfsr_tag_t *tag_, lfsr_bptr_t *bptr_) {
|
||||
// swap dirty/mutated flags while in lfsr_mtree_gc
|
||||
t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags);
|
||||
|
||||
dropped:;
|
||||
lfsr_tag_t tag;
|
||||
lfsr_bptr_t bptr;
|
||||
@@ -8696,6 +8693,14 @@ dropped:;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
// swap dirty/mutated flags while in lfsr_mtree_gc
|
||||
t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags);
|
||||
|
||||
// track in-use blocks?
|
||||
if (lfsr_t_islookahead(t->o.o.flags)) {
|
||||
lfs_alloc_markinuse(lfs, tag, &bptr);
|
||||
}
|
||||
|
||||
// mkconsistencing mdirs?
|
||||
if (lfsr_t_ismkconsistent(t->o.o.flags)
|
||||
&& tag == LFSR_TAG_MDIR
|
||||
@@ -8711,16 +8716,14 @@ dropped:;
|
||||
|
||||
// did this drop our mdir?
|
||||
if (mdir->mid != -1 && mdir->rbyd.weight == 0) {
|
||||
// swap back dirty/mutated flags
|
||||
t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags);
|
||||
// continue traversal
|
||||
t->o.o.state = LFSR_TSTATE_MDIRS;
|
||||
goto dropped;
|
||||
}
|
||||
}
|
||||
|
||||
// track in-use blocks?
|
||||
if (lfsr_t_islookahead(t->o.o.flags)) {
|
||||
lfs_alloc_markinuse(lfs, tag, &bptr);
|
||||
}
|
||||
|
||||
// compacting mdirs?
|
||||
if (lfsr_t_iscompact(t->o.o.flags)
|
||||
&& tag == LFSR_TAG_MDIR
|
||||
@@ -8838,7 +8841,6 @@ dropped:;
|
||||
|
||||
// swap back dirty/mutated flags
|
||||
t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags);
|
||||
|
||||
if (tag_) {
|
||||
*tag_ = tag;
|
||||
}
|
||||
@@ -8847,16 +8849,12 @@ dropped:;
|
||||
}
|
||||
return 0;
|
||||
|
||||
eot:;
|
||||
failed:;
|
||||
// swap back dirty/mutated flags
|
||||
t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags);
|
||||
return err;
|
||||
|
||||
// was mkconsistent successful?
|
||||
if (lfsr_t_ismkconsistent(t->o.o.flags)
|
||||
&& !lfsr_f_isdirty(t->o.o.flags)) {
|
||||
lfs->flags &= ~LFS_F_ORPHANS;
|
||||
}
|
||||
|
||||
eot:;
|
||||
// was lookahead scan successful?
|
||||
if (lfsr_t_islookahead(t->o.o.flags)
|
||||
&& !lfsr_f_isdirty(t->o.o.flags)
|
||||
@@ -8864,6 +8862,12 @@ eot:;
|
||||
lfs_alloc_markfree(lfs);
|
||||
}
|
||||
|
||||
// was mkconsistent successful?
|
||||
if (lfsr_t_ismkconsistent(t->o.o.flags)
|
||||
&& !lfsr_f_isdirty(t->o.o.flags)) {
|
||||
lfs->flags &= ~LFS_F_ORPHANS;
|
||||
}
|
||||
|
||||
// was compaction successful? note we may need multiple passes if
|
||||
// we want to be sure everything is compacted
|
||||
if (lfsr_t_iscompact(t->o.o.flags)
|
||||
@@ -8873,11 +8877,6 @@ eot:;
|
||||
}
|
||||
|
||||
return LFS_ERR_NOENT;
|
||||
|
||||
failed:;
|
||||
// swap back dirty/mutated flags
|
||||
t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user