diff options
author | asomers <asomers@FreeBSD.org> | 2016-12-16 20:49:50 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2016-12-16 20:49:50 +0000 |
commit | ce9e78822f045ebdeb7cf9f2185e2679e1959af0 (patch) | |
tree | 6c81ccd80c14d16e66de274bb59a74770de61a2b /lib/libutil/gr_util.c | |
parent | bad6a620da0682cbcda223b7ec0b7f2a097ebbd0 (diff) | |
download | FreeBSD-src-ce9e78822f045ebdeb7cf9f2185e2679e1959af0.zip FreeBSD-src-ce9e78822f045ebdeb7cf9f2185e2679e1959af0.tar.gz |
MFC r308806
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.
Diffstat (limited to 'lib/libutil/gr_util.c')
-rw-r--r-- | lib/libutil/gr_util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c index 93b3eb2..6153209 100644 --- a/lib/libutil/gr_util.c +++ b/lib/libutil/gr_util.c @@ -141,7 +141,7 @@ gr_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) |