block_invalidate_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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

okay so bestie, buckle up, we're getting into block_invalidate_folio β€” it lives in the Kernel API Manual and it's genuinely one of those little functions that's doing main character work behind the scenes 🫢


✨ NAME ✨

block_invalidate_folio β€” invalidate part or all of a buffer-backed folio. literally what it says on the tin πŸ’–


🌸 SYNOPSIS 🌸

void block_invalidate_folio (struct folio *folio , size_t offset ,
       size_t length );

like, no return value, it just goes and does the thing πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • folio β€” the folio which is affected. this is the one getting the ~treatment~ πŸ¦‹
  • offset β€” start of the range to invalidate ✨
  • length β€” length of the range to invalidate ✨

πŸ’… DESCRIPTION πŸ’…

so block_invalidate_folio gets called when all or part of the folio has been invalidated by a truncate operation. yep, truncate said "you're done here" and this is the function that handles the emotional fallout 😭

now, the vibe check: block_invalidate_folio does not have to release all buffers. like, that's not the assignment. but it must make sure of two things, no cap:

  • no dirty buffer is left outside offset
  • no I/O is underway against any of the blocks which are outside the truncation point
why tho? because the caller is about to free (and possibly reuse) those blocks on-disk. so anything still dirty or still doing I/O out there is gonna be a whole mess πŸ”₯πŸ’€

so yeah, not optional. the must is doing heavy lifting there, bestie, respect it.


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./fs/buffer.c β€” and the whole friend group came through:

bio_endio_bh(9), end_buffer_read_sync(9), bh_end_read(9), bh_end_write(9), bh_end_async_write(9), mmb_sync(9), block_dirty_folio(9), mark_buffer_dirty(9), __brelse(9), __bforget(9), bh_submit(9), bdev_getblk(9), __bread_gfp(9), clean_bdev_aliases(9), try_to_free_buffers(9), bh_uptodate_or_lock(9), __bh_read(9), __bh_read_batch(9)


that's the whole page, icon behaviour only 🌈⭐ this cutie comes to you from ./fs, dated October 2026, and it's block_invalidate_folio(9) β€” ily, go read fs/buffer.c πŸ“πŸ§šπŸ’œ

πŸ“¦ where this page comes from