From owner-svn-src-head@FreeBSD.ORG Mon Oct 21 06:44:55 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E0179EFE; Mon, 21 Oct 2013 06:44:55 +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 B601F2E5D; Mon, 21 Oct 2013 06:44:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9L6itU7085433; Mon, 21 Oct 2013 06:44:55 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9L6itBR085432; Mon, 21 Oct 2013 06:44:55 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201310210644.r9L6itBR085432@svn.freebsd.org> From: Alexander Motin Date: Mon, 21 Oct 2013 06:44:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256830 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2013 06:44:56 -0000 Author: mav Date: Mon Oct 21 06:44:55 2013 New Revision: 256830 URL: http://svnweb.freebsd.org/changeset/base/256830 Log: MFprojects/camlock r256619: Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping temporary mapped buffer. That fixes double unmap if biodone() called twice for the same BIO (but with different done methods). Move mapping removal before calling bio_done() method. I believe that it is very wrong to do anything to BIO after reporting completion. kib@ thinks it was done for some forgotten now case when bio_done() method needed mapped buffer. But 1) if BIO was sent as unmapped, then IMO done() should be called in the same way; 2) IMO there is no guatantee that buffer will be mapped at this point at all, for example, if all underlying stack supports unmapped I/O, so bio_done() handler can not expect that. Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Mon Oct 21 06:31:56 2013 (r256829) +++ head/sys/kern/vfs_bio.c Mon Oct 21 06:44:55 2013 (r256830) @@ -3557,15 +3557,15 @@ biodone(struct bio *bp) struct mtx *mtxp; void (*done)(struct bio *); vm_offset_t start, end; - int transient; if ((bp->bio_flags & BIO_TRANSIENT_MAPPING) != 0) { + bp->bio_flags &= ~BIO_TRANSIENT_MAPPING; + bp->bio_flags |= BIO_UNMAPPED; start = trunc_page((vm_offset_t)bp->bio_data); end = round_page((vm_offset_t)bp->bio_data + bp->bio_length); - transient = 1; - } else { - transient = 0; - start = end = 0; + pmap_qremove(start, OFF_TO_IDX(end - start)); + vmem_free(transient_arena, start, end - start); + atomic_add_int(&inflight_transient_maps, -1); } done = bp->bio_done; if (done == NULL) { @@ -3578,11 +3578,6 @@ biodone(struct bio *bp) bp->bio_flags |= BIO_DONE; done(bp); } - if (transient) { - pmap_qremove(start, OFF_TO_IDX(end - start)); - vmem_free(transient_arena, start, end - start); - atomic_add_int(&inflight_transient_maps, -1); - } } /*