__mark_inode_dirty(9)
π __mark_inode_dirty(9) π
okay so this is a page from the Kernel API Manual, and bestie, it's a kernel-internal one β like, it's the backstage pass, not the general admission ticket. buckle up π
β¨ NAME β¨
__mark_inode_dirty β the internal function that marks an inode dirty. yeah. that's the whole name. it's giving "unassuming but crucial" π
πΈ SYNOPSIS πΈ
void __mark_inode_dirty (struct inode *inode , int flags );
π¦ ARGUMENTS π¦
inodeβ the inode you wanna mark. that's it. that's the one. π«Άflagsβ okay so this is what kind of dirty we're talking about, e.g.I_DIRTY_SYNC. and yes, it can be a combination of multipleI_DIRTY_*flags β a little flag salad, we love that for us β EXCEPT thatI_DIRTY_TIMEcan't be combined withI_DIRTY_PAGES. no cap, that combo is not allowed π«π
β DESCRIPTION β
so the whole job here is: mark an inode as dirty. simple enough, right? but the order matters, and the order is literally the plot:
- we notify the filesystem first π£
- then we update the inode's dirty flags
- then, if needed, we add the inode to the appropriate dirty list
and here's the thing, bestie β most callers should use mark_inode_dirty or mark_inode_dirty_sync instead of calling this directly. this one's for the internal girlies. you probably don't need to raw-dog this function π
CAREFUL! π₯ we only add the inode to the dirty list if it is hashed or if it refers to a blockdev. unhashed inodes will never be added to the dirty list, even if they get hashed later β because they will have been marked dirty already. so like... the window has passed. it's over. π
in short (and I need you to internalize this): ensure you hash any inodes _before_ you start marking them dirty. order of operations is literally everything here, iykyk π
and now the blockdev lore, because it's lowkey iconic π§
for blockdevs, inode->dirtied_when represents the dirtying time of the block-special inode (/dev/hda1) itself. meanwhile the ->dirtied_when field of the kernel-internal blockdev inode represents the dirtying time of the blockdev's pages. two different times, two different inodes, no confusion intended (there is, in fact, confusion intended, but now you know π).
which is exactly why, for I_DIRTY_PAGES, we always use page->mapping->host β so the page-dirtying time gets recorded in the internal blockdev inode. it's giving "correct accounting or bust" πβ¨
π SEE ALSO π
kernel file ./fs/fs-writeback.c plus this whole squad right here, no gatekeeping:
inode_io_list_move_locked(9)wb_wait_for_completion(9)inode_cgwb_move_to_attached(9)locked_inode_to_wb_and_lock_list(9)inode_to_wb_and_lock_list(9)inode_switch_wbs(9)cleanup_offline_cgwb(9)wbc_attach_and_unlock_inode(9)wbc_attach_fdatawrite_inode(9)wbc_detach_inode(9)wbc_account_cgroup_owner(9)wb_split_bdi_pages(9)bdi_split_work_to_wbs(9)cgroup_writeback_by_id(9)cgroup_writeback_umount(9)wb_start_background_writeback(9)filemap_dontcache_kick_writeback(9)writeback_inodes_sb_nr(9)writeback_inodes_sb(9)try_to_writeback_inodes_sb(9)sync_inodes_sb(9)write_inode_now(9)sync_inode_metadata(9)
and that's the page!! πβ¨π
signed, sealed, delivered by ./fs β October 2026 β mwah, take care of your inodes bestie π«ΆπΈ
π¦ 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