Page MenuHomeFreeBSD

Reduce use of O_SYNC in libutil
ClosedPublic

Authored by dwmalone on Feb 23 2016, 5:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 23, 4:13 AM
Unknown Object (File)
Sat, Jan 18, 5:51 AM
Unknown Object (File)
Fri, Jan 17, 11:46 PM
Unknown Object (File)
Dec 24 2024, 6:36 PM
Unknown Object (File)
Nov 25 2024, 6:26 PM
Unknown Object (File)
Nov 20 2024, 5:37 AM
Unknown Object (File)
Nov 20 2024, 4:24 AM
Unknown Object (File)
Nov 20 2024, 12:25 AM
Subscribers

Details

Summary

To follow on from D5186, I think this change should actually improve the chances of temporary copies of the group and password file making it to the disk, without using O_SYNC. The idea is to avoid opening with O_SYNC, but to call fsync() after data is written.

For the group file, this is relatively easy, as the file is only written by gr_tmp() and gr_copy(), so I call fsync() at the end of writing data in both of these.

For the password file, we have a third possibility, which is someone calls pw_edit. In this case we can't just call fsync() on the descriptor for the temp file because (1) it isn't accessible in pw_edit and (2) the editor might have replaced the file with a different file. Instead we briefly open the file, fsync() it and close it. This is the same strategy adopted by the fsync command line utility.

This change should actually improve the chances of the data winding up on the disk in the case where the editor doesn't edit the file in place, because the O_SYNC wouldn't have applied to the new file.

Diff Detail

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

Event Timeline

dwmalone retitled this revision from to Reduce use of O_SYNC in libutil.
dwmalone updated this object.
dwmalone edited the test plan for this revision. (Show Details)
dwmalone added reviewers: bapt, vangyzen, garga.
dwmalone set the repository for this revision to rS FreeBSD src repository - subversion.
bapt edited edge metadata.
This revision is now accepted and ready to land.Feb 29 2016, 7:33 PM
imp added a reviewer: imp.

A better solution was used in the end

Hi Bapt,

I don't think anything ever got committed to fix the overuse of O_SYNC that's addressed in this patch? There was a separate fabricator review for password db and mkcap problems.

David.