Reverted best-effort fsinfo.known_free/inuse prototype

See previous commit for motivation.

I can't think of how you could easily find this information from the
gbmap during/after mount, short of a O(d log_b d) scan through the
gbmap. Maybe useful, but probably not a great tradeoff for what is only
debug/diagnostic information.

So reverting, but maybe interesting to explore in the future with other
debug APIs.

Code changes:

                 code          stack          ctx
  before:       35220           2136          660
  after:        35160 (-0.2%)   2136 (+0.0%)  660 (+0.0%)

                 code          stack          ctx
  gbmap before: 38116           2152          776
  gbmap after:  38020 (-0.3%)   2152 (+0.0%)  772 (-0.5%)
This commit is contained in:
Christopher Haster
2025-12-02 21:22:36 -06:00
parent 0b48faf898
commit 465e9fbe9d
2 changed files with 1 additions and 42 deletions
-30
View File
@@ -10459,8 +10459,6 @@ eot:;
static void lfs3_gbmap_init(lfs3_gbmap_t *gbmap) {
gbmap->window = 0;
gbmap->known = 0;
// we lazily populate this during lookahead scans
gbmap->known_free = -1;
lfs3_btree_init(&gbmap->b);
lfs3_btree_init(&gbmap->b_p);
}
@@ -16102,34 +16100,6 @@ int lfs3_fs_stat(lfs3_t *lfs3, struct lfs3_fsinfo *fsinfo) {
fsinfo->name_limit = lfs3->name_limit;
fsinfo->file_limit = lfs3->file_limit;
// return best effort knowledge of block usage
// if we have a gbmap, we choose whichever allocator has more
// information, otherwise we fall back to the lookahead buffer
if (LFS3_IFDEF_GBMAP(
lfs3_f_isgbmap(lfs3->flags)
// known_free=-1 indicates we don't know the free/inuse
// breakdown yet
&& lfs3->gbmap.known_free != -1
&& lfs3->gbmap.known >= lfs3->lookahead.known,
false)) {
#ifdef LFS3_GBMAP
fsinfo->known_free = lfs3->gbmap.known_free;
fsinfo->known_inuse = lfs3->gbmap.known - lfs3->gbmap.known_free;
#endif
} else {
lfs3_block_t free = 0;
for (lfs3_size_t i = 0; i < lfs3->lookahead.known; i++) {
if (!(lfs3->lookahead.buffer[(lfs3->lookahead.off+i) / 8]
& (1 << ((lfs3->lookahead.off+i) % 8)))) {
free += 1;
}
}
fsinfo->known_free = free;
fsinfo->known_inuse = lfs3->lookahead.known - free;
}
return 0;
}