do_budget_space(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:

  1. add the amount of budgeted index space to the size of the current index
  2. multiply that by 3
  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_lebs is 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_lebs is the number of LEBS the index presumably takes. IOW, the index may be consolidated to take up to c->bi.min_idx_lebs LEBs ⭐

🌈 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:


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