VOP_FSYNC(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… VOP_FSYNC(9) πŸ’…

okay so bestie, this is the Kernel Developer's Manual page for VOP_FSYNC(9), and it’s literally about flushing file system buffers for a file. it’s giving β€œmake sure your crash recovery is cute” energy, no cap. πŸ’–


🌸 NAME 🌸

VOP_FDATASYNC, VOP_FSYNC β€” flush file system buffers for a file ✨

✨ SYNOPSIS ✨

bestie, here’s the exact shape of it:

#include <sys/param.h>
#include <sys/vnode.h>

int
VOP_FDATASYNC(struct vnode *vp, struct thread *td);

int
VOP_FSYNC(struct vnode *vp, int waitfor, struct thread *td);

πŸ’– DESCRIPTION πŸ’–

VOP_FSYNC() makes sure a file can be recovered to its current state following a crash. that typically means flushing the file’s dirty buffers, its inode, and possibly other filesystem metadata to persistent media. VOP_FSYNC() is used to implement the sync(2) and fsync(2) system calls. slay.

Its arguments are:

  • vp β€” the vnode of the file. iconic.
  • waitfor β€” whether the function should wait for I/O to complete. possible values are:
    • MNT_WAIT β€” synchronously wait for I/O to complete.
    • MNT_NOWAIT β€” start all I/O, but do not wait for it.
    • MNT_LAZY β€” push data not written by file system syncer.
  • td β€” the calling thread. hi bestie πŸ‘‹

VOP_FDATASYNC() is similar, but it does not require that all of the file’s metadata be flushed. it only requires that the file’s data be recoverable after a crash. that implies the data itself must be flushed to disk, as well as some metadata such as the file’s size but not necessarily its attributes. VOP_FDATASYNC() should always wait for I/O to complete, as if called with MNT_WAIT. VOP_FDATASYNC() is used to implement fdatasync(2). periodt. πŸ’…

πŸ”’ LOCKS πŸ”’

the vnode should be exclusively locked on entry, and it stays locked on return. no sneaky unlocking, bestie β€” that’s the rule. πŸ”

πŸŽ€ RETURN VALUES πŸŽ€

Zero is returned if the call is successful; otherwise an appropriate error code is returned. that’s it, that’s the vibe check. βœ…

🚨 ERRORS 🚨

  • [ENOSPC] β€” The file system is full. 😭
  • [EDQUOT] β€” Quota exceeded. πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

  • vnode(9) β€” go read that one too, iykyk. πŸ¦‹

🫢 AUTHORS 🫢

This manual page was written by Doug Rabson. shoutout, king. πŸ‘‘


okay that’s the whole page, bestie! this one is from Debian, dated March 22, 2019, and it’s the VOP_FSYNC(9) manual page. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from