VOP_FSYNC(9)

NAME
VOP_FDATASYNC, VOP_FSYNC - flush filesystem buffers for a file

SYNOPSIS
#include <sys/param.h>
#include <sys/vnode.h>
int
VOP_FDATASYNC(struct vnode *vp, int waitfor, int flags);
int
VOP_FSYNC(struct vnode *vp, int waitfor, int flags);

DESCRIPTION
This call flushes any dirty filesystem buffers for the file. It is used to implement the sync(2) and fsync(2) system calls.

Its arguments are:

vp  the vnode of the file.

waitfor
    whether the function should do data, meta-data updates or be full-synchronous.

flags
    are additional flags to be passed to the filesystem specific fsync(2) function.

The argument waitfor can use the following flags:

MNT_NOWAIT
    is for an asynchronous data pass and a meta-data pass as well.

MNT_LAZY
    means a limited amount of data from dirty buffers and a full meta-data synchronization pass.

MNT_WAIT
    will make syncer(4) try to do a full synchronization pass. That is, a meta-data pass and multiple data passes.

The argument flags is to specify additional flags passed to the filesystem specific fsync(2) call. The only supported flag at the moment is VOP_FSYNC_SYSCALL which indicates the file synchronization was requested from userland.

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. VOP_FDATASYNC() is used to implement fdatasync(2).

RETURN VALUES
Zero is returned if the call is successful, otherwise an appropriate error code is returned.

ERRORS

[ENOSPC]
    The filesystem is full.

[EDQUOT]
    Quota exceeded.

SEE ALSO
syncer(4), vnode(9)

AUTHORS
This man page was written by Doug Rabson.