sb_start_write(9)
π sb_start_write(9) β like, the kernel API manual, bestie β¨
okay so before we even get into it: this is a page from the Kernel API Manual, and the star of the show is sb_start_write. Buckle up, it's giving "locking but make it fashion" π
πΈ NAME πΈ
sb_start_write β get write access to a superblock (yes, the superblock. the big one. the main character π)
β¨ SYNOPSIS β¨
void sb_start_write (struct super_block *sb );
that's it. that's the whole vibe check. no return value, nothing to check, just call it and go π¦
π«Ά ARGUMENTS π«Ά
sbβ the super we write to. that's the superblock you're about to get all up in π
π₯ DESCRIPTION π₯
okay so here's the tea β When a process wants to write data or metadata to a file system (iykyk β that's like dirtying a page or an inode), it should embed the operation in a sb_start_write β sb_end_write pair so it gets exclusion against file system freezing. like, freezing can NOT happen while you're mid-write, periodt π
So what does this function actually do? It increments the number of writers, which is literally what prevents freezing from happening. and if the file system is already frozen when you call it? it just waits β like, sits there, patient, until the file system is thawed π no cap.
β οΈ and now the important part, bestie, so listen up β since freeze protection behaves as a lock, users have to preserve the ordering of freeze protection and other filesystem locks. do not mess with the order. this is not a drill π¨
Generally, freeze protection should be the outermost lock. In particular, we have:
sb_start_write -> i_rwsem (write path, truncate,
directory ops, ...) -> s_umount (freeze_super,
thaw_super)
so yeah, sb_start_write comes first, then i_rwsem (that's the write path, truncate, directory ops, ...), then s_umount (that's freeze_super, thaw_super). outermost lock energy only πβ¨
π¦ SEE ALSO π¦
bestie these are all friends of the family, go say hi π
- Kernel file
./include/linux/fs/super.h __sb_write_started(9)sb_write_started(9)sb_write_not_started(9)sb_end_write(9)sb_end_pagefault(9)sb_end_intwrite(9)sb_start_pagefault(9)sb_start_intwrite(9)
and that's the whole page, no notes π this lil beauty lives over at ./include/linux/fs, dated October 2026 β mwah, go forth and lock 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