diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-02-01 18:18:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-02-01 18:18:09 +0000 |
commit | a11a0fe9cc20035ea8df2f93542de8798d4ea4e5 (patch) | |
tree | 75740a62ed365b299b34aeabaa5d91b9ba8c0083 | |
parent | c86cf8907b0f26154e75c86e6873239fcebee5ba (diff) |
Only squeeze a short key/value pair onto a page with other complete key/value
pairs, not onto a page containing the end of a big pair; mycroft@netbsd.org
-rw-r--r-- | lib/libc/db/hash/hash_page.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index 1e9a66c9f0a..7a01277657e 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash_page.c,v 1.9 2002/02/01 18:17:36 millert Exp $ */ +/* $OpenBSD: hash_page.c,v 1.10 2002/02/01 18:18:08 millert Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; #else -static char rcsid[] = "$OpenBSD: hash_page.c,v 1.9 2002/02/01 18:17:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: hash_page.c,v 1.10 2002/02/01 18:18:08 millert Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -423,17 +423,22 @@ __addel(hashp, bufp, key, val) if (!bufp) return (-1); bp = (u_int16_t *)bufp->page; - } else + } else if (bp[bp[0]] != OVFLPAGE) { + /* Short key/data pairs, no more pages */ + break; + } else { /* Try to squeeze key on this page */ - if (FREESPACE(bp) > PAIRSIZE(key, val)) { + if (bp[2] >= REAL_KEY && + FREESPACE(bp) >= PAIRSIZE(key, val)) { squeeze_key(bp, key, val); - return (0); + goto stats; } else { bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); if (!bufp) return (-1); bp = (u_int16_t *)bufp->page; } + } if (PAIRFITS(bp, key, val)) putpair(bufp->page, key, val); @@ -450,6 +455,7 @@ __addel(hashp, bufp, key, val) if (__big_insert(hashp, bufp, key, val)) return (-1); } +stats: bufp->flags |= BUF_MOD; /* * If the average number of keys per bucket exceeds the fill factor, |