diff options
author | asomers <asomers@FreeBSD.org> | 2016-12-16 20:10:55 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2016-12-16 20:10:55 +0000 |
commit | 771f03f8a2c26a3126885f1dcd8321d191013ff4 (patch) | |
tree | a2ebb4b1eb6112556e9f126c005a277c317c47f6 /usr.sbin/pw/grupd.c | |
parent | f510da46a78eae2d3267ae1ea9be37877b0363cc (diff) | |
download | FreeBSD-src-771f03f8a2c26a3126885f1dcd8321d191013ff4.zip FreeBSD-src-771f03f8a2c26a3126885f1dcd8321d191013ff4.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 'usr.sbin/pw/grupd.c')
-rw-r--r-- | usr.sbin/pw/grupd.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c index 38d5e5b..5d0df02 100644 --- a/usr.sbin/pw/grupd.c +++ b/usr.sbin/pw/grupd.c @@ -77,6 +77,7 @@ gr_update(struct group * grp, char const * group) close(tfd); err(1, "gr_copy()"); } + fsync(tfd); close(tfd); if (gr_mkdb() == -1) { gr_fini(); |