From owner-svn-src-stable-10@FreeBSD.ORG Sun Jan 5 23:00:39 2014 Return-Path: Delivered-To: svn-src-stable-10@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 ESMTPS id 11A196B3; Sun, 5 Jan 2014 23:00:39 +0000 (UTC) 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 D7FDE1CF0; Sun, 5 Jan 2014 23:00:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s05N0ccl020618; Sun, 5 Jan 2014 23:00:38 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s05N0cPs020617; Sun, 5 Jan 2014 23:00:38 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401052300.s05N0cPs020617@svn.freebsd.org> From: Alexander Motin Date: Sun, 5 Jan 2014 23:00:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r260354 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2014 23:00:39 -0000 Author: mav Date: Sun Jan 5 23:00:38 2014 New Revision: 260354 URL: http://svnweb.freebsd.org/changeset/base/260354 Log: MFC r256614: - 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: stable/10/sys/kern/vfs_bio.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_bio.c ============================================================================== --- stable/10/sys/kern/vfs_bio.c Sun Jan 5 22:55:21 2014 (r260353) +++ stable/10/sys/kern/vfs_bio.c Sun Jan 5 23:00:38 2014 (r260354) @@ -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);