From owner-svn-src-all@FreeBSD.ORG Tue Mar 17 16:30:49 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 E60951065676; Tue, 17 Mar 2009 16:30:49 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D344F8FC12; Tue, 17 Mar 2009 16:30:49 +0000 (UTC) (envelope-from attilio@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 n2HGUnsw099800; Tue, 17 Mar 2009 16:30:49 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2HGUnPP099799; Tue, 17 Mar 2009 16:30:49 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200903171630.n2HGUnPP099799@svn.freebsd.org> From: Attilio Rao Date: Tue, 17 Mar 2009 16:30:49 +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: r189933 - head/sys/kern 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: Tue, 17 Mar 2009 16:30:50 -0000 Author: attilio Date: Tue Mar 17 16:30:49 2009 New Revision: 189933 URL: http://svn.freebsd.org/changeset/base/189933 Log: Fix an old-standing bug that crept in along the several revisions: B_DELWRI cleanup and vnode disassociation should happen just before to assign the buffer to a queue. Reported by: miwi, Volker , Ben Kaduk , Christopher Mallon Tested by: lulf, miwi Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Tue Mar 17 14:53:42 2009 (r189932) +++ head/sys/kern/vfs_bio.c Tue Mar 17 16:30:49 2009 (r189933) @@ -1369,9 +1369,23 @@ brelse(struct buf *bp) if (bp->b_qindex != QUEUE_NONE) panic("brelse: free buffer onto another queue???"); + /* + * If the buffer has junk contents signal it and eventually + * clean up B_DELWRI and diassociate the vnode so that gbincore() + * doesn't find it. + */ + if (bp->b_bufsize == 0 || (bp->b_ioflags & BIO_ERROR) != 0 || + (bp->b_flags & (B_INVAL | B_NOCACHE | B_RELBUF)) != 0) + bp->b_flags |= B_INVAL; + if (bp->b_flags & B_INVAL) { + if (bp->b_flags & B_DELWRI) + bundirty(bp); + if (bp->b_vp) + brelvp(bp); + } + /* buffers with no memory */ if (bp->b_bufsize == 0) { - bp->b_flags |= B_INVAL; bp->b_xflags &= ~(BX_BKGRDWRITE | BX_ALTDATA); if (bp->b_vflags & BV_BKGRDINPROG) panic("losing buffer 1"); @@ -1384,7 +1398,6 @@ brelse(struct buf *bp) /* buffers with junk contents */ } else if (bp->b_flags & (B_INVAL | B_NOCACHE | B_RELBUF) || (bp->b_ioflags & BIO_ERROR)) { - bp->b_flags |= B_INVAL; bp->b_xflags &= ~(BX_BKGRDWRITE | BX_ALTDATA); if (bp->b_vflags & BV_BKGRDINPROG) panic("losing buffer 2"); @@ -1407,19 +1420,6 @@ brelse(struct buf *bp) mtx_unlock(&bqlock); /* - * If B_INVAL and B_DELWRI is set, clear B_DELWRI. We have already - * placed the buffer on the correct queue. We must also disassociate - * the device and vnode for a B_INVAL buffer so gbincore() doesn't - * find it. - */ - if (bp->b_flags & B_INVAL) { - if (bp->b_flags & B_DELWRI) - bundirty(bp); - if (bp->b_vp) - brelvp(bp); - } - - /* * Fixup numfreebuffers count. The bp is on an appropriate queue * unless locked. We then bump numfreebuffers if it is not B_DELWRI. * We've already handled the B_INVAL case ( B_DELWRI will be clear