Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Feb 2011 10:20:32 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r218164 - stable/8/sys/kern
Message-ID:  <201102011020.p11AKWqS068218@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Feb  1 10:20:31 2011
New Revision: 218164
URL: http://svn.freebsd.org/changeset/base/218164

Log:
  MFC r217824:
  When vtruncbuf() iterates over the vnode buffer list, lock buffer object
  before checking the validity of the next buffer pointer. Otherwise, the
  buffer might be reclaimed after the check, causing iteration to run into
  wrong buffer.

Modified:
  stable/8/sys/kern/vfs_subr.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/kern/vfs_subr.c
==============================================================================
--- stable/8/sys/kern/vfs_subr.c	Tue Feb  1 10:18:36 2011	(r218163)
+++ stable/8/sys/kern/vfs_subr.c	Tue Feb  1 10:20:31 2011	(r218164)
@@ -1340,13 +1340,14 @@ restart:
 			brelse(bp);
 			anyfreed = 1;
 
+			BO_LOCK(bo);
 			if (nbp != NULL &&
 			    (((nbp->b_xflags & BX_VNCLEAN) == 0) ||
 			    (nbp->b_vp != vp) ||
 			    (nbp->b_flags & B_DELWRI))) {
+				BO_UNLOCK(bo);
 				goto restart;
 			}
-			BO_LOCK(bo);
 		}
 
 		TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) {
@@ -1363,13 +1364,15 @@ restart:
 			bp->b_flags &= ~B_ASYNC;
 			brelse(bp);
 			anyfreed = 1;
+
+			BO_LOCK(bo);
 			if (nbp != NULL &&
 			    (((nbp->b_xflags & BX_VNDIRTY) == 0) ||
 			    (nbp->b_vp != vp) ||
 			    (nbp->b_flags & B_DELWRI) == 0)) {
+				BO_UNLOCK(bo);
 				goto restart;
 			}
-			BO_LOCK(bo);
 		}
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102011020.p11AKWqS068218>