libc/db/hash: cap auto-tuned block size with a value that actually works

This fix mostly matters after r206129 that made it possible for
st_blksize to be greater than 4K.  For this reason, this change should
be MFC-ed before r206129.
Also, it seems that all FreeBSD uitlities that use db(3) hash databases
and create new databases in files, specify their own block size value
and thus do not depend on block size autotuning.

PR:		bin/144446
Submitted by:	Peter Jeremy <peterjeremy@acm.org>
MFC after:	5 days
This commit is contained in:
Andriy Gapon 2010-04-05 10:12:21 +00:00
parent 983419fe1e
commit f3c733e82b
2 changed files with 3 additions and 1 deletions

View File

@ -293,6 +293,8 @@ init_hash(HTAB *hashp, const char *file, const HASHINFO *info)
if (stat(file, &statbuf))
return (NULL);
hashp->BSIZE = statbuf.st_blksize;
if (hashp->BSIZE > MAX_BSIZE)
hashp->BSIZE = MAX_BSIZE;
hashp->BSHIFT = __log2(hashp->BSIZE);
}

View File

@ -118,7 +118,7 @@ typedef struct htab { /* Memory resident data structure */
/*
* Constants
*/
#define MAX_BSIZE 65536 /* 2^16 */
#define MAX_BSIZE 32768 /* 2^15 but should be 65536 */
#define MIN_BUFFERS 6
#define MINHDRSIZE 512
#define DEF_BUFSIZE 65536 /* 64 K */