file_fdatawait_range(9)
π file_fdatawait_range β wait for writeback to complete π
okay so bestie, this is a page from the Kernel API Manual (9 section, kernel dev vibes only) and it's literally all about one function that makes you wait. no cap. let's get into it π«Ά
β¨ SYNOPSIS β¨
int file_fdatawait_range (struct file *file , loff_t start_byte , loff_t
end_byte );
like, that's it. that's the whole signature. three args, returns an int. slay π
π ARGUMENTS π
fileβ the file that points at the address space structure you're waiting on. it's giving "which one of y'all am I babysitting" energy β¨start_byteβ the offset in bytes where the range starts. where the drama begins πΈend_byteβ the offset in bytes where the range ends, and yeah it's inclusive, so don't come for me about off-by-one, she's included π
π DESCRIPTION π
so what it actually does: it walks the list of under-writeback pages belonging to the address space that file refers to, but only in the given range, and waits for all of them. like a little line of pages all going "still writing!!" and this function is the friend going "okay bestie I'll wait" π¦
then it checks the error status of the address space vs. the file->f_wb_err cursor and returns it. iykyk π
π¨ important caveat, fr fr β since the error status of the file is advanced by this function, callers are responsible for checking the return value and handling and/or reporting the error. like, do not just ignore it, that's not the vibe. π
β RETURN β
the error status of the address space vs. the file->f_wb_err cursor. that's the whole return, no extras, periodt π―
π§ SEE ALSO π§
Kernel file ./mm/filemap.c β and here's the full squad, not skipping a single one, because everyone deserves their moment:
filemap_remove_folio(9)filemap_fdatawrite_range(9)filemap_flush_range(9)filemap_flush(9)filemap_range_has_page(9)filemap_fdatawait_range(9)filemap_fdatawait_range_keep_errors(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, go forth and wait on your writeback responsibly π
cute little sign-off: this legend lives in the ./mm source directory, and this particular printing is the October 2026 version. mwah πβ¨
π¦ 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