mmb_sync(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’Ύ mmb_sync(9) β€” the kernel API manual, bestie edition πŸ’Ύ

okay so you found the mmb_sync page in the Kernel API Manual and you're like "what is this even" β€” don't worry, I got you. πŸ’–


🌸 NAME 🌸

mmb_sync β€” write out & wait upon all buffers in a list


✨ SYNOPSIS ✨

int mmb_sync (struct mapping_metadata_bhs *mmb );

πŸŽ€ ARGUMENTS πŸŽ€

  • mmb β€” the list of buffers to write. that's the whole vibe check, she's just a list of buffers πŸ’…

πŸ’« DESCRIPTION πŸ’«

okay so first thing: it starts I/O against the buffers in the given list and then waits upon that I/O. literally starts it, then sits there waiting. no cap. 🫢

basically, this is a convenience function for fsync. and mmb is for a file or directory which needs those buffers to be written for a successful fsync, iykyk.

now here's where it gets real β€” we have conflicting pressures: πŸ’€

  • we want to make sure that all initially dirty buffers get waited on
  • but that any subsequently dirtied buffers don't

after all, we don't want fsync to last forever if somebody is actively writing to the file. imagine. 😭

so we do this in two main stages:

  1. first we copy dirty buffers to a temporary inode list, queueing the writes as we go.
  2. then we clean up, waiting for those writes to complete.

and here's the iconic safety detail: mark_buffer_dirty_inode doesn't touch b_assoc_buffers list if b_mmb is not NULL so we are sure the buffer stays on our list until I/O completes (at which point it can be reaped). slay. πŸ”₯


πŸ¦‹ SEE ALSO πŸ¦‹

kernel file ./fs/buffer.c β€” and honestly, the whole friend group: bio_endio_bh(9), end_buffer_read_sync(9), bh_end_read(9), bh_end_write(9), bh_end_async_write(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), clean_bdev_aliases(9), try_to_free_buffers(9), bh_uptodate_or_lock(9), __bh_read(9), __bh_read_batch(9)


ngl bestie, that's a lot of friends but they all ate. go read them too, periodt. πŸ‘‘

🌸 okay that's the whole page!! this one came from ./fs and it's dated October 2026, and it's the mmb_sync(9) page from the Kernel API Manual. mwah, go sync something, ily πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from