__mark_inode_dirty(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __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 multiple I_DIRTY_* flags β€” a little flag salad, we love that for us β€” EXCEPT that I_DIRTY_TIME can't be combined with I_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:

  1. we notify the filesystem first πŸ“£
  2. then we update the inode's dirty flags
  3. 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:


and that's the page!! πŸŽ€βœ¨πŸ’–

signed, sealed, delivered by ./fs β€” October 2026 β€” mwah, take care of your inodes bestie 🫢🌸

πŸ“¦ where this page comes from