freebsd-dev/usr.sbin/mountd
Rick Macklem 46a6b5c451 Replace a single linked list with a hash table of lists.
mountd.c uses a single linked list of "struct exportlist" structures,
where there is one of these for each exported file system on the NFS server.
This list gets long if there are a large number of file systems exported and
the list must be searched for each line in the exports file(s) when
SIGHUP causes the exports file(s) to be reloaded.
A simple benchmark that traverses SLIST() elements and compares two 32bit
fields in the structure for equal (which is what the search is)
appears to take a couple of nsec. So, for a server with 72000 exported file
systems, this can take about 5sec during reload of the exports file(s).
By replacing the single linked list with a hash table with a target of
10 elements per list, the time should be reduced to less than 1msec.
Peter Errikson (who has a server with 72000+ exported file systems) ran
a test program using 5 hashes to see how they worked.
fnv_32_buf(fsid,..., 0)
fnv_32_buf(fsid,..., FNV1_32_INIT)
hash32_buf(fsid,..., 0)
hash32_buf(fsid,..., HASHINIT)
- plus simply using the low order bits of fsid.val[0].
The first three behaved about equally well, with the first one being
slightly better than the others.
It has an average variation of about 4.5% about the target list length
and that is what this patch uses.
Peter Errikson also tested this hash table version and found that the
performance wasn't measurably improved by a larger hash table, so a
load factor of 10 appears adequate.

Tested by:	pen@lysator.liu.se (with other patches)
PR:		237860
MFC after:	1 month
2019-05-31 01:28:48 +00:00
..
exports.5 Bump .Dd for today's edit. 2019-02-11 16:31:15 +00:00
Makefile usr.sbin: normalize paths using SRCTOP-relative paths or :H when possible 2017-03-04 11:38:03 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
mountd.8 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
mountd.c Replace a single linked list with a hash table of lists. 2019-05-31 01:28:48 +00:00
netgroup.5 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
pathnames.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00