From owner-svn-src-projects@FreeBSD.ORG Sat Oct 12 09:56:10 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9EF21CDB; Sat, 12 Oct 2013 09:56:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7448A2465; Sat, 12 Oct 2013 09:56:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9C9uATB013907; Sat, 12 Oct 2013 09:56:10 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9C9uAVj013906; Sat, 12 Oct 2013 09:56:10 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201310120956.r9C9uAVj013906@svn.freebsd.org> From: Alexander Motin Date: Sat, 12 Oct 2013 09:56:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256370 - projects/camlock/sys/kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Oct 2013 09:56:10 -0000 Author: mav Date: Sat Oct 12 09:56:09 2013 New Revision: 256370 URL: http://svnweb.freebsd.org/changeset/base/256370 Log: - 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: projects/camlock/sys/kern/vfs_bio.c Modified: projects/camlock/sys/kern/vfs_bio.c ============================================================================== --- projects/camlock/sys/kern/vfs_bio.c Sat Oct 12 07:50:15 2013 (r256369) +++ projects/camlock/sys/kern/vfs_bio.c Sat Oct 12 09:56:09 2013 (r256370) @@ -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);