clean_bdev_aliases(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… clean_bdev_aliases(9) πŸ’…

okay bestie, welcome to the Kernel API Manual page for clean_bdev_aliases(9) β€” no cap, we're doing buffer-cache cleanup and being cute about it. 🧚✨


🌸 NAME 🌸

clean_bdev_aliases β€” clean a range of buffers in block device. πŸ’–

✨ SYNOPSIS ✨

void clean_bdev_aliases (struct block_device *bdev , sector_t block ,
       sector_t len );

πŸŽ€ ARGUMENTS πŸŽ€

  • bdev β€” Block device to clean buffers in. πŸ’…
  • block β€” Start of a range of blocks to clean. ⭐
  • len β€” Number of blocks to clean. πŸ“

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the vibe: we're taking a range of blocks for data, and we do not want writeback of any buffer-cache aliases starting from the return of this function until something explicitly marks the buffer dirty β€” hopefully that will not happen until we free that block ;-). We don't even need to mark it not-uptodate β€” nobody can expect anything from a newly allocated buffer anyway. We used to use unmap_buffer for this kind of invalidation, but that was wrong. We definitely don't want to mark the alias unmapped, for example β€” it would confuse anyone who might pick it with bread afterwards... 😭

Also.. note that bforget doesn't lock the buffer. So there can be writeout I/O going on against recently-freed buffers. We don't wait on that I/O in bforget β€” it's more efficient to wait on the I/O only if we really need to. That happens here. πŸ’€πŸ”₯

🌈 SEE ALSO 🌈

Kernel file ./fs/buffer.c: 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), block_invalidate_folio(9), try_to_free_buffers(9), bh_uptodate_or_lock(9), __bh_read(9), __bh_read_batch(9). 🫢


bye bestie 🫢 β€” source/version: ./fs, date: October 2026, page: clean_bdev_aliases(9). mwah πŸ’‹

πŸ“¦ where this page comes from