HomeFreeBSD

UFS: write inode block for fdatasync(2) if pointers in inode where allocated

Description

UFS: write inode block for fdatasync(2) if pointers in inode where allocated

The fdatasync() description in POSIX specifies that

all I/O operations shall be completed as defined for synchronized I/O
data integrity completion.

and then the explanation of Synchronized I/O Data Integrity Completion says

The write is complete only when the data specified in the write
request is successfully transferred and all file system
information required to retrieve the data is successfully
transferred.

For UFS this means that all pointers must be on disk. Indirect
pointers already contribute to the list of dirty data blocks, so only
direct blocks and root pointers to indirect blocks, both of which
reside in the inode block, should be taken care of. In ffs_balloc(),
mark the inode with the new flag IN_IBLKDATA that specifies that
ffs_syncvnode(DATA_ONLY) needs a call to ffs_update() to flush the
inode block.

Reviewed by: mckusick
Discussed with: tmunro
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25072