From owner-svn-src-stable-7@FreeBSD.ORG Wed Sep 15 15:33:51 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E76631065670; Wed, 15 Sep 2010 15:33:51 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D6AE78FC15; Wed, 15 Sep 2010 15:33:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8FFXpO3040840; Wed, 15 Sep 2010 15:33:51 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8FFXpQS040837; Wed, 15 Sep 2010 15:33:51 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201009151533.o8FFXpQS040837@svn.freebsd.org> From: Matthew D Fleming Date: Wed, 15 Sep 2010 15:33:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212664 - in stable/7/sys: kern sys X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2010 15:33:52 -0000 Author: mdf Date: Wed Sep 15 15:33:51 2010 New Revision: 212664 URL: http://svn.freebsd.org/changeset/base/212664 Log: Revert r212563, which was a MFC of r209053, as it introduced an unlocked read/modify/write of b_vflags. The unlocked access is fixed in CURRENT and stable/8 by r211213 and its MFC, r212583. Rather than MFC to stable/7, reverting the injecting code seems preferable. Modified: stable/7/sys/kern/vfs_bio.c stable/7/sys/sys/buf.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_bio.c ============================================================================== --- stable/7/sys/kern/vfs_bio.c Wed Sep 15 15:18:41 2010 (r212663) +++ stable/7/sys/kern/vfs_bio.c Wed Sep 15 15:33:51 2010 (r212664) @@ -381,16 +381,10 @@ runningbufwakeup(struct buf *bp) */ static __inline void -bufcountwakeup(struct buf *bp) +bufcountwakeup(void) { - int old; - KASSERT((bp->b_vflags & BV_INFREECNT) == 0, - ("buf %p already counted as free", bp)); - bp->b_vflags |= BV_INFREECNT; - old = atomic_fetchadd_int(&numfreebuffers, 1); - KASSERT(old >= 0 && old < nbuf, - ("numfreebuffers climbed to %d", old + 1)); + atomic_add_int(&numfreebuffers, 1); mtx_lock(&nblock); if (needsbuffer) { needsbuffer &= ~VFS_BIO_NEED_ANY; @@ -593,7 +587,7 @@ bufinit(void) bp->b_rcred = NOCRED; bp->b_wcred = NOCRED; bp->b_qindex = QUEUE_EMPTY; - bp->b_vflags = BV_INFREECNT; /* buf is counted as free */ + bp->b_vflags = 0; bp->b_xflags = 0; LIST_INIT(&bp->b_dep); BUF_LOCKINIT(bp); @@ -694,7 +688,6 @@ bfreekva(struct buf *bp) void bremfree(struct buf *bp) { - int old; CTR3(KTR_BUF, "bremfree(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(BUF_REFCNT(bp), ("bremfree: buf must be locked.")); @@ -705,13 +698,8 @@ bremfree(struct buf *bp) bp->b_flags |= B_REMFREE; /* Fixup numfreebuffers count. */ - if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) { - KASSERT((bp->b_vflags & BV_INFREECNT) != 0, - ("buf %p not counted in numfreebuffers", bp)); - bp->b_vflags &= ~BV_INFREECNT; - old = atomic_fetchadd_int(&numfreebuffers, -1); - KASSERT(old > 0, ("numfreebuffers dropped to %d", old - 1)); - } + if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) + atomic_subtract_int(&numfreebuffers, 1); } /* @@ -737,8 +725,6 @@ bremfreef(struct buf *bp) static void bremfreel(struct buf *bp) { - int old; - CTR3(KTR_BUF, "bremfreel(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(BUF_REFCNT(bp), ("bremfreel: buffer %p not locked.", bp)); @@ -761,13 +747,8 @@ bremfreel(struct buf *bp) * delayed-write, the buffer was free and we must decrement * numfreebuffers. */ - if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) { - KASSERT((bp->b_vflags & BV_INFREECNT) != 0, - ("buf %p not counted in numfreebuffers", bp)); - bp->b_vflags &= ~BV_INFREECNT; - old = atomic_fetchadd_int(&numfreebuffers, -1); - KASSERT(old > 0, ("numfreebuffers dropped to %d", old - 1)); - } + if ((bp->b_flags & B_INVAL) || (bp->b_flags & B_DELWRI) == 0) + atomic_subtract_int(&numfreebuffers, 1); } @@ -1471,7 +1452,7 @@ brelse(struct buf *bp) */ if (!(bp->b_flags & B_DELWRI)) - bufcountwakeup(bp); + bufcountwakeup(); /* * Something we can maybe free or reuse @@ -1561,7 +1542,7 @@ bqrelse(struct buf *bp) mtx_unlock(&bqlock); if ((bp->b_flags & B_INVAL) || !(bp->b_flags & B_DELWRI)) - bufcountwakeup(bp); + bufcountwakeup(); /* * Something we can maybe free or reuse. @@ -1941,8 +1922,6 @@ restart: bp->b_flags = 0; bp->b_ioflags = 0; bp->b_xflags = 0; - KASSERT((bp->b_vflags & BV_INFREECNT) == 0, - ("buf %p still counted as free?", bp)); bp->b_vflags = 0; bp->b_vp = NULL; bp->b_blkno = bp->b_lblkno = 0; @@ -4104,27 +4083,4 @@ DB_SHOW_COMMAND(vnodebufs, db_show_vnode db_printf("\n"); } } - -DB_COMMAND(countfreebufs, db_coundfreebufs) -{ - struct buf *bp; - int i, used = 0, nfree = 0; - - if (have_addr) { - db_printf("usage: countfreebufs\n"); - return; - } - - for (i = 0; i < nbuf; i++) { - bp = &buf[i]; - if ((bp->b_vflags & BV_INFREECNT) != 0) - nfree++; - else - used++; - } - - db_printf("Counted %d free, %d used (%d tot)\n", nfree, used, - nfree + used); - db_printf("numfreebuffers is %d\n", numfreebuffers); -} #endif /* DDB */ Modified: stable/7/sys/sys/buf.h ============================================================================== --- stable/7/sys/sys/buf.h Wed Sep 15 15:18:41 2010 (r212663) +++ stable/7/sys/sys/buf.h Wed Sep 15 15:33:51 2010 (r212664) @@ -247,7 +247,6 @@ struct buf { #define BV_SCANNED 0x00000001 /* VOP_FSYNC funcs mark written bufs */ #define BV_BKGRDINPROG 0x00000002 /* Background write in progress */ #define BV_BKGRDWAIT 0x00000004 /* Background write waiting */ -#define BV_INFREECNT 0x80000000 /* buf is counted in numfreebufs */ #ifdef _KERNEL /*