opr: Allow non-2^x for n_buckets in opr_cache_init 22/14122/3
authorAndrew Deason <adeason@sinenomine.net>
Mon, 30 Mar 2020 19:21:21 +0000 (14:21 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 10 Apr 2020 13:55:35 +0000 (09:55 -0400)
commit19524a49d4389bff6f7ba9d9c355489450579c01
treeb3befe0914afb4de23fc83f8483ba9ee31b6cc01
parent3db8c37e8ef6bea0f03ef6b8f82ed93d52937d7d
opr: Allow non-2^x for n_buckets in opr_cache_init

Currently, opr_cache_init requires that opts->n_buckets is a power of
2 (since our underlying opr_dict requires this). However, callers may
want to pick a number of buckets based on some other value. Requiring
each caller to calculate the nearest power-of-2 is annoying, so
instead just have opr_cache_init itself calculate a nearby power of 2.

That is, with this commit, opts->n_buckets is allowed to not be a
power of 2; when it's not a power of 2, opr_cache_init will calculate
the next highest power of 2 and use that as the number of buckets.

Change-Id: Icd3c56c1fe0733e3dac964ea9a98ff7b436254e6
Reviewed-on: https://gerrit.openafs.org/14122
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/opr/cache.c
tests/opr/cache-t.c