From owner-svn-src-head@FreeBSD.ORG Sat Mar 28 06:38:32 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FEEF106564A; Sat, 28 Mar 2009 06:38:32 +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 2DDD18FC0A; Sat, 28 Mar 2009 06:38:32 +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 n2S6cW93087235; Sat, 28 Mar 2009 06:38:32 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2S6cWhu087234; Sat, 28 Mar 2009 06:38:32 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200903280638.n2S6cWhu087234@svn.freebsd.org> From: Xin LI Date: Sat, 28 Mar 2009 06:38:32 +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: r190492 - head/lib/libc/db/hash X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2009 06:38:32 -0000 Author: delphij Date: Sat Mar 28 06:38:31 2009 New Revision: 190492 URL: http://svn.freebsd.org/changeset/base/190492 Log: - Avoid overwriting the cursor page when the cursor page becomes the LRU page. - Fix for sequential retrieval failure when using large key/data pairs. Obtained from: OpenBSD Modified: head/lib/libc/db/hash/hash_buf.c Modified: head/lib/libc/db/hash/hash_buf.c ============================================================================== --- head/lib/libc/db/hash/hash_buf.c Sat Mar 28 06:30:43 2009 (r190491) +++ head/lib/libc/db/hash/hash_buf.c Sat Mar 28 06:38:31 2009 (r190492) @@ -164,11 +164,31 @@ newbuf(HTAB *hashp, u_int32_t addr, BUFH oaddr = 0; bp = LRU; + + /* It is bad to overwrite the page under the cursor. */ + if (bp == hashp->cpage) { + BUF_REMOVE(bp); + MRU_INSERT(bp); + bp = LRU; + } + + /* If prev_bp is part of bp overflow, create a new buffer. */ + if (hashp->nbufs == 0 && prev_bp && bp->ovfl) { + BUFHEAD *ovfl; + + for (ovfl = bp->ovfl; ovfl ; ovfl = ovfl->ovfl) { + if (ovfl == prev_bp) { + hashp->nbufs++; + break; + } + } + } + /* * If LRU buffer is pinned, the buffer pool is too small. We need to * allocate more buffers. */ - if (hashp->nbufs || (bp->flags & BUF_PIN)) { + if (hashp->nbufs || (bp->flags & BUF_PIN) || bp == hashp->cpage) { /* Allocate a new one */ if ((bp = (BUFHEAD *)calloc(1, sizeof(BUFHEAD))) == NULL) return (NULL);