freeze_super(9)
π freeze_super(9)
okay so bestie, we're in the Kernel API Manual today and the star of the show is freeze_super(9) β yes, the one and only. grab a π and let's get into it.
β¨ NAME β¨
freeze_super β lock the filesystem and force it into a consistent state ππ§
πΈ SYNOPSIS πΈ
int freeze_super (struct super_block *sb , enum freeze_holder who ,
const void *freeze_owner );
π ARGUMENTS π
sbβ the super to lock πwhoβ the context that wants to freezefreeze_ownerβ the owner of the freeze
π¦ DESCRIPTION π¦
So what it literally does: it syncs the super to make sure the filesystem is consistent, then calls the fs's freeze_fs. And heads up β subsequent calls to this without first thawing the fs may return -EBUSY. π
who should be one of these icons:
FREEZE_HOLDER_USERSPACEif userspace wants to freeze the fs;FREEZE_HOLDER_KERNELif the kernel wants to freeze the fs;FREEZE_MAY_NESTwhether nesting freeze and thaw requests is allowed.
The who argument is the whole point, lowkey β it distinguishes between the kernel and userspace trying to freeze the filesystem. And like, even though there cannot be multiple kernel freezes or multiple userspace freezes in effect at any given time, the kernel and userspace can both hold a filesystem frozen. The filesystem stays frozen until there are no kernel or userspace freezes in effect. periodt. β¨
A filesystem may hold multiple devices, and thus a filesystems may be frozen through the block layer via multiple block devices. In this case the request is marked as being allowed to nest by passing FREEZE_MAY_NEST. The filesystem remains frozen until all block devices are unfrozen. If multiple freezes are attempted without FREEZE_MAY_NEST, -EBUSY will be returned. π
π§ the vibe check: what sb->s_writers.frozen goes through π§
During this function, sb->s_writers.frozen goes through these values β it's giving a whole glow-up arc:
SB_UNFROZEN: File system is normal, all writes progress as usual. main character energy, nothing to see here π
SB_FREEZE_WRITE: The file system is in the process of being frozen. New writes should be blocked, though page faults are still allowed. We wait for all writes to complete and then proceed to the next stage. π«Ά
SB_FREEZE_PAGEFAULT: Freezing continues. Now also page faults are blocked but internal fs threads can still modify the filesystem (although they should not dirty new pages or inodes), writeback can run etc. After waiting for all running page faults we sync the filesystem which will clean all dirty pages and inodes (no new dirty pages or inodes can be created when sync is running). π§
SB_FREEZE_FS: The file system is frozen. Now all internal sources of fs modification are blocked (e.g. XFS preallocation truncation on inode reclaim). This is usually implemented by blocking new transactions for filesystems that have them and need this additional guard. After all internal writers are finished we call ->freeze_fs to finish filesystem freezing. Then we transition to SB_FREEZE_COMPLETE state. This state is mostly auxiliary for filesystems to verify they do not modify frozen fs. π₯
ngl,sb->s_writers.frozenis protected bysb->s_umount. keep that in mind, bestie, it's important. π
π RETURN π
If the freeze was successful, zero is returned. If the freeze failed, a negative error code is returned. slay or π, no in between.
β SEE ALSO β
Kernel file ./fs/super.c β and the whole squad: super_lock(9), alloc_super(9), deactivate_locked_super(9), deactivate_super(9), grab_super(9), retire_super(9), generic_shutdown_super(9), sget_fc(9), iterate_supers_type(9), reconfigure_super(9), emergency_thaw_all(9), get_anon_bdev(9), sget_dev(9), fs_bdev_freeze(9), fs_bdev_thaw(9), fs_bdev_file_open_by_dev(9), fs_bdev_file_open_by_path(9), fs_bdev_unregister(9), fs_bdev_file_release(9), get_tree_bdev_flags(9), get_tree_bdev(9), vfs_get_tree(9), sb_wait_write(9), thaw_super(9). iykyk π
π«Ά and that's the page! this one lives in the ./fs section and it's dated October 2026 β so like, write it in your calendar bestie. stay frozen, stay iconic π
π¦ 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