STRUCT UBIFS_WBUF(9)
π 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 thebuf,lnum,offs,avail,used,next_inoandinodesfields. 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
- 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