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 26A5FEB64DD for ; Tue, 27 Jun 2023 15:31:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E7B88D0005; Tue, 27 Jun 2023 11:31:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 798438D0001; Tue, 27 Jun 2023 11:31:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6869E8D0005; Tue, 27 Jun 2023 11:31:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 55B9F8D0001 for ; Tue, 27 Jun 2023 11:31:27 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 34E4F1A09BD for ; Tue, 27 Jun 2023 15:31:26 +0000 (UTC) X-FDA: 80948916972.24.60CC5AC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 59AB12004C for ; Tue, 27 Jun 2023 15:31:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gHepl+Tc; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687879880; 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=lHqSq2yg0hu/9TbZSF7IDALzpNFv9gjm5EjJ/uf/0wM=; b=ak/RbiEAOJ91DawXyAbyruRiD+ILfORs3y4FYq147g04GXGCJZ3hMxTdgfzMXHuMOfZZ8D 8GR6FRMdM8WkBsv+W/Ax22pucwcIktb22QnpTXUQ1iztGYCdjqSEB/OJi9mcCZzmaTK7C4 Yqa99+9YMQi0heuzxXAYX2htujtHKb8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gHepl+Tc; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687879880; a=rsa-sha256; cv=none; b=55g6p9RQ0TLAqIOrsV6EdJB91Xn7XO/bi8fVEJPGDzrWjRdXI3EmLZ89+5406p1xD22wOU 24werNbmlVHxJREeyxnltg3ztj0CJfkh6lI7/dfZUaFiggja7TtHl0gk8LqtV1XqxNEZgb jktdYeUdTlC9bT39tM/Gdp+a3geeXUA= 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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 59AB12004C X-Stat-Signature: 7m6gwbz7uuq1z7us99n5zdw6ip8g6rwu X-Rspam-User: X-HE-Tag: 1687879879-676172 X-HE-Meta: U2FsdGVkX19PDvdpxFbCV4i/Dnr3Sm25ZlXmjuzYA3r4Y21JaMr4tvLUWUKQ7UVC1CZ0x1ZDsCxt7ok6hzhivvD9sdLcq1PmfDrCJrzsWqBwKbdGSLYRHd6JxpjjW/zS9zYqwnKQelGxtggrFzgSkhY08QN3/OxPs7RlPWvW6B7eiQAiGx9XvwS2+PJzHMw0ye1qjQlqrnJZu0GqbDRAXf7uDKk/zP0xj2WNfQ+idvd+NTK0KxsG7ViEKCj/9h8UFxA7YugQsRdrgeICxEKVVvbHfFY9VCh+vUry/gRUgddW1Au7GIyp2c+ydP/kvJEx4LLMs+LiTH7iEUTUUMZIDR1gRDhLbElSQj4t8135VeMszF+oPpMm6nD9jS/GA2qdewwEN/us2iI1IglvjffpbIlFfrF/9SquORgvpI4Xi37sK1sYGjneSKnVkH2BHb5OeqbmESIJthmwHS5y1OBFkzOjb6R5a6YdCovJ37p1jQwoEgSMPHqW0tyC8/3eDihuHEcP9RdanrcZpFirw5V6uhYVl9TuJqAi+ugWC/lh+RsOtN4l/s2o93CeNKSfuqIndMqRoXIhkZ/PIbWbJDCVIucSvL67+P+1eHAOPzf6vOTFDGU32gvNC6f6gSCfaIs9BdVZwg2kV6uJjXhbiZWaTCsOtJUin+YmV6hJSqbpEXp0xt0uKbtWHQwQrobkhT6mWQ2JDccMyHsbf/VcsUXyr4WAxEZJpMYnrzzJ7ezJKBs5zwFfMGPUpQFACeIuE9+fVTTjrrzpcm9CAer4PdW2VxQxCmNC6rRBPyt9FvohdrRZc4QZudvB2smdA+rnbk6e0MqwGh7FEU6b6/6DDP/GxLN0ISIXqpWmYbOTsgxtGjF+GN+Bk8ZvmfFD2Viik3145M0aOHky9yIaZHkBZhGYn3jGfOhnxJh3LXoLL4H+KK+1kjbxF1fHXb0a0ERCrF7cf/WuTG+H+FEPf7jwn0K ZI0PVxs6 RuafyALvzfTPc9rckANdku504tgYA203m8rN8IoDgeqYJrKErPQ2GSzzzcphYNh9tbU9Xg0068Fad6d0m9+Bhi1h8jlsCt2ImLfAXhjKm/2VwMiLTti+mA4GhDcPmmYTaly4mZnBq2jmXhUqzyXvxvSMUxxnQ4xGo9vVnlQegAvR2fNNHHKq5d2PTyiJ5WTSaeNVYqQh3tgKVVqQ//MR1OKEuLJfEGWzFB/B+0plOl0aQefM= 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 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.