Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jan 2016 14:48:40 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r293197 - head/sys/kern
Message-ID:  <201601051448.u05Eme83057405@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Jan  5 14:48:40 2016
New Revision: 293197
URL: https://svnweb.freebsd.org/changeset/base/293197

Log:
  Two fixes for excessive iterations after r292326.
  
  Advance the logical block number to the lblkno of the found block plus
  one, instead of incrementing the block number which was used for
  lookup.  This change skips sparcely populated buffer ranges, similar
  to r292325, instead of doing useless lookups.
  
  Do not restart the bnoreuselist() from the start of the range if
  buffer lock cannot be obtained without sleep.  Only retry lookup and
  lock for the same queue and same logical block number.
  
  Reported by:	benno
  Tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 days

Modified:
  head/sys/kern/vfs_default.c
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_default.c
==============================================================================
--- head/sys/kern/vfs_default.c	Tue Jan  5 14:21:02 2016	(r293196)
+++ head/sys/kern/vfs_default.c	Tue Jan  5 14:48:40 2016	(r293197)
@@ -1080,15 +1080,9 @@ vop_stdadvise(struct vop_advise_args *ap
 		bsize = vp->v_bufobj.bo_bsize;
 		startn = ap->a_start / bsize;
 		endn = ap->a_end / bsize;
-		for (;;) {
-			error = bnoreuselist(&bo->bo_clean, bo, startn, endn);
-			if (error == EAGAIN)
-				continue;
+		error = bnoreuselist(&bo->bo_clean, bo, startn, endn);
+		if (error == 0)
 			error = bnoreuselist(&bo->bo_dirty, bo, startn, endn);
-			if (error == EAGAIN)
-				continue;
-			break;
-		}
 		BO_RUNLOCK(bo);
 		VOP_UNLOCK(vp, 0);
 		break;

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Tue Jan  5 14:21:02 2016	(r293196)
+++ head/sys/kern/vfs_subr.c	Tue Jan  5 14:48:40 2016	(r293197)
@@ -1669,7 +1669,8 @@ bnoreuselist(struct bufv *bufv, struct b
 
 	ASSERT_BO_LOCKED(bo);
 
-	for (lblkno = startn;; lblkno++) {
+	for (lblkno = startn;;) {
+again:
 		bp = BUF_PCTRIE_LOOKUP_GE(&bufv->bv_root, lblkno);
 		if (bp == NULL || bp->b_lblkno >= endn)
 			break;
@@ -1677,11 +1678,14 @@ bnoreuselist(struct bufv *bufv, struct b
 		    LK_INTERLOCK, BO_LOCKPTR(bo), "brlsfl", 0, 0);
 		if (error != 0) {
 			BO_RLOCK(bo);
-			return (error != ENOLCK ? error : EAGAIN);
+			if (error == ENOLCK)
+				goto again;
+			return (error);
 		}
 		KASSERT(bp->b_bufobj == bo,
 		    ("bp %p wrong b_bufobj %p should be %p",
 		    bp, bp->b_bufobj, bo));
+		lblkno = bp->b_lblkno + 1;
 		if ((bp->b_flags & B_MANAGED) == 0)
 			bremfree(bp);
 		bp->b_flags |= B_RELBUF;



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