ubifs_find_dirty_leb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ubifs_find_dirty_leb(9) β€” Kernel API Manual πŸ’…

okay bestie, welcome to the Kernel API Manual page for ubifs_find_dirty_leb(9). This one is all about the Garbage Collector finding a dirty LEB, and it's lowkey iconic. Let's get into it πŸ’–

✨ NAME ✨

ubifs_find_dirty_leb β€” find a dirty LEB for the Garbage Collector.

🌈 SYNOPSIS 🌈

Here's the signature, exactly as it appears, bestie β€” do not freestyle it:

int ubifs_find_dirty_leb (struct ubifs_info *c , struct ubifs_lprops
       *ret_lp , int min_space , int pick_free );

πŸŽ€ ARGUMENTS πŸŽ€

  • c β€” the UBIFS file-system description object. It's giving main character energy for the whole operation 🫢
  • ret_lp β€” LEB properties are returned here on exit. So this is where the goods land ✨
  • min_space β€” minimum amount free plus dirty space the returned LEB has to have. Like the bar for entry, no cap πŸ’…
  • pick_free β€” controls whether it is OK to pick empty or index LEBs. This little argument is the vibe check for free/freeable LEBs πŸ‘‘

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so this function tries to find a dirty logical eraseblock which has at least min_space free and dirty space. It prefers to take an LEB from the dirty or dirty index heap, and it falls-back to LPT scanning if the heaps are empty or do not have an LEB which satisfies the min_space criteria. Obsessed with a fallback plan, honestly.

🚨 Note: LEBs which have less than dead watermark of free + dirty space are never picked by this function. Not even a little. Not even for you, bestie.

The additional pick_free argument controls if this function has to return a free or freeable LEB if one is present. For example, GC must set it to 1 when called from the journal space reservation function, because the appearance of free space may coincide with the loss of enough dirty space for GC to succeed anyway. It's giving "don't get fooled by a free-looking LEB" energy 😭

In contrast, if the Garbage Collector is called from budgeting, it should just make free space, not return LEBs which are already free or freeable. Periodt. Budgeting GC is not here to hand you a free LEB, it's here to make free space πŸ’…

In addition pick_free is set to 2 by the recovery process in order to recover gc_lnum, in which case an index LEB must not be returned. That's the special recovery mode, and the index LEB rule is non-negotiable 🚫

This function returns zero and the LEB properties of found dirty LEB in case of success, -ENOSPC if no dirty LEB was found and a negative error code in case of other failures. The returned LEB is marked as "taken". So yeah: success means zero plus the found dirty LEB's props, no dirty LEB means -ENOSPC, and other failures throw a negative error code. The taken mark is the little "claimed" sticker πŸ’–

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./fs/ubifs/find.c, plus the whole friend group:


πŸ’– That's the whole page, bestie! Source/version: ./fs/ubifs; date: October 2026; page: ubifs_find_dirty_leb(9). Slay πŸ’…βœ¨

πŸ“¦ where this page comes from