Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17930015rwd; Tue, 27 Jun 2023 09:14:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sBCHFOXw7VQ87weeJhRg0uFg1BsM8VBUBw0uYV77Ocyo3BIuZUpvLuhr0detPmtLH2QEF X-Received: by 2002:a19:5f44:0:b0:4f6:2317:f387 with SMTP id a4-20020a195f44000000b004f62317f387mr16846890lfj.35.1687882494789; Tue, 27 Jun 2023 09:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882494; cv=none; d=google.com; s=arc-20160816; b=gkl2GxvUa2/ey+aMOscAH2bei5eHQO/jxw2bEyfzqW2IBhgg6uZjPya6zNCMsuPW+f 2OoZuD/ozRYn2UKfaGuNU5c4DlGCFexBnWUV68VUOZwXhnWmyBmhH3U/7y88C3V1YzcB xcE4WW5WR1/LizdoqreqKcWLk+CFn5eljr8Ad1O6I/Mfw0AW6B+ZzFYYtYGF23B/sbZS eMvmosW0Hhfqmid49/uiTp0fonEl38P6wZCxhQiQf1C0cohXku6ptm9NCxwxkY7VLGKa A3YIlToE5c+C5l0jnSiKlEmPEDAJiID3x+UBo2TPfok0ew1U9J6Lhm59o8JP/ijdWtM9 n2zg== 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=lHqSq2yg0hu/9TbZSF7IDALzpNFv9gjm5EjJ/uf/0wM=; fh=7/+bH645pXOMPUvchXG33u55fF+jis9y1S98vUjQIUs=; b=lFqh8MdmUY4B891XyrR2ZDstCxRHlAoYFDgxPKjLIHMCwCBt8P/mgAKzpYIDbBnz6r GJbQ5+89qzadQhQO39U5JqvPYes0jKScPoDcxNrzvImH0tSlijDShbk5fCJT4H2NgELs XplOIvlS1fLDHA6Cy87tVOMKvX9/52K4f5IcScs/VuxygWf7+oON2lcrwv1l3cwRO9CJ AMcf0C3I5PXbdvP8ngf5uzQBCeAv6hXSC7soPQJyame6E/hvwhw6F7/QujX/fevh5RYy wChXZHO93yMRuD2V+YQ6LjsIiCHU5OpdlJgnj/FH4Bg6GvtFs7QIqemrxS1cdGlw9qLV 7SkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gHepl+Tc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 d22-20020aa7d5d6000000b0051d96936b9asi2912677eds.338.2023.06.27.09.14.27; Tue, 27 Jun 2023 09:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=casper.20170209 header.b=gHepl+Tc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbjF0PbX (ORCPT + 99 others); Tue, 27 Jun 2023 11:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjF0PbW (ORCPT ); Tue, 27 Jun 2023 11:31:22 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B25270C; Tue, 27 Jun 2023 08:31:21 -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=lHqSq2yg0hu/9TbZSF7IDALzpNFv9gjm5EjJ/uf/0wM=; b=gHepl+TciLMWXYtAYcyOchIQ8O 92/OeN6/EuVk4lVItxfJ2FB0AfBIwXfT8d/+QpWWC/fpd+cdGEybTJfKOnFuDIiYi8ev/koIl0U5I u12r3uX+SYED69pLyAiX4AedlQ7VKmMxP0B8OsqpcHLxPwZrU18TYwrgNTzIYp0kqDMuP9vqkbnUD YgTk5Pe1cqhcgKi1NFiBs6Rgz4ahCvuTKFgGIyUSfDkMzc5OqdPDWRZ6JCaBYBXmEHY8bX1HYM3E2 wGUz/xKGJUBQaxjim0VxGIm+wN247iwNXYkwMuPRD6RwbHkXvo9zUTPxIuuJx3jUe9guGzVAkxG3g gU/65X2g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qEAez-002qVu-HU; Tue, 27 Jun 2023 15:31:17 +0000 Date: Tue, 27 Jun 2023 16:31:17 +0100 From: Matthew Wilcox To: Christoph Hellwig Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , David Howells Subject: Re: [PATCH 09/12] writeback: Factor writeback_iter_next() out of write_cache_pages() Message-ID: References: <20230626173521.459345-1-willy@infradead.org> <20230626173521.459345-10-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org On Mon, Jun 26, 2023 at 09:39:39PM -0700, Christoph Hellwig wrote: > On Mon, Jun 26, 2023 at 06:35:18PM +0100, Matthew Wilcox (Oracle) wrote: > > Pull the post-processing of the writepage_t callback into a > > separate function. That means changing writeback_finish() to > > return NULL, and writeback_get_next() to call writeback_finish() > > when we naturally run out of folios. > > > > Signed-off-by: Matthew Wilcox (Oracle) > > --- > > mm/page-writeback.c | 84 ++++++++++++++++++++++++--------------------- > > 1 file changed, 44 insertions(+), 40 deletions(-) > > > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > > index 659df2b5c7c0..ef61d7006c5e 100644 > > --- a/mm/page-writeback.c > > +++ b/mm/page-writeback.c > > @@ -2360,7 +2360,7 @@ void tag_pages_for_writeback(struct address_space *mapping, > > } > > EXPORT_SYMBOL(tag_pages_for_writeback); > > > > -static int writeback_finish(struct address_space *mapping, > > +static struct folio *writeback_finish(struct address_space *mapping, > > struct writeback_control *wbc, bool done) > > { > > folio_batch_release(&wbc->fbatch); > > @@ -2375,7 +2375,7 @@ static int writeback_finish(struct address_space *mapping, > > if (wbc->range_cyclic || (wbc->range_whole && wbc->nr_to_write > 0)) > > mapping->writeback_index = wbc->done_index; > > > > - return wbc->err; > > + return NULL; > > Having a return value that is always NULL feels a bit weird vs just > doing that return in the caller. It makes the callers neater. Compare: if (!folio) return writeback_finish(mapping, wbc, false); vs if (!folio) { writeback_finish(mapping, wbc, false); return NULL; } Similarly for the other two callers. > > + if (error == AOP_WRITEPAGE_ACTIVATE) { > > + folio_unlock(folio); > > + error = 0; > > Note there really shouldn't be any need for this in outside of the > legacy >writepage case. But it might make sense to delay the removal > until after ->writepage is gone to avoid bugs in conversions. ext4_journalled_writepage_callback() still returns AOP_WRITEPAGE_ACTIVATE, and that's used by a direct call to write_cache_pages(). > > + } else if (wbc->sync_mode != WB_SYNC_ALL) { > > + wbc->err = error; > > + wbc->done_index = folio->index + > > + folio_nr_pages(folio); > > Btw, I wonder if a folio_next_index helper for this might be useful > as it's a pattern we have in a few places. I think that's a reasonable addition to the API.