ext4_swap_extents(9)
π ext4_swap_extents (kernel API manual, section 9, bestie)
Okay so bestie, buckle up β we're diving into ext4_swap_extents, and honestly? It's giving "does exactly what it says on the tin" energy. Let's go π«Ά
β¨ NAME β¨
ext4_swap_extents β swap extents between two inodes π
π SYNOPSIS π
int ext4_swap_extents (handle_t *handle , struct inode *inode1 , struct
inode *inode2 , ext4_lblk_t lblk1 , ext4_lblk_t lblk2 , ext4_lblk_t
count , int unwritten , int *erp );
Yes, that's a lot of arguments. No, we're not skipping any of them. Come on π
πΈ ARGUMENTS πΈ
handleβ the handle for this transaction, like the VIP wristband for the whole operation ποΈinode1β first inode. The main character (of the pair, anyway) πinode2β second inode. Equally iconique, don't worry πlblk1β start block for the first inode πlblk2β start block for the second inode πcountβ number of blocks to swap. Yes, an actual count, not a vibe π’unwrittenβ mark the second inode's extents as unwritten after the swap πerpβ pointer to save the error value. When things go sideways, this is where the receipts live π§Ύ
π¦ DESCRIPTION π¦
So this helper routine literally does exactly what it promises: it "swaps extents." That's the whole assignment, and it ate π₯
But β and this is the important part, bestie β all the other stuff is not its job. Page-cache locking consistency? Not here. bh mapping consistency? Nope. Extent's data copying? Also not here. All of that must be performed by the caller. It's giving "I did my part, you do yours" energy π
π Locking
i_rwsemis held for both inodesi_data_semis locked for write for both inodes
β οΈ Assumptions
- All pages from the requested range are locked for both inodes
fr fr, read the assumptions before you call this. It assumes you've already done the locking homework πβ¨
π SEE ALSO π
- Kernel file
./fs/ext4/extents.cπ
Anyway, that's the whole page, bestie β you're now officially educated on extent swapping π§ββοΈβ¨
This little love letter comes from the source tree ./fs/ext4, dated October 2026 β and it's the ext4_swap_extents(9) page, in case you lost track π
π¦ 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