Page MenuHomeFreeBSD

Add O_DSYNC support to open(2) and fcntl(2).
ClosedPublic

Authored by tmunro on Jun 1 2020, 3:39 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 2:10 PM
Unknown Object (File)
Feb 8 2024, 7:41 PM
Unknown Object (File)
Feb 8 2024, 7:41 PM
Unknown Object (File)
Feb 8 2024, 7:41 PM
Unknown Object (File)
Dec 20 2023, 2:43 AM
Unknown Object (File)
Dec 10 2023, 10:18 PM
Unknown Object (File)
Nov 16 2023, 6:20 AM
Unknown Object (File)
Nov 10 2023, 10:04 PM

Details

Summary

This is mostly the same as O_SYNC, but can potentially skip writing out stuff that isn't required for reading the data back.

From the point of view of a file system, this is reported as the new flag IO_DATASYNC passed to VOP_WRITE(), along with the existing IO_SYNC flag. That means that filesystems that don't know about IO_DATASYNC yet can keep on doing what they're doing, but those that understand IO_DATASYNC can modify their behaviour.

Once D25072 goes in, it should be possible to teach ffs_write() to understand IO_DATASYNC, to avoid unnecesssary inode write-back.

Also, fix up some related outdated comments and man pages: a claim that f_flag is a short (not true for a very long time), some missing flags and a typo in fcntl.2, and some language that makes O_SYNC seem like second fiddle to O_FSYNC, when IMHO it should now be the other way around.

Also, adjust the ZFS macro that redefines FDSYNC not to do that anymore. Even though with this patch it becomes a value distinct from FFSYNC, that's OK because zfs_vnops.c, zfs_log.c, zvol.c, vdev_file.c always test for (FSYNC | FDSYNC) anwyay.

A separate patch will add O_DSYNC support for aio_fsync(2), see D25071.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tmunro requested review of this revision.Jun 1 2020, 3:39 AM

Two simple fixes for the man page.

lib/libc/sys/fcntl.2
229

A line break is needed after a sentence stop.

237

Another line break here after the sentence stop.

tmunro added reviewers: kib, mjg.
tmunro marked 2 inline comments as done.

Thanks! Fixed.

lib/libc/sys/open.2
243

... all data and metadata required to read the data back will be ...

sys/kern/vfs_vnops.c
1070

... instead set IO_SYNC | IO_DATASYNC there.

1071

I suggest to not change this condition...

tmunro marked 3 inline comments as done.
kib added inline comments.
lib/libc/sys/open.2
659

BTW I see no reason to not merge this to 12.

This revision is now accepted and ready to land.Jun 2 2020, 11:35 AM

Rebased (mostly: ZFS moved).

This revision now requires review to proceed.Jan 6 2021, 11:42 AM
This revision is now accepted and ready to land.Jan 6 2021, 5:18 PM
This revision was automatically updated to reflect the committed changes.