VOP_FSYNC(9)
β¨ VOP_FSYNC β flush file system buffers for a file β¨
okay bestie, welcome to the Kernel Developer's Manual, section 9 π this one's about VOP_FDATASYNC and VOP_FSYNC, and no cap, it's giving "make sure your data is actually, for real, on the disk" energy πΎβ¨
πΈ SYNOPSIS πΈ
#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 π
so VOP_FSYNC() is the icon that makes sure a file can be recovered to its current state after a crash π like if the power just dips and everything's chaos, this is what saves you. that typically means flushing the file's dirty buffers, its inode, and possibly other filesystem metadata out to persistent media π«Ά
and the way it's used? it's literally the implementation behind the sync(2) and fsync(2) system calls. main character behaviour fr fr π
its arguments are:
vpβ the vnode of the file π¦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 π§΅
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 that 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. no shortcuts bestie. and it's used to implement fdatasync(2) π
π LOCKS π
the vnode should be exclusively locked on entry, and it stays locked on return. yes, it walks in holding the lock and it walks out holding the lock. consistent queen π
β RETURN VALUES β
zero is returned if the call is successful π otherwise an appropriate error code is returned π
π ERRORS π
[ENOSPC]β the file system is full. it's giving "no room, babe" π[EDQUOT]β quota exceeded. you ate too much, respectfully π
π SEE ALSO π
π AUTHORS π
this manual page was written by Doug Rabson. thank you for your service king π«‘β¨
lowkey if you're poking at vnodes at 3am, hydrate, lock exclusively, and remember: MNT_WAIT is your friend π
this was the VOP_FSYNC(9) page from the Debian edition of the Kernel Developer's Manual, dated March 22, 2019 πΈ slay, stay synced, periodt π
π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1996 Doug Rabson
- Copyright (c) 2019 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms