From owner-freebsd-hackers@freebsd.org Mon Oct 16 07:17:46 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CE80E319FE for ; Mon, 16 Oct 2017 07:17:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B99CB70590 for ; Mon, 16 Oct 2017 07:17:45 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v9G7HYds001614 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 16 Oct 2017 10:17:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v9G7HYds001614 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v9G7HY4X001612; Mon, 16 Oct 2017 10:17:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 16 Oct 2017 10:17:34 +0300 From: Konstantin Belousov To: "Owens, Keith" Cc: "freebsd-hackers@freebsd.org" Subject: Re: How to map a single unmapped BIO? Message-ID: <20171016071734.GF2473@kib.kiev.ua> References: <0A22297308D147479E18AA1807A03807017F2378@MX202CL01.corp.emc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0A22297308D147479E18AA1807A03807017F2378@MX202CL01.corp.emc.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Oct 2017 07:17:46 -0000 On Mon, Oct 16, 2017 at 06:24:19AM +0000, Owens, Keith wrote: > I have a geom that sometimes (very rarely) needs to modify the data in an unmapped BIO. Completely removing unmapped support from the entire geom is overkill. What is the best way of converting a single unmapped BIO to a mapped address so I can access the data? > > Basically I want g_io_transient_map_bio(), but that function is static. Duplicating that code in my geom is not elegant. Making g_io_transient_map_bio() non-static and allowing arbitrary geom to use it would probably cause troubles, because the mapping is automatically destroyed by biodone(). It is either too late if yor only need the mapping now, or too early in other situations. Consider using the sf bufs, which were designed specifically to allow kernel consumers to create temporary mappings. There is even a man page sf_buf(4), which is mostly up to date.