diff options
author | Alan Somers <asomers@FreeBSD.org> | 2016-11-18 16:07:08 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2016-11-18 16:07:08 +0000 |
commit | e1c14b0cd9c2d6edd97517368ab16647191b4429 (patch) | |
tree | 3555d5daed444f6a29100f360049a9d813fc9f2b /pw/pw_nis.c | |
parent | b740a3ee5598c5dd5baf65ca8dfec07737ec3e70 (diff) | |
download | pw-darwin-e1c14b0cd9c2d6edd97517368ab16647191b4429.tar.gz pw-darwin-e1c14b0cd9c2d6edd97517368ab16647191b4429.tar.zst pw-darwin-e1c14b0cd9c2d6edd97517368ab16647191b4429.zip |
Speed up pw operations that edit /etc/group or /etc/passwd
r285050 fixed a bug in pw that could lead to /etc/passwd or /etc/group
corruption on power loss. However, it fixed it by opening those files with
O_SYNC, which is very slow, especially on ZFS. This change replaces O_SYNC
with appropriately placed fsync()s instead, which is much faster. Using a
ZFS tmpdir, the time to run pw's kyua tests drops from 245s to 35s.
Reviewed by: allanjude, bapt, vangyzen, garga
Tested on pfSense by: garga
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D8319
Diffstat (limited to 'pw/pw_nis.c')
-rw-r--r-- | pw/pw_nis.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/pw/pw_nis.c b/pw/pw_nis.c index 35b26ea..087c946 100644 --- a/pw/pw_nis.c +++ b/pw/pw_nis.c @@ -67,6 +67,7 @@ pw_nisupdate(const char * path, struct passwd * pwd, char const * user) close(tfd); err(1, "pw_copy()"); } + fsync(tfd); close(tfd); if (chmod(pw_tempname(), 0644) == -1) err(1, "chmod()"); |