aboutsummaryrefslogtreecommitdiff
path: root/lib/libutil/pw_util.c
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2016-11-18 16:07:08 +0000
committerAlan Somers <asomers@FreeBSD.org>2016-11-18 16:07:08 +0000
commitcbaba16b23124331498f0a6d48a4d71f4f20b508 (patch)
tree229b54f5e1d98024a318d18cab53e0ea1469b9fc /lib/libutil/pw_util.c
parent34cd8ebdcfc8b88cfba92270f37e870dc00c47e8 (diff)
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
Notes
Notes: svn path=/head/; revision=308806
Diffstat (limited to 'lib/libutil/pw_util.c')
-rw-r--r--lib/libutil/pw_util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index 2838871d93f6..d7903281d7cc 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -225,7 +225,7 @@ pw_tmp(int mfd)
errno = ENAMETOOLONG;
return (-1);
}
- if ((tfd = mkostemp(tempname, O_SYNC)) == -1)
+ if ((tfd = mkostemp(tempname, 0)) == -1)
return (-1);
if (mfd != -1) {
while ((nr = read(mfd, buf, sizeof(buf))) > 0)