From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EABE3C6FA82 for ; Fri, 23 Sep 2022 08:44:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 622E380009; Fri, 23 Sep 2022 04:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D31480007; Fri, 23 Sep 2022 04:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49A8A80009; Fri, 23 Sep 2022 04:44:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3855780007 for ; Fri, 23 Sep 2022 04:44:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 06AE11C6BA3 for ; Fri, 23 Sep 2022 08:44:48 +0000 (UTC) X-FDA: 79942714656.03.CA310EE Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id A872640007 for ; Fri, 23 Sep 2022 08:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=nNv86JWq7K4SrXi9kThW3IL/MbxUCnwp29q6ItT7Jcw=; b=mZ8CmQuWblk1MMVUpDuLR6qc2s 66kAf6IwGc9rz0v2QxusGWOBx/z7JWCpwJXwtQQfoZl02tWSFIeMLPbv6Y8FLFUcMX5RNQyuMyjNm 2MGSOlBfZUOF3LiHToMr2YMxtlRl+e7cmeIS9x7sZKYj9mQbVlaIHExj1LBNB8vuyeJOWksc5BLvN nPucVivNwS7UH0z21KZ4o09dDV43l7Y1TIlsWlLIFZqIkl+lF4tXhcr6mMihC0eK0a4ng9TjYi2fy Re5oLmrnTKJy1TB7kLdq4LFaKHsUAY6WZuzCKzI5722zzZ/Qq6ez4BCJv73S/3i7ZgPbsi1+l4f4v /WaWCnfw==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1obeIT-00327F-D2; Fri, 23 Sep 2022 08:44:33 +0000 Date: Fri, 23 Sep 2022 01:44:33 -0700 From: Christoph Hellwig To: Al Viro Cc: Christoph Hellwig , Jan Kara , John Hubbard , Andrew Morton , Jens Axboe , Miklos Szeredi , "Darrick J . Wong" , Trond Myklebust , Anna Schumaker , David Hildenbrand , Logan Gunthorpe , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, LKML Subject: Re: [PATCH v2 4/7] iov_iter: new iov_iter_pin_pages*() routines Message-ID: References: <20220906102106.q23ovgyjyrsnbhkp@quack3> <20220914145233.cyeljaku4egeu4x2@quack3> <20220915081625.6a72nza6yq4l5etp@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663922687; a=rsa-sha256; cv=none; b=NimgVrgDcfwl1AWXetgYT7TzOfU/7/Volnnfs/5w5OiCDwp/uL74PNOopdjslU2o+0glWn tUCBZtqQgXTNNYDI9Lo7clM23Vz5axlL9mqjGs/JlssJMzclz7m03L68MxbmGHG+vb7dac /o9pr52C63z7jPiDL56aELoowQGxHls= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mZ8CmQuW; spf=none (imf04.hostedemail.com: domain of BATV+37c89300bb66dcdb041c+6970+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+37c89300bb66dcdb041c+6970+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663922687; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nNv86JWq7K4SrXi9kThW3IL/MbxUCnwp29q6ItT7Jcw=; b=qM1hE8nQib1d6jX9ql1GGuIc95FIFcieR8vNuSuF5FLVDbMci6hXy7KjhNlt/dXLntzPYx bsl5/r4snepGcgdmuL4wufubrsMGR46A3uXexjIVAlX+SS95sL+yzL1XwmYsqVcwK9p/Ej oKhUuCI/3maXY/sZRd3ZcP5KLrScCl4= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A872640007 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mZ8CmQuW; spf=none (imf04.hostedemail.com: domain of BATV+37c89300bb66dcdb041c+6970+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+37c89300bb66dcdb041c+6970+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none X-Rspam-User: X-Stat-Signature: yriheu5ojunk3y9n5tqhn4casb3xj19u X-HE-Tag: 1663922687-98687 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Sep 23, 2022 at 05:22:17AM +0100, Al Viro wrote: > > Add a iov_iter_unpin_pages that does the right thing based on the > > type. (block will need a modified copy of it as it doesn't keep > > the pages array around, but logic will be the same). > > Huh? You want to keep the type (+ direction) of iov_iter in any structure > a page reference coming from iov_iter_get_pages might end up in? IDGI... Why would I? We generall do have or should have the iov_iter around. And for the common case where we don't (bios) we can carry that information in the bio as it needs a special unmap helper anyway. But if you don't want to use the iov_iter for some reason, we'll just need to condense the information to a flags variable and then pass that. > > BTW, speaking of lifetime rules - am I right assuming that fd_execute_rw() > does IO on pages of the scatterlist passed to it? Yes. > Where are they getting > dropped and what guarantees that IO is complete by that point? The exact place depens on the exact taaraget frontend of which we have a few. But it happens from the end_io callback that is triggered through a call to target_complete_cmd. > The reason I'm asking is that here you have an ITER_BVEC possibly fed to > __blkdev_direct_IO_async(), with its > if (iov_iter_is_bvec(iter)) { > /* > * Users don't rely on the iterator being in any particular > * state for async I/O returning -EIOCBQUEUED, hence we can > * avoid expensive iov_iter_advance(). Bypass > * bio_iov_iter_get_pages() and set the bvec directly. > */ > bio_iov_bvec_set(bio, iter); > which does *not* grab the page referneces. Sure, bio_release_pages() knows > to leave those alone and doesn't drop anything. However, what is the > mechanism preventing the pages getting freed before the IO completion > in this case? The contract that callers of bvec iters need to hold their own references as without that doing I/O do them would be unsafe. It they did not hold references the pages could go away before even calling bio_iov_iter_get_pages (or this open coded bio_iov_bvec_set).