gc: Tweaked lfs3_fs_gc_ to rely on lfs3_mtree_gc for fixgrms
This does two things:
- Deduplicates another fixgrm call, now all fixgrm cleanup (outside of
mkdir/remove) goes through lfs3_mtree_gc.
- Predicates fixgrm on if lookahead work is complete.
Code changes:
code stack ctx
before: 35128 2136 660
after: 35116 (-0.0%) 2136 (+0.0%) 660 (+0.0%)
code stack ctx
gbmap before: 38052 2136 776
gbmap after: 38040 (-0.0%) 2136 (+0.0%) 776 (+0.0%)
This commit is contained in:
@@ -16128,7 +16128,7 @@ failed:;
|
||||
// note lfs3_fs_stat should never go to disk
|
||||
int lfs3_fs_stat(lfs3_t *lfs3, struct lfs3_fsinfo *fsinfo) {
|
||||
// return various filesystem flags
|
||||
uint32_t flags = lfs3->flags & (
|
||||
fsinfo->flags = (lfs3->flags & (
|
||||
LFS3_I_RDONLY
|
||||
| LFS3_I_FLUSH
|
||||
| LFS3_I_SYNC
|
||||
@@ -16143,19 +16143,14 @@ int lfs3_fs_stat(lfs3_t *lfs3, struct lfs3_fsinfo *fsinfo) {
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_I_COMPACT)
|
||||
| LFS3_I_CKMETA
|
||||
| LFS3_I_CKDATA
|
||||
| LFS3_IFDEF_GBMAP(LFS3_I_GBMAP, 0));
|
||||
|
||||
// some flags we calculate on demand
|
||||
|
||||
// internally, LFS3_I_MKCONSISTENT just means we may have orphaned
|
||||
// stickynotes, need to also include any grms
|
||||
#ifndef LFS3_RDONLY
|
||||
if (lfs3_t_ismkconsistent(lfs3->flags) || lfs3_grm_count(lfs3) > 0) {
|
||||
flags |= LFS3_I_MKCONSISTENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
fsinfo->flags = flags;
|
||||
| LFS3_IFDEF_GBMAP(LFS3_I_GBMAP, 0)))
|
||||
// LFS3_I_MKCONSISTENT is a bit of a special case,
|
||||
// internally it strictly indicates untracked orphans, but
|
||||
// externally it also includes any pending grms
|
||||
| LFS3_IFDEF_RDONLY(0,
|
||||
(lfs3_grm_count(lfs3) > 0)
|
||||
? LFS3_I_MKCONSISTENT
|
||||
: 0);
|
||||
|
||||
// return filesystem config, this may come from disk
|
||||
fsinfo->block_size = lfs3->cfg->block_size;
|
||||
@@ -16358,26 +16353,20 @@ int lfs3_fs_mkconsistent(lfs3_t *lfs3) {
|
||||
// multiple passes
|
||||
static int lfs3_fs_gc_(lfs3_t *lfs3, lfs3_mgc_t *mgc,
|
||||
uint32_t flags, lfs3_soff_t steps) {
|
||||
// fix pending grms if requested
|
||||
#ifndef LFS3_RDONLY
|
||||
if (lfs3_t_ismkconsistent(flags)
|
||||
&& lfs3_grm_count(lfs3) > 0) {
|
||||
int err = lfs3_fs_fixgrm(lfs3);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while ((lfs3_off_t)steps > 0) {
|
||||
// do we have any pending work?
|
||||
uint32_t pending = flags & (
|
||||
(LFS3_IFDEF_RDONLY(0, LFS3_GC_MKCONSISTENT)
|
||||
(lfs3->flags & (
|
||||
LFS3_IFDEF_RDONLY(0, LFS3_GC_MKCONSISTENT)
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_GC_LOOKAHEAD)
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_GC_COMPACT)
|
||||
| LFS3_GC_CKMETA
|
||||
| LFS3_GC_CKDATA)
|
||||
& lfs3->flags);
|
||||
| LFS3_GC_CKDATA))
|
||||
// including any pending grms
|
||||
| LFS3_IFDEF_RDONLY(0,
|
||||
(lfs3_grm_count(lfs3) > 0)
|
||||
? LFS3_GC_MKCONSISTENT
|
||||
: 0));
|
||||
if (!pending) {
|
||||
break;
|
||||
}
|
||||
@@ -16401,13 +16390,12 @@ static int lfs3_fs_gc_(lfs3_t *lfs3, lfs3_mgc_t *mgc,
|
||||
// note that even though our current API prevents flags from
|
||||
// changing mid-traversal, lfs3->flags can be updated by other
|
||||
// operations
|
||||
mgc->t.h.flags &= ~(
|
||||
(LFS3_IFDEF_RDONLY(0, LFS3_GC_MKCONSISTENT)
|
||||
mgc->t.h.flags &= ~(pending ^ (
|
||||
LFS3_IFDEF_RDONLY(0, LFS3_GC_MKCONSISTENT)
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_GC_LOOKAHEAD)
|
||||
| LFS3_IFDEF_RDONLY(0, LFS3_GC_COMPACT)
|
||||
| LFS3_GC_CKMETA
|
||||
| LFS3_GC_CKDATA)
|
||||
^ pending);
|
||||
| LFS3_GC_CKDATA));
|
||||
|
||||
// will this traversal still make progress? no? start over
|
||||
if (!(mgc->t.h.flags
|
||||
|
||||
Reference in New Issue
Block a user