STRUCT UBIFS_WBUF(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct ubifs_wbuf(9) β€” the kernel API manual, but make it make sense πŸ’–

okay bestie, so this is a page from the Kernel API Manual (yes, the big scary one) and today's main character is struct ubifs_wbuf β€” the UBIFS write-buffer. it's giving "small struct, big responsibilities" and honestly? iconic. 🫢


✨ NAME ✨

struct ubifs_wbuf β€” UBIFS write-buffer. that's it, that's the name, no cap. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole shape of her, character for character, don't touch:

struct ubifs_wbuf {
    struct ubifs_info *c;
    void *buf;
    int lnum;
    int offs;
    int avail;
    int used;
    int size;
    int jhead;
    int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int
pad);
    struct mutex io_mutex;
    spinlock_t lock;
    struct hrtimer timer;
    unsigned int no_timer:1;
    unsigned int need_sync:1;
    int next_ino;
    ino_t *inodes;
 };

πŸŽ€ Members πŸŽ€

okay this is the part where we meet everyone in the group chat, one field at a time:

  • c β€” the UBIFS file-system description object. the ~context~ of the whole operation. 🌸
  • buf β€” the write-buffer itself (of min. flash I/O unit size). the lil buffer doing the actual buffering. ✨
  • lnum β€” logical eraseblock number the write-buffer points to. where we at on the LEB map. πŸ—ΊοΈ
  • offs β€” write-buffer offset in this logical eraseblock. like, where inside that LEB. πŸ“
  • avail β€” number of bytes available in the write-buffer. room to spare, bestie. πŸ’œ
  • used β€” number of used bytes in the write-buffer. the space that's already taken. no takebacks. πŸ’€
  • size β€” write-buffer size, and it lives in the [c->min_io_size, c->max_write_size] range. respect the boundaries fr fr. πŸ”₯
  • jhead β€” journal head the mutex belongs to. > note: needed only to shut lockdep up by 'mutex_lock_nested'. (lockdep really said "prove it" and this field said "fine.") πŸ™ˆ
  • sync_callback β€” write-buffer synchronization callback. the "hey we synced, here's what happened" messenger. 🧚
  • io_mutex β€” serializes write-buffer I/O. one at a time, please, we're not animals. πŸŽ€
  • lock β€” serializes the buf, lnum, offs, avail, used, next_ino and inodes fields. yes all of those. it's a whole roster. πŸ‘‘
  • timer β€” write-buffer timer. tick tock. ⭐
  • no_timer β€” non-zero if this write-buffer does not have a timer. so like, the timer has an off switch, basically. 🌈
  • need_sync β€” non-zero if the timer expired and the wbuf needs sync'ing. the "we gotta move" flag. 😭
  • next_ino β€” points to the next position of the following inode number. lineup energy. πŸ“
  • inodes β€” stores the inode numbers of the nodes which are in wbuf. the whole crew, remembered. πŸ’–

🌟 Description 🌟

so here's the lore: the write-buffer synchronization callback gets called when the write-buffer is synchronized, and its whole job is to notify how much space was wasted due to write-buffer padding and how much free space is left in the LEB. so it's basically the receipts. 🧾✨


πŸ’€ Note πŸ’€

listen up, this one's important:

the fields buf, lnum, offs, avail and used can be read under spin-lock or mutex because they are written under both mutex and spin-lock. buf is appended to under mutex but overwritten under both mutex and spin-lock. thus the data between buf and buf + used can be read under spinlock. 🫢

lowkey love how that's spelled out for us. read it twice, it's not a vibe check you can skip. πŸ’…

🌈 SEE ALSO 🌈

all her friends, in the order they showed up β€” Kernel file ./fs/ubifs/ubifs.h, plus:

struct ubifs_old_idx(9), struct ubifs_scan_node(9), struct ubifs_scan_leb(9), struct ubifs_gced_idx_leb(9), struct ubifs_inode(9), struct ubifs_unclean_leb(9), struct ubifs_lprops(9), struct ubifs_lpt_lprops(9), struct ubifs_lp_stats(9), struct ubifs_cnode(9), struct ubifs_pnode(9), struct ubifs_nbranch(9), struct ubifs_nnode(9), struct ubifs_lpt_heap(9), struct ubifs_bud(9), struct ubifs_jhead(9), struct ubifs_zbranch(9), struct ubifs_znode(9), struct bu_info(9), struct ubifs_node_range(9), struct ubifs_compressor(9), struct ubifs_budget_req(9), struct ubifs_orphan(9), struct ubifs_mount_opts(9), struct ubifs_budg_info(9), struct ubifs_stats_info(9), struct ubifs_info(9), ubifs_check_hash(9), ubifs_check_hmac(9), ubifs_branch_hash(9), ubifs_copy_hash(9), ubifs_auth_node_sz(9)


and that's the whole page, bestie!! πŸŽ€βœ¨ this lil slice of the manual lives at ./fs/ubifs and it's dated October 2026 β€” so yeah, future-dated lore, we love a forward-thinking queen. mwah, study it, slay your kernel debugging, periodt. πŸ’–πŸ‘‘πŸ”₯

πŸ“¦ where this page comes from