Page MenuHomeFreeBSD

First stage of implementing fdatasync(2).
ClosedPublic

Authored by kib on Aug 11 2016, 8:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 8:55 PM
Unknown Object (File)
Wed, Mar 20, 5:22 AM
Unknown Object (File)
Mar 11 2024, 9:17 AM
Unknown Object (File)
Mar 11 2024, 9:16 AM
Unknown Object (File)
Mar 11 2024, 9:16 AM
Unknown Object (File)
Mar 11 2024, 9:16 AM
Unknown Object (File)
Mar 7 2024, 11:10 PM
Unknown Object (File)
Mar 7 2024, 3:06 PM
Subscribers

Details

Summary

The patch implements fdatasync(2) syscall, which purpose is to request flushing of user data for given file to disk. Difference with fsync(2) is that metadata flush is not required.

The implementation provides non-trivial and believed to be correct VOPs for UFS and msdosfs. For all other filesystems, VOP_FDATASYNC() redirects to VOP_FSYNC(), which should be functionally, but not performance-wise, correct. I believe that ZFS has some code which just needs to be called from VOP to get the implementation as well, but I do not know how.

Still, this is not a complete implementation of the POSIX requirements, because SUSv7 contains the following language:

The fdatasync( ) function shall force all currently queued I/O operations associated with the file
indicated by file descriptor fildes to the synchronized I/O completion state.

I believe that the statement requires OS to complete all queued AIO requests before fdatasync(2) returns. This is not done, the code for the syscall contains placeholder. Still, I think it is useful first step, and right now I am concerned with the correctness of UFS implementation rather then AIO bits.

Test Plan

This was tested by Peter Holm, including specific tests for fdatasync(2).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib retitled this revision from to First stage of implementing fdatasync(2)..
kib updated this object.
kib edited the test plan for this revision. (Show Details)
kib added reviewers: jhb, mckusick, trasz, emaste, avg.
kib set the repository for this revision to rS FreeBSD src repository - subversion.
kib added a subscriber: pho.

Regarding ZFS, as far as I know, it does not make any distinction between metadata and data operations when it creates ZIL records. And sync commits all ZIL records related to a file to disk. That's how fsync is implemented. So, I do not see any easy way to implement fdatasync that would do a subset of what fsync does.

kib edited edge metadata.

Update after private Kirk' notes:

  • invert the flag to kern_fsync().
  • change order of the then/else statements in still_dirty calculation in ffs_syncvnode().
  • consider fdatasync() done if only indirect metadata blocks are left on dirty buffer queue.
mckusick edited edge metadata.

I am in agreement with the latest proposed change and am ready to have it committed.

This revision is now accepted and ready to land.Aug 15 2016, 4:22 AM
This revision was automatically updated to reflect the committed changes.