filemap_get_folio(9)
π
filemap_get_folio β the Kernel API Manual, bestie edition β¨
okay so this is filemap_get_folio(9) from the Kernel API Manual, and honestly? it's giving "small function, huge main character energy" π let's get into it.
πΈ NAME πΈ
filemap_get_folio β find and get a folio. that's it. that's the whole vibe. π
β¨ SYNOPSIS β¨
struct folio * filemap_get_folio (struct address_space *mapping ,
pgoff_t index );
literally two args, no cap. π«Ά
π¦ ARGUMENTS π¦
mappingβ theaddress_spaceyou're searching through. this is the lookup zone, the search space, the place where the folios live. πindexβ the page index. yeah. the index. of the page. that one. π
π DESCRIPTION π
so what it does β it looks up the page cache entry at mapping & index. cute, right? and if a folio is actually present there? it gets returned to you with an increased refcount π so like, bestie, you now own a reference. hold onto it responsibly. that's the whole thing. π
π₯ RETURN π₯
you get either:
- a folio π β slay, it was there
- or
ERR_PTR(-ENOENT)π β if there's no folio in the cache for this index
and important: it will not return a shadow, swap or DAX entry. periodt. not doing it. don't ask. π
π SEE ALSO π
Kernel file ./include/linux/pagemap.h, plus this absolutely iconic lineup of related pages (iykyk):
filemap_set_wb_err(9)filemap_check_wb_err(9)filemap_sample_wb_err(9)file_sample_sb_err(9)mapping_set_error(9)mapping_set_large_folios(9)mapping_align_index(9)mapping_pmd_folio_support(9)folio_flush_mapping(9)folio_inode(9)folio_attach_private(9)folio_change_private(9)folio_detach_private(9)fgf_t(9)fgf_set_order(9)write_begin_get_folio(9)filemap_lock_folio(9)filemap_grab_folio(9)find_get_page(9)find_lock_page(9)find_or_create_page(9)grab_cache_page_nowait(9)folio_next_index(9)folio_next_pos(9)folio_file_page(9)folio_contains(9)page_pgoff(9)folio_pos(9)linear_page_delta(9)linear_page_index(9)linear_anon_page_index(9)folio_trylock(9)folio_lock(9)lock_page(9)folio_lock_killable(9)filemap_range_needs_writeback(9)struct readahead_control(9)page_cache_sync_readahead(9)page_cache_async_readahead(9)readahead_folio(9)readahead_pos(9)readahead_length(9)readahead_index(9)readahead_count(9)readahead_batch_length(9)folio_mkwrite_check_truncate(9)i_blocks_per_folio(9)
like, that's a whole friend group right there π§π
π«Ά quick reminder bestie: the refcount is increased when a folio comes back to you. that's the deal. don't fumble it.
and that's the page!! sourced from ./include/linux, dated October 2026, filed under filemap_get_folio(9) β mwah, go read some folios ππΈβ
π¦ 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