Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Oct 2013 09:56:41 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r256614 - head/sys/kern
Message-ID:  <201310160956.r9G9ufSk021213@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Oct 16 09:56:40 2013
New Revision: 256614
URL: http://svnweb.freebsd.org/changeset/base/256614

Log:
  MFprojects/camlock r256370:
   - Take BIO lock in biodone() only when there is no completion callback set
  and so we should wake up thread waiting in biowait().
   - Remove msleep() timeout from biowait().  It was added 11 years ago, when
  there was no locks used, and it should not be needed any more.

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==============================================================================
--- head/sys/kern/vfs_bio.c	Wed Oct 16 09:52:59 2013	(r256613)
+++ head/sys/kern/vfs_bio.c	Wed Oct 16 09:56:40 2013	(r256614)
@@ -3559,9 +3559,6 @@ biodone(struct bio *bp)
 	vm_offset_t start, end;
 	int transient;
 
-	mtxp = mtx_pool_find(mtxpool_sleep, bp);
-	mtx_lock(mtxp);
-	bp->bio_flags |= BIO_DONE;
 	if ((bp->bio_flags & BIO_TRANSIENT_MAPPING) != 0) {
 		start = trunc_page((vm_offset_t)bp->bio_data);
 		end = round_page((vm_offset_t)bp->bio_data + bp->bio_length);
@@ -3571,11 +3568,16 @@ biodone(struct bio *bp)
 		start = end = 0;
 	}
 	done = bp->bio_done;
-	if (done == NULL)
+	if (done == NULL) {
+		mtxp = mtx_pool_find(mtxpool_sleep, bp);
+		mtx_lock(mtxp);
+		bp->bio_flags |= BIO_DONE;
 		wakeup(bp);
-	mtx_unlock(mtxp);
-	if (done != NULL)
+		mtx_unlock(mtxp);
+	} else {
+		bp->bio_flags |= BIO_DONE;
 		done(bp);
+	}
 	if (transient) {
 		pmap_qremove(start, OFF_TO_IDX(end - start));
 		vmem_free(transient_arena, start, end - start);
@@ -3585,9 +3587,6 @@ biodone(struct bio *bp)
 
 /*
  * Wait for a BIO to finish.
- *
- * XXX: resort to a timeout for now.  The optimal locking (if any) for this
- * case is not yet clear.
  */
 int
 biowait(struct bio *bp, const char *wchan)
@@ -3597,7 +3596,7 @@ biowait(struct bio *bp, const char *wcha
 	mtxp = mtx_pool_find(mtxpool_sleep, bp);
 	mtx_lock(mtxp);
 	while ((bp->bio_flags & BIO_DONE) == 0)
-		msleep(bp, mtxp, PRIBIO, wchan, hz / 10);
+		msleep(bp, mtxp, PRIBIO, wchan, 0);
 	mtx_unlock(mtxp);
 	if (bp->bio_error != 0)
 		return (bp->bio_error);



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