Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4175367pxb; Tue, 2 Nov 2021 05:32:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRcJ1ixdXvIvGqE7b0LOMRvvSUffsxjv6a9AToMmtWeIotQPMCrumnAz1JqOFDuLBOkz2G X-Received: by 2002:a05:6e02:190f:: with SMTP id w15mr11504403ilu.197.1635856376449; Tue, 02 Nov 2021 05:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635856376; cv=none; d=google.com; s=arc-20160816; b=T5QktLDGxV8skL29CI2ZkqzBwnnJJ1r9WZiKmKJmdZwARICKgjNU3SAeHapt/c3aFZ Ei9aToIzk1nl2P7UPCPOJTBjZymTQk5nZLry9SqpGpxG826jMWvPmJJKJcECvsN9uPCF 1xJ5X9UeB7j8UG9odIRKriIqpWbDW8o48a0vFhu0giDBvqPP5d3m2WWTv66FOlgEkrKZ 94sqWtPfZawQVPl4Dbol0FM7kr37ZxjNwWo32HXHWgn0HZ/VOgimEgfgFCcAF5rHYVqq ReBOqgTf/8G/nbwfXflC+OpEYmQHg9v4GyWvtx1SwmJ/sYItInW/I2lQ6mLDr8n7ReuN RV/A== 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=TKqWgfpw5AGxV0aXDmIN4fp1Id+pK1uozWw0xKtDRVU=; b=m74Dv2v+OsONNSR3mlPhhzOsAkOHWeTnFuPIMIVI7UQXr5KWE7WvVUN03C9jCCxKzJ lbaeuY6G+JOQdI6Y/RuJaBDvUiRmkHB5SIXYbEsIGDu0zPCB8yKtAf6sFrQ4Ez/uWgnt VD3eQuLtcVcGJU9Bq7DGEcXOnRQaWNXi3b6vsP+WqMk9fgjclnJC7g/w1Fg1d3SHKpUq fR88yamudUV8KGUBTd5bo6yo3RbU4gxOb0t4D/gvRskdYKQMTDkgR4x9VoeZ4DgVVWhV yIDZOLiZud9uDG6Xr1f0jDM1eIClMyTAxkN2Sq4vwsX+rVRHEwBH72eYvx/VOyEv4ZL1 28dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=o3CXWrfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w70si18430309jaa.124.2021.11.02.05.32.44; Tue, 02 Nov 2021 05:32:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=o3CXWrfh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbhKBMc0 (ORCPT + 99 others); Tue, 2 Nov 2021 08:32:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhKBMcZ (ORCPT ); Tue, 2 Nov 2021 08:32:25 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E1DC061714; Tue, 2 Nov 2021 05:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=TKqWgfpw5AGxV0aXDmIN4fp1Id+pK1uozWw0xKtDRVU=; b=o3CXWrfh6eqE/lwsca02rozqZi OKidFQjXbtIZCsmOTMW6lm0UZf4jV+/3UzKD5e2BRyjbi0/0OTBwZhxKMLqEikCYo5IknqCcBY4FZ 8tDZWe8odIIUSQvYZA99b7ad2EaM18IKKCj6hc4+hl6xAjdmRil/Vv2tSSgF0+vGrOiKRLpc84cEd s40c1JwJvOlFAdQRRqzsMgQqCsGsWUywtkapp54VRZB5DKQhlhyvp/brpw1s+Kde1Kv1JjNcQLaZY VBNS7+gt5Dv4idlPr/falDKw8o4yF554w+cRiqLW11HkNrPn4D0mK11mGQ+nqrJR7pnAzORfmr06c 39usDeAQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhsta-004UJp-MJ; Tue, 02 Nov 2021 12:29:01 +0000 Date: Tue, 2 Nov 2021 12:28:06 +0000 From: Matthew Wilcox To: Christoph Hellwig Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Subject: Re: [PATCH 13/21] iomap: Convert readahead and readpage to use a folio Message-ID: References: <20211101203929.954622-1-willy@infradead.org> <20211101203929.954622-14-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 02, 2021 at 12:20:47AM -0700, Christoph Hellwig wrote: > On Mon, Nov 01, 2021 at 08:39:21PM +0000, Matthew Wilcox (Oracle) wrote: > > for (done = 0; done < length; done += ret) { > > - if (ctx->cur_page && offset_in_page(iter->pos + done) == 0) { > > - if (!ctx->cur_page_in_bio) > > - unlock_page(ctx->cur_page); > > - put_page(ctx->cur_page); > > - ctx->cur_page = NULL; > > + if (ctx->cur_folio && > > + offset_in_folio(ctx->cur_folio, iter->pos + done) == 0) { > > + if (!ctx->cur_folio_in_bio) > > + folio_unlock(ctx->cur_folio); > > + ctx->cur_folio = NULL; > > Where did the put_page here disappear to? I'll put that explanation in the changelog: Handle folios of arbitrary size instead of working in PAGE_SIZE units. readahead_folio() puts the page for you, so this is not quite a mechanical change. --- The reason for making that change is that I messed up when introducing the readahead() operation. I followed the refcounting rule of ->readpages() instead of the rule of ->readpage(). For a successful readahead, we have two more atomic operations than necessary. I want to fix that, and this seems like a good opportunity to do it. Once all filesystems are converted to call readahead_folio(), we can remove the extra get_page() and put_page(). I did put an explanation of that in commit 9bf70167e3c6, but it's not reasonable to expect reviewers to remember that when reviewing changes to their filesystem's readahead, so I'll be sure to mention it in any future conversion's changelogs. mm/filemap: Add readahead_folio() The pointers stored in the page cache are folios, by definition. This change comes with a behaviour change -- callers of readahead_folio() are no longer required to put the page reference themselves. This matches how readpage works, rather than matching how readpages used to work.