do_budget_space(9)
π do_budget_space(9) β from the Kernel API Manual β¨
okay so bestie, buckle up, because we're diving into do_budget_space(9) and honestly? she's lowkey the reason your flash doesn't fold under pressure π«Ά
β¨ NAME β¨
do_budget_space β reserve flash space for index and data growth. that's it, that's the vibe π
πΈ SYNOPSIS πΈ
int do_budget_space (struct ubifs_info *c );
π ARGUMENTS π
cβ the UBIFS file-system description object. she's the main character here, periodt π
π¦ DESCRIPTION π¦
So like, this function's whole job is making sure UBIFS has enough free LEBs for index growth and data. no cap, that's the entire mission π
When it's budgeting index space, UBIFS reserves thrice as many LEBs as the index would take if it was consolidated and written to the flash. Why, you ask? because this guarantees the "in-the-gaps" commit method always succeeds, and UBIFS will always be able to commit a dirty index. iconic behavior honestly π₯
So basically what this function does is:
- add the amount of budgeted index space to the size of the current index
- multiply that by
3 - make sure this does not exceed the amount of free LEBs
like, that's the whole recipe π
π notes about c->bi.min_idx_lebs and c->lst.idx_lebs π
c->lst.idx_lebsis the number of LEBs the index currently uses. it might be large, because UBIFS does not do any index consolidation as long as there is free space. IOW, the index may take a lot of LEBs, but those LEBs will contain a lot of dirt π§Ήc->bi.min_idx_lebsis the number of LEBS the index presumably takes. IOW, the index may be consolidated to take up toc->bi.min_idx_lebsLEBs β
π RETURN VALUE π
This function returns zero in case of success, and -ENOSPC in case of failure π (you will know when things go wrong, bestie)
π SEE ALSO π
Kernel file ./fs/ubifs/budget.c plus the whole friend group:
shrink_liability(9)run_gc(9)get_liability(9)make_free_space(9)ubifs_calc_min_idx_lebs(9)ubifs_calc_available(9)can_use_rp(9)calc_idx_growth(9)calc_data_growth(9)calc_dd_growth(9)ubifs_budget_space(9)ubifs_release_budget(9)ubifs_convert_page_budget(9)ubifs_release_dirty_inode_budget(9)ubifs_reported_space(9)ubifs_get_free_space_nolock(9)ubifs_get_free_space(9)
and that's the whole page, bestie π«Ά this little icon lives in ./fs/ubifs, dated October 2026, and she goes by do_budget_space(9) β go forth and budget responsibly πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms