filemap_grab_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… filemap_grab_folio(9) β€” from the Kernel API Manual, bestie πŸŽ€

okay so picture this: you're deep in the kernel, you need a folio, and this little icon is literally the page-cache vending machine. grab a snack, get a folio. no cap.


✨ NAME ✨

filemap_grab_folio β€” grab a folio from the page cache 🫢


🌸 SYNOPSIS 🌸

struct folio * filemap_grab_folio (struct address_space *mapping ,
pgoff_t index );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • mapping β€” the address space to search πŸ” like, the whole neighbourhood you're looking in
  • index β€” the page index πŸ“ the exact house number

πŸ’– DESCRIPTION πŸ’–

So the way this works: it looks up the page cache entry at mapping & index. Cute, right?

if no folio is found, a new folio is created. yes, it manifests one. main character energy fr fr ✨

the folio is locked, marked as accessed, and returned. so it comes back to you locked and already flagged as "yeah someone touched this" β€” all in one trip πŸ’…


πŸ‘‘ RETURN πŸ‘‘

a found or created folio πŸ’œ

but if it's giving nothing β€” like, no folio was found and creating one failed β€” you get ERR_PTR(-ENOMEM) 😭 so always check, bestie, don't just vibe with the pointer.


🌈 SEE ALSO 🌈

the kernel file ./include/linux/pagemap.h and honestly, the whole extended friend group:


πŸ› small heads up: the folio you get back is locked β€” so bestie, you own the unlock. don't ghost it. 😭

and that's the whole page, mwah πŸ’‹ β€” this one lives in ./include/linux and it's dated October 2026, so mark your calendar πŸ“…βœ¨ slay, go read some folios πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from