diff options
author | millert <millert@openbsd.org> | 2018-09-18 03:05:42 +0000 |
---|---|---|
committer | millert <millert@openbsd.org> | 2018-09-18 03:05:42 +0000 |
commit | ab9bceb9af3064c91be3599295ee0f2b3d91d0d0 (patch) | |
tree | 4e8e0005c2b6a5c74a77b249c3d6b8391772eea3 /usr.sbin/pwd_mkdb | |
parent | remove macros for xmalloc(), xcalloc() & xreallocarray() and just name the (diff) | |
download | wireguard-openbsd-ab9bceb9af3064c91be3599295ee0f2b3d91d0d0.tar.xz wireguard-openbsd-ab9bceb9af3064c91be3599295ee0f2b3d91d0d0.zip |
Account from the fact that we store ech entry three times when
estimating the number of hash table elements. Also set the bucket
size to be the optimal file system block size instead of hard-coding
to 4096. OK tb@
Diffstat (limited to 'usr.sbin/pwd_mkdb')
-rw-r--r-- | usr.sbin/pwd_mkdb/pwd_mkdb.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 35648a44721..37bc4c829cc 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pwd_mkdb.c,v 1.53 2015/11/05 15:10:11 semarie Exp $ */ +/* $OpenBSD: pwd_mkdb.c,v 1.54 2018/09/18 03:05:42 millert Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -188,8 +188,13 @@ main(int argc, char **argv) /* Tweak openinfo values for large passwd files. */ if (st.st_size > (off_t)100*1024) openinfo.cachesize = MINIMUM(st.st_size * 20, (off_t)12*1024*1024); - if (st.st_size / 128 > openinfo.nelem) - openinfo.nelem = st.st_size / 128; + /* Estimate number of elements based on a 128-byte average entry. */ + if (st.st_size / 128 * 3 > openinfo.nelem) + openinfo.nelem = st.st_size / 128 * 3; + + /* Use optimal filesystem block size. */ + if (st.st_blksize > openinfo.bsize) + openinfo.bsize = st.st_blksize; /* If only updating a single record, stash the old uid */ if (username) { |