From owner-svn-src-all@FreeBSD.ORG Sat Mar 28 06:25:33 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7684D1065670; Sat, 28 Mar 2009 06:25:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 64CEA8FC13; Sat, 28 Mar 2009 06:25:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2S6PXOM086854; Sat, 28 Mar 2009 06:25:33 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2S6PXKm086853; Sat, 28 Mar 2009 06:25:33 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200903280625.n2S6PXKm086853@svn.freebsd.org> From: Xin LI Date: Sat, 28 Mar 2009 06:25:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190490 - head/lib/libc/db/hash X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2009 06:25:33 -0000 Author: delphij Date: Sat Mar 28 06:25:33 2009 New Revision: 190490 URL: http://svn.freebsd.org/changeset/base/190490 Log: 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. Obtained from: NetBSD via OpenBSD Modified: head/lib/libc/db/hash/hash_page.c Modified: head/lib/libc/db/hash/hash_page.c ============================================================================== --- head/lib/libc/db/hash/hash_page.c Sat Mar 28 06:23:10 2009 (r190489) +++ head/lib/libc/db/hash/hash_page.c Sat Mar 28 06:25:33 2009 (r190490) @@ -404,17 +404,22 @@ __addel(HTAB *hashp, BUFHEAD *bufp, cons 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); @@ -431,6 +436,7 @@ __addel(HTAB *hashp, BUFHEAD *bufp, cons 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,