Following revision r295924, the changes to a db file should be fsynced

before the file is closed. Consequently, it shouldn't be necessary to
open the file with O_SYNC any more.

This improves the performance of building large .db files for large
password files a lot and should resolve this problem:

	https://forums.freebsd.org/threads/10-2-pre-pwd_mkdb-slow-on-larger-master-passwd.52700/

Differential Revision:	https://reviews.freebsd.org/D5186
Reviewed by:	garga, vangyzen, bapt, se
MFC after:	1 week
This commit is contained in:
David Malone 2016-02-23 15:28:13 +00:00
parent efb7dae251
commit 95bcaf513b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295925

View file

@ -228,14 +228,14 @@ main(int argc, char *argv[])
clean = FILE_INSECURE;
cp(buf2, buf, PERM_INSECURE);
dp = dbopen(buf,
O_RDWR|O_EXCL|O_SYNC, PERM_INSECURE, DB_HASH, &openinfo);
O_RDWR|O_EXCL, PERM_INSECURE, DB_HASH, &openinfo);
if (dp == NULL)
error(buf);
clean = FILE_SECURE;
cp(sbuf2, sbuf, PERM_SECURE);
sdp = dbopen(sbuf,
O_RDWR|O_EXCL|O_SYNC, PERM_SECURE, DB_HASH, &openinfo);
O_RDWR|O_EXCL, PERM_SECURE, DB_HASH, &openinfo);
if (sdp == NULL)
error(sbuf);
@ -292,13 +292,13 @@ main(int argc, char *argv[])
method = 0;
} else {
dp = dbopen(buf,
O_RDWR|O_CREAT|O_EXCL|O_SYNC, PERM_INSECURE, DB_HASH, &openinfo);
O_RDWR|O_CREAT|O_EXCL, PERM_INSECURE, DB_HASH, &openinfo);
if (dp == NULL)
error(buf);
clean = FILE_INSECURE;
sdp = dbopen(sbuf,
O_RDWR|O_CREAT|O_EXCL|O_SYNC, PERM_SECURE, DB_HASH, &openinfo);
O_RDWR|O_CREAT|O_EXCL, PERM_SECURE, DB_HASH, &openinfo);
if (sdp == NULL)
error(sbuf);
clean = FILE_SECURE;