From owner-svn-src-projects@FreeBSD.ORG Wed Oct 16 11:30:48 2013 Return-Path: Delivered-To: svn-src-projects@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 0F6AF3FF; Wed, 16 Oct 2013 11:30:48 +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 D883A25D1; Wed, 16 Oct 2013 11:30:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9GBUlDm071785; Wed, 16 Oct 2013 11:30:47 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9GBUlHd071784; Wed, 16 Oct 2013 11:30:47 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201310161130.r9GBUlHd071784@svn.freebsd.org> From: Alexander Motin Date: Wed, 16 Oct 2013 11:30:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256619 - 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: Wed, 16 Oct 2013 11:30:48 -0000 Author: mav Date: Wed Oct 16 11:30:47 2013 New Revision: 256619 URL: http://svnweb.freebsd.org/changeset/base/256619 Log: Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping temporary mapped buffer. That fixes double unmap triggered by r256286, when 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: projects/camlock/sys/kern/vfs_bio.c Modified: projects/camlock/sys/kern/vfs_bio.c ============================================================================== --- projects/camlock/sys/kern/vfs_bio.c Wed Oct 16 10:36:42 2013 (r256618) +++ projects/camlock/sys/kern/vfs_bio.c Wed Oct 16 11:30:47 2013 (r256619) @@ -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); - } } /*