From owner-svn-src-all@FreeBSD.ORG Sun May 17 23:25:53 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 99D1F106566B; Sun, 17 May 2009 23:25:53 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8735E8FC19; Sun, 17 May 2009 23:25:53 +0000 (UTC) (envelope-from alc@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 n4HNPr7W042701; Sun, 17 May 2009 23:25:53 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4HNPrXD042700; Sun, 17 May 2009 23:25:53 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200905172325.n4HNPrXD042700@svn.freebsd.org> From: Alan Cox Date: Sun, 17 May 2009 23:25:53 +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: r192270 - 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: Sun, 17 May 2009 23:25:54 -0000 Author: alc Date: Sun May 17 23:25:53 2009 New Revision: 192270 URL: http://svn.freebsd.org/changeset/base/192270 Log: Several changes to vfs_bio_clrbuf(): Provide a more descriptive comment. Eliminate dead code. The page cannot possibly have PG_ZERO set. Eliminate unnecessary blank lines. Reviewed by: tegge Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Sun May 17 23:17:56 2009 (r192269) +++ head/sys/kern/vfs_bio.c Sun May 17 23:25:53 2009 (r192270) @@ -3706,24 +3706,25 @@ vfs_bio_set_validclean(struct buf *bp, i /* * vfs_bio_clrbuf: * - * clear a buffer. This routine essentially fakes an I/O, so we need - * to clear BIO_ERROR and B_INVAL. + * If the specified buffer is a non-VMIO buffer, clear the entire + * buffer. If the specified buffer is a VMIO buffer, clear and + * validate only the previously invalid portions of the buffer. + * This routine essentially fakes an I/O, so we need to clear + * BIO_ERROR and B_INVAL. * * Note that while we only theoretically need to clear through b_bcount, * we go ahead and clear through b_bufsize. */ - void vfs_bio_clrbuf(struct buf *bp) { - int i, j, mask = 0; + int i, j, mask; caddr_t sa, ea; if ((bp->b_flags & (B_VMIO | B_MALLOC)) != B_VMIO) { clrbuf(bp); return; } - bp->b_flags &= ~B_INVAL; bp->b_ioflags &= ~BIO_ERROR; VM_OBJECT_LOCK(bp->b_bufobj->bo_object); @@ -3735,8 +3736,7 @@ vfs_bio_clrbuf(struct buf *bp) VM_OBJECT_LOCK_ASSERT(bp->b_pages[0]->object, MA_OWNED); if ((bp->b_pages[0]->valid & mask) == mask) goto unlock; - if (((bp->b_pages[0]->flags & PG_ZERO) == 0) && - ((bp->b_pages[0]->valid & mask) == 0)) { + if ((bp->b_pages[0]->valid & mask) == 0) { bzero(bp->b_data, bp->b_bufsize); bp->b_pages[0]->valid |= mask; goto unlock; @@ -3755,13 +3755,11 @@ vfs_bio_clrbuf(struct buf *bp) VM_OBJECT_LOCK_ASSERT(bp->b_pages[i]->object, MA_OWNED); if ((bp->b_pages[i]->valid & mask) == mask) continue; - if ((bp->b_pages[i]->valid & mask) == 0) { - if ((bp->b_pages[i]->flags & PG_ZERO) == 0) - bzero(sa, ea - sa); - } else { + if ((bp->b_pages[i]->valid & mask) == 0) + bzero(sa, ea - sa); + else { for (; sa < ea; sa += DEV_BSIZE, j++) { - if (((bp->b_pages[i]->flags & PG_ZERO) == 0) && - (bp->b_pages[i]->valid & (1 << j)) == 0) + if ((bp->b_pages[i]->valid & (1 << j)) == 0) bzero(sa, DEV_BSIZE); } }