Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp395601rwb; Thu, 22 Sep 2022 20:38:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66Ci4/KPAkoqwYjMLUqfOAAHhZVhbj+JyMwYmc0vTIU95KVu0okKKi+gIBG8Lt/t10v2Ls X-Received: by 2002:a17:907:a06a:b0:77d:2f20:69c0 with SMTP id ia10-20020a170907a06a00b0077d2f2069c0mr5343153ejc.40.1663904333102; Thu, 22 Sep 2022 20:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663904333; cv=none; d=google.com; s=arc-20160816; b=BJOTgvs/dGekwreFbBlm0XiN9HSqYrD1d6T87NexsLXFQ3OVbtyRSYmuyt97TeafDR DQmwgPn7rvx7/NjT3wQi35ET+c6qTi+S+JRGCvJnYgh45/0FLW20p3g8ZHAjU2/11Dz3 Q3XTZmU8Izldd/foU8JlCfqV+k9k743Ne/xpvVCVVx7cbeN1Lf1pHPn+KMNtxrrM2lqx dgQpU1qNEp5MBdYhU+ZSNDNtb31fDn7lXVGCFw3kjZ7PcDCLcGN5xJkCmFLsGmEiaPUz ze/Opmy+KwRk/ucfhLby+eJVpLXPlEsrAJyEpfbHyPbDzPyoGC+i3VKJxaaq8PgTpxnu AN4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Q+FM57iduMogJtSFwZB4LfTdEsChuEHae2/DVlkArcM=; b=Fq3WiH2RzWkrd1lflfjZfkp2ASqKdt9jXk5JeDbGGMo1OKYjNhBLzvyG++5U50EAIy PVE75Jondd/c6JvfPsJPwAX1EsdmEsUedQ1QihebZdBlcBp9Dc30A7x626bEMYzQ2ocg kmq2/p6l45GhNmhnn/n3K+IhmAXDI9fuBKlCK9Rr7WDlmoBiQV90CzaUVfHK9TRwqMCF d6hvUAhDvtXDN802PmuGofIGirNdc9s2+iojkCC8+3ZUSbTtbwGQnJyopZCU+XYcmD4o lLGtVYo/Vtm05lzU4LB9d4jNwyRb5reylZd9iETFTNUWjzSW99+5q26EF9huIxoxhPSY /3XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b="sk/KR0xP"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn3-20020a17090794c300b00780633dc7b8si8413630ejc.734.2022.09.22.20.38.00; Thu, 22 Sep 2022 20:38:53 -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=@linux.org.uk header.s=zeniv-20220401 header.b="sk/KR0xP"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbiIWDUO (ORCPT + 99 others); Thu, 22 Sep 2022 23:20:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiIWDUN (ORCPT ); Thu, 22 Sep 2022 23:20:13 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30584814D1; Thu, 22 Sep 2022 20:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Q+FM57iduMogJtSFwZB4LfTdEsChuEHae2/DVlkArcM=; b=sk/KR0xPUKPHHKWolvPzsqAt4o o9FlyBUe1wX2zq2RbXWaAJTiFJqpuaVPHn1hI4kFCMLxmK2i4rRcZyBQ7i8qSoGeGHFgdH3ZJ0UN5 dLNBxE5Tu66mnNUVk9JDrYHLUSZ5tR8FUBrd6EieY3EtTeOzsSdqmQkk2T5jFMG+0yVorDIOTv6BI x2e9UgKUZKYh/UhIHRV8YFxRZVu+ZhV9ughRdGArDVjBkXAu9QUFk9H7Msq1b4dF/F8zWJ6sfxbPX 1KW1gnVTo+E89ZNUi1kmPsIS+V0iIkxK6dzo7GQGwpv2V3hXCjpWSwrQMvlVc1ZMa41+fwRncsoTL 6/jkjISg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1obZE6-002eVa-0R; Fri, 23 Sep 2022 03:19:42 +0000 Date: Fri, 23 Sep 2022 04:19:42 +0100 From: Al Viro To: Jan Kara Cc: John Hubbard , Christoph Hellwig , 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> <20220922112935.pep45vfqfw5766gq@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220922112935.pep45vfqfw5766gq@quack3> Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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 Thu, Sep 22, 2022 at 01:29:35PM +0200, Jan Kara wrote: > > This rule would mostly work, as long as we can relax it in some cases, to > > allow pinning of both source and dest pages, instead of just destination > > pages, in some cases. In particular, bio_release_pages() has lost all > > context about whether it was a read or a write request, as far as I can > > tell. And bio_release_pages() is the primary place to unpin pages for > > direct IO. > > Well, we already do have BIO_NO_PAGE_REF bio flag that gets checked in > bio_release_pages(). I think we can easily spare another bio flag to tell > whether we need to unpin or not. So as long as all the pages in the created > bio need the same treatment, the situation should be simple. Yes. Incidentally, the same condition is already checked by the creators of those bio - see the assorted should_dirty logics. While we are at it - how much of the rationale around bio_check_pages_dirty() doing dirtying is still applicable with pinning pages before we stick them into bio? We do dirty them before submitting bio, then on completion bio_check_pages_dirty() checks if something has marked them clean while we'd been doing IO; if all of them are still dirty we just drop the pages (well, unpin and drop), otherwise we arrange for dirty + unpin + drop done in process context (via schedule_work()). Can they be marked clean by anyone while they are pinned? After all, pinning is done to prevent writeback getting done on them while we are modifying the suckers...