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 88BEEC4828F for ; Wed, 7 Feb 2024 08:42:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B17646B0071; Wed, 7 Feb 2024 03:42:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC7BC8D0001; Wed, 7 Feb 2024 03:42:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98EF16B0074; Wed, 7 Feb 2024 03:42:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 89A976B0071 for ; Wed, 7 Feb 2024 03:42:34 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 54A49A0D11 for ; Wed, 7 Feb 2024 08:42:34 +0000 (UTC) X-FDA: 81764366628.28.2361180 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf22.hostedemail.com (Postfix) with ESMTP id 0E8A1C000A for ; Wed, 7 Feb 2024 08:42:30 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=D9B8ecpX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="a/DE9HMm"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=D9B8ecpX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="a/DE9HMm"; dmarc=none; spf=pass (imf22.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707295351; 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=2g70fPjpQ5IfQrdko+WLA6L2tGMboSG/Vf9GkcU2sHM=; b=XnHq9sKhX4u9rOoOuLRt8jku0z4sW/yWEW2u2Otja52rQhpnN19Jkxi+bONGAmnmzFJ+5B wELM2UKnokak8KWxdwJOE5Y/BJdfSKxwb1rYW2RgbWaF8RmH1BXcq6FVLQ1Q9z9yKz+J3I xXnDtLRu3X7KsCivJQg0YJE4DSAi8nw= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=D9B8ecpX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="a/DE9HMm"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=D9B8ecpX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="a/DE9HMm"; dmarc=none; spf=pass (imf22.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707295351; a=rsa-sha256; cv=none; b=pdWT7DGslQAZY9s4zaEc0nW/QyqpiCpyIy3DufIsihnZWERyLP+sO2D43Ifs8zz60vkyRN +sv1eG7jny98TZ69saUDBnbsvSS2L2naFA/75ElWKSldM0bQjZhMOIVKMJiqO9EhOCyIWk tdbRxVLRyCiE22KxHNJOVkEhBe3yfBg= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 236E81F45B; Wed, 7 Feb 2024 08:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1707295349; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2g70fPjpQ5IfQrdko+WLA6L2tGMboSG/Vf9GkcU2sHM=; b=D9B8ecpXtDdsnSvQF4JPndq8iFjXGjxZa+fB38klu9RVra65ZPQE7HCe82gb5CfC4SBwYq sas+r21Oc8S+95NiK6k1QsHkv9j7zb6/fFcjqa5Z3JkKuSOLWRIg49Ii9XPAUvJ+zyhpZu mhkpKZiUk7YYcMGBaTokGcOCCFLX/p8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1707295349; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2g70fPjpQ5IfQrdko+WLA6L2tGMboSG/Vf9GkcU2sHM=; b=a/DE9HMmPKkuE0y3lNqk20qSVQpF+J5hf7l47fcHv0t8wjx82YmaMwOrdaRh0oN9njYfLQ Upx0hhnWuFiFm+Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1707295349; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2g70fPjpQ5IfQrdko+WLA6L2tGMboSG/Vf9GkcU2sHM=; b=D9B8ecpXtDdsnSvQF4JPndq8iFjXGjxZa+fB38klu9RVra65ZPQE7HCe82gb5CfC4SBwYq sas+r21Oc8S+95NiK6k1QsHkv9j7zb6/fFcjqa5Z3JkKuSOLWRIg49Ii9XPAUvJ+zyhpZu mhkpKZiUk7YYcMGBaTokGcOCCFLX/p8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1707295349; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2g70fPjpQ5IfQrdko+WLA6L2tGMboSG/Vf9GkcU2sHM=; b=a/DE9HMmPKkuE0y3lNqk20qSVQpF+J5hf7l47fcHv0t8wjx82YmaMwOrdaRh0oN9njYfLQ Upx0hhnWuFiFm+Ag== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 16D7B139D8; Wed, 7 Feb 2024 08:42:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id pOOGBXVCw2WeQwAAD6G6ig (envelope-from ); Wed, 07 Feb 2024 08:42:29 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id B9F9CA0809; Wed, 7 Feb 2024 09:42:24 +0100 (CET) Date: Wed, 7 Feb 2024 09:42:24 +0100 From: Jan Kara To: Brian Foster Cc: Christoph Hellwig , linux-mm@kvack.org, Matthew Wilcox , Jan Kara , David Howells , Christian Brauner , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 12/13] writeback: add a writeback iterator Message-ID: <20240207084224.o6nn4l7owwhzb5e3@quack3> References: <20240203071147.862076-1-hch@lst.de> <20240203071147.862076-13-hch@lst.de> 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: 0E8A1C000A X-Stat-Signature: qg49hq8p9wcqquc8j7y9b5i8j8sidhri X-Rspam-User: X-HE-Tag: 1707295350-551562 X-HE-Meta: U2FsdGVkX18UQDI2Lvl4U7hftoxJ0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dsGCxas86qD/MU5hmwmsA1RXoO150y4ADbkn1hbjig+0qzcO8hMdhud3AuJhmBwyXgMJbhIlaNXhK1F9CkeLxVoh4Ei56px1xkW4rc9U4vhHJDRA146cDEwkaQ7hn/McNYaz2e6+ZDpTkmEun+lBKsFwWWTuF6ruy6+AyfRGquzPGHCvOu1PC0DiKcVgBzqe5ONbg== 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: List-Subscribe: List-Unsubscribe: On Tue 06-02-24 09:54:01, Brian Foster wrote: > On Mon, Feb 05, 2024 at 10:33:52AM -0500, Brian Foster wrote: > > On Sat, Feb 03, 2024 at 08:11:46AM +0100, Christoph Hellwig wrote: > > > Refactor the code left in write_cache_pages into an iterator that the > > > file system can call to get the next folio for a writeback operation: > > > > > > struct folio *folio = NULL; > > > > > > while ((folio = writeback_iter(mapping, wbc, folio, &error))) { > > > error = ; > > > } > > > > > > The twist here is that the error value is passed by reference, so that > > > the iterator can restore it when breaking out of the loop. > > > > > > Handling of the magic AOP_WRITEPAGE_ACTIVATE value stays outside the > > > iterator and needs is just kept in the write_cache_pages legacy wrapper. > > > in preparation for eventually killing it off. > > > > > > Heavily based on a for_each* based iterator from Matthew Wilcox. > > > > > > Signed-off-by: Christoph Hellwig > > > --- > > > include/linux/writeback.h | 4 + > > > mm/page-writeback.c | 192 ++++++++++++++++++++++---------------- > > > 2 files changed, 118 insertions(+), 78 deletions(-) > > > > > ... > > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > > > index 3abb053e70580e..5fe4cdb7dbd61a 100644 > > > --- a/mm/page-writeback.c > > > +++ b/mm/page-writeback.c > > ... > > > @@ -2434,69 +2434,68 @@ static struct folio *writeback_get_folio(struct address_space *mapping, > > > } > > > > > > /** > > ... > > > */ > > > -int write_cache_pages(struct address_space *mapping, > > > - struct writeback_control *wbc, writepage_t writepage, > > > - void *data) > > > +struct folio *writeback_iter(struct address_space *mapping, > > > + struct writeback_control *wbc, struct folio *folio, int *error) > > > { > > ... > > > + } else { > > > wbc->nr_to_write -= folio_nr_pages(folio); > > > > > > - if (error == AOP_WRITEPAGE_ACTIVATE) { > > > - folio_unlock(folio); > > > - error = 0; > > > - } > > > + WARN_ON_ONCE(*error > 0); > > > > Why the warning on writeback error here? It looks like new behavior, but > > maybe I missed something. Otherwise the factoring LGTM. > > Err, sorry.. I glossed over the > 0 check and read it as < 0. > Disregard, this seems reasonable to me as long as we no longer expect > those AOP returns (which I'm not really clear on either, but anyways..): > > Reviewed-by: Brian Foster So my understanding is that AOP_WRITEPAGE_ACTIVATE should be now handled directly by the caller of ->writepage hook and not by writeback_iter() which is the reason why the warning is here. Honza -- Jan Kara SUSE Labs, CR