gc: Enabled committing the gbmap if we have nothing else to do
This kinda fell out of the preerase gc work.
Normally, we're lazy about committing the gbmap into the mtree. Most
on-demand gbmap rebuilds are followed by an mdir commit anyways, so
normally it would just add redundant work and muddy up the
lfs3_alloc_ckpoint path.
But this isn't the case for gc work, which will probably be followed by
long periods of idling. If we lose power while idling (which, let's be
honest, is the most likely time to lose power), we'll lose any
gbmap-related gc progres. Not ideal.
Fortunately, avoiding this is easy. We just need an additional step
after any traversal/preerasing gc work that eagerly commits the gbmap
into the mtree.
The only downside is a bit more code:
code stack ctx
before: 35116 2136 660
after: 35116 (+0.0%) 2136 (+0.0%) 660 (+0.0%)
code stack ctx
gbmap+np before: 38188 2144 776
gbmap+np after: 38252 (+0.2%) 2144 (+0.0%) 776 (+0.0%)
code stack ctx
gbmap+yp before: 38608 2144 796
gbmap+yp after: 38664 (+0.1%) 2144 (+0.0%) 796 (+0.0%)
This commit is contained in:
@@ -16633,11 +16633,18 @@ static int lfs3_fs_gc_(lfs3_t *lfs3, lfs3_mgc_t *mgc,
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO do this
|
||||
// // if we have nothing else to do, try to commit the gbmap to
|
||||
// // disk so it's recoverable if we lose power
|
||||
// } else if (lfs3_btree_cmp(&lfs3->gbmap.b, &lfs3->gbmap.b_p) != 0) {
|
||||
// // TODO
|
||||
// if we have nothing else to do, try to commit the gbmap to
|
||||
// disk so it's recoverable if we lose power
|
||||
} else if (LFS3_IFDEF_GBMAP(
|
||||
lfs3_btree_cmp(&lfs3->gbmap.b, &lfs3->gbmap.b_p) != 0,
|
||||
false)) {
|
||||
#if !defined(LFS3_RDONLY) && defined(LFS3_GBMAP)
|
||||
int err = lfs3_mdir_commit(lfs3, &lfs3->mroot,
|
||||
LFS3_RATTRS(LFS3_RATTR_NULL));
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nothing to do at all? guess we're done
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user