filemap_fdatawait_range(9)
π filemap_fdatawait_range (Kernel API Manual, bestie!)
okay so picture this: you're deep in the kernel, in the 9 section of the manual, and you just need to wait for writeback to be done. that's the whole vibe of this function β filemap_fdatawait_range β and yes it literally does what it says on the tin: it waits for writeback to complete. no cap. π
β¨ SYNOPSIS β¨
int filemap_fdatawait_range (struct address_space *mapping , loff_t
start_byte , loff_t end_byte );
like, it returns an int, takes a struct address_space *mapping, and two loff_ts: start_byte and end_byte. that's the whole signature, she's not complicated π¦
πΈ ARGUMENTS πΈ
mappingβ the address space structure you're waiting on. this is the main character of the whole operation, honestly. πstart_byteβ offset in bytes where the range starts.end_byteβ offset in bytes where the range ends, and note that it's inclusive β she's in the range, not politely standing outside it. π«Ά
π DESCRIPTION π
so here's what happens: it walks the list of under-writeback pages of the given address space, in the given range, and waits for all of them. every single one. no skipping, no "eh close enough". then it checks the error status of the address space and returns it back to you. slay. β¨
π¨ important, bestie, read this twice: since the error status of the address space is cleared by this function, callers are responsible for checking the return value and handling and/or reporting the error. it's giving "you break it, you bought it". the function does not remember the error for you β it hands it to you and wipes it. so if you ignore the return value, that error is justβ¦ gone. π fr fr, do not let that happen.
π RETURN π
the error status of the address space. that's it, that's the return value. catching it and actually doing something with it is your job. π
π¦ SEE ALSO π¦
Kernel file ./mm/filemap.c and honestly the whole friend group:
filemap_remove_folio(9)filemap_fdatawrite_range(9)filemap_flush_range(9)filemap_flush(9)filemap_range_has_page(9)filemap_fdatawait_range_keep_errors(9)file_fdatawait_range(9)filemap_fdatawait_keep_errors(9)filemap_write_and_wait_range(9)file_check_and_advance_wb_err(9)file_write_and_wait_range(9)replace_page_cache_folio(9)softleaf_entry_wait_on_locked(9)folio_put_wait_locked(9)folio_unlock(9)folio_end_read(9)folio_end_private_2(9)folio_wait_private_2(9)folio_wait_private_2_killable(9)folio_end_writeback_no_dropbehind(9)folio_end_writeback(9)__folio_lock(9)page_cache_next_miss(9)page_cache_prev_miss(9)__filemap_get_folio_mpol(9)find_get_entries(9)find_lock_entries(9)filemap_get_folios(9)filemap_get_folios_contig(9)filemap_get_folios_tag(9)filemap_get_folios_dirty(9)filemap_read(9)generic_file_read_iter(9)filemap_splice_read(9)mapping_seek_hole_data(9)filemap_fault(9)read_cache_folio(9)mapping_read_folio_gfp(9)read_cache_page_gfp(9)__generic_file_write_iter(9)generic_file_write_iter(9)filemap_release_folio(9)filemap_invalidate_inode(9)filemap_cachestat(9)
π okay that's the whole page, you ate that. this one lives in ./mm and it's dated October 2026 β so go forth, wait for your writeback, and please check that return value. ily, bye! ππ§ββοΈ
π¦ 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