Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3987380rwb; Tue, 6 Sep 2022 00:10:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AOuezNz1M7KbkJCvQB8LyGhg/n2D/JMC2tYzQE9+uOqHTs8Ui5MvZzE168mhtVYl/kgB0 X-Received: by 2002:a05:6402:42d4:b0:443:4b8:8cba with SMTP id i20-20020a05640242d400b0044304b88cbamr46275331edc.3.1662448218919; Tue, 06 Sep 2022 00:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662448218; cv=none; d=google.com; s=arc-20160816; b=YYNBwkISs1blF78bmB5eqxyLkKFRuP73ESgngTFJIxxeERqlNa1TgM9qAV8E5gIg8M PzQr/31TWKB/xbMFmmRR8OoD1MlPEEwW6HHOVNAhlFE+Yto+Y+mLDNAVrQ6R/QXMbke+ GW8rw2jBUUwtjHsu3DEyOGY1W//9iDcuv1kjOevo2stZjWcI+1m9btpWyDJggS3pZ3ua 5IHewCzPkDekHxCHfgISL1xdNDZd2Tsg+YWU3fh3HdB4ZG5AWx19mLLNtHziNmveHzph XgKFUrzP5d8zE0gFc2SnjolOSXF3A6xkMbTcR9SrvJp77LwYARJGYkBSe6oOUfysiwwF grwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=29BCCHFkbIUvIEkJ/NT2axzz3sINy2OSORQKgk8fFZA=; b=1GtvOynJp0uiYoOtOZjgUuU9dNJDVa06R66tKNSQXlw/Bu3ts9dspZXM3qq7Ujc5pW x9o2J2RV8HmvkGK5kiGNNuFHBsApG0HRPjkSyBKzQIZUoVhK/t/oAb5gWzNVOMAx+Qn3 2WVds8GlyAUOw44jIYF7lU0/VFUOE5JmbGT4ezRqU2S85sMbxU9JAfB8XozOZGkwblSS 9WNZB8RWuxjvoZAOnuGu/L3U1VqULd56NCUnLftBZlavMFH20jm9k5OJHHMIkgxzO8d9 QlHZ8Ak7lGLoutHddd6HrsfMS6lq4m6v11x2cnv2cGgK4JMBS8yw9kZMQQJ6UR0WJ5v2 Cp1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RxGtQVXb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x44-20020a50baaf000000b004405af7da47si8860684ede.564.2022.09.06.00.09.51; Tue, 06 Sep 2022 00:10:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=RxGtQVXb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238687AbiIFGuI (ORCPT + 99 others); Tue, 6 Sep 2022 02:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238690AbiIFGuB (ORCPT ); Tue, 6 Sep 2022 02:50:01 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D75D1CFFD; Mon, 5 Sep 2022 23:49:58 -0700 (PDT) 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=29BCCHFkbIUvIEkJ/NT2axzz3sINy2OSORQKgk8fFZA=; b=RxGtQVXb+DTaBvy7bbOri5nYAg Vlb1SRCZHEDoJqUOVg0QSh7MMLoV+F9l+kk4YFZmCrpL4bfLviIzZt86aP7PMF/Sx755TIndJqbn2 vUYABmKgOwA6ZRqXcimL9pgJJ/QYUIHXV5GPYKvCROQx062hhMR+mCOgD1Tn18Us8aW8nvBeVfpny Umh8wtLdaRIrBIAzAa53a/M3auCX0EPffzuBfmut/XNIDXEkkgr0EosOkxeA2x9Vhb+scbIFZ1v0Z GytoOg3FHHaIiluF0aHHfUt7G5QMYlm5BzF4uSByddA4H+J+Sl3785RSLNpiy5z62/QmKRpYIwMBR 0e7+915A==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVSP8-00AYGR-D8; Tue, 06 Sep 2022 06:49:50 +0000 Date: Mon, 5 Sep 2022 23:49:50 -0700 From: Christoph Hellwig To: John Hubbard Cc: Andrew Morton , Jens Axboe , Alexander Viro , Miklos Szeredi , Christoph Hellwig , "Darrick J . Wong" , Trond Myklebust , Anna Schumaker , Jan Kara , 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 6/7] NFS: direct-io: convert to FOLL_PIN pages Message-ID: References: <20220831041843.973026-1-jhubbard@nvidia.com> <20220831041843.973026-7-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220831041843.973026-7-jhubbard@nvidia.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Aug 30, 2022 at 09:18:42PM -0700, John Hubbard wrote: static void nfs_direct_release_pages(struct iov_iter *iter, struct page **pages, unsigned int npages) > { > - unsigned int i; > - for (i = 0; i < npages; i++) > - put_page(pages[i]); > + if (user_backed_iter(iter) || iov_iter_is_bvec(iter)) > + dio_w_unpin_user_pages(pages, npages); > + else > + release_pages(pages, npages); Instead of having this magic in all kinds of places, we need a helper that takes the page array, npages and iter->type and does the right thing.