writeback_iter(9)
π writeback_iter(9) π
okay so this is a page from the Kernel API Manual and it's all about writeback_iter β the little function that hands you folios one at a time while you're doing writeback. bestie, it's literally the backbone of your ->writepages implementation and i need you to respect it. π«Ά
β¨ NAME β¨
writeback_iter β iterate folio of a mapping for writeback
πΈ SYNOPSIS πΈ
struct folio * writeback_iter (struct address_space *mapping , struct
writeback_control *wbc , struct folio *folio , int *error );
π ARGUMENTS π
mappingβ the address space structure you wanna write, bestie. that's the whole target of the operation πwbcβ the writeback context. it's giving "here's how we're doing this writeback" energyfolioβ the folio you iterated before. passNULLto start, and then keep feeding back what you got π¦errorβ an in-out pointer for writeback errors (peep the description below, it matters π)
π DESCRIPTION π
so this function returns the next folio for the writeback operation described by wbc on mapping, and you should be calling it in a while loop inside your ->writepages implementation. no cap. that's the whole deal.
to start the writeback operation, you pass NULL in the folio argument β that's your opening move. then, for every subsequent iteration, you pass the folio you got back last time right back in. yes, it's a little handoff ritual, and honestly? iconic. β¨
if there was an error in the per-folio writeback inside the writeback_iter loop, error should be set to that error value. don't be shy about it, tell the truth to the pointer. π
once the writeback described in wbc has finished, this function returns NULL β that's your "we're done here" moment β and if there was an error in any iteration, it restores it to error. so the error you stashed does not get lost, periodt.
π₯ NOTE π₯
callers should not manually break out of the loop usingbreakorgotoβ no ma'am, absolutely not. you must keep callingwriteback_iteruntil it returnsNULL. it's a whole commitment, like finishing a series. π
β RETURN β
the folio to write, or NULL if the loop is done. that's it, that's the answer. π
π SEE ALSO π
kernel file ./mm/page-writeback.c and all its friends:
node_dirtyable_memory(9)global_dirtyable_memory(9)domain_dirty_limits(9)global_dirty_limits(9)node_dirty_limit(9)node_dirty_ok(9)__wb_calc_thresh(9)balance_dirty_pages_ratelimited_flags(9)balance_dirty_pages_ratelimited(9)wb_over_bg_thresh(9)tag_pages_for_writeback(9)filemap_dirty_folio(9)folio_redirty_for_writepage(9)folio_mark_dirty(9)folio_wait_writeback(9)folio_wait_writeback_killable(9)folio_wait_stable(9)
and that's the whole page, bestie!! π this one comes to you straight from ./mm (the source, mwah) and it's dated October 2026 β so like, very on-trend. go forth and iterate your folios responsibly π§ββοΈπ
π¦ 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