Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp90877rdb; Thu, 21 Dec 2023 03:52:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRX57ye/wOIWZZu4NVaJy15Ur+ccEVPF0LgiUaCKg9W6UvorHJxosE6Qb3X4UEkCJwqwb1 X-Received: by 2002:a05:6870:4303:b0:203:c08d:aa9a with SMTP id w3-20020a056870430300b00203c08daa9amr1112751oah.103.1703159562960; Thu, 21 Dec 2023 03:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703159562; cv=none; d=google.com; s=arc-20160816; b=gWowV6b/7mzxpPYFq4kTZ7aI0C6UfxEgs7BHKS4wdn4c7BuXQpUi793dxplupxy7B4 K0gvNWJmIvbUdlpBN60jaNh1hrjGoj43MX8JXFzfSUyNTNzexZH9VNgUOc6FiwOxTXvj UpKyoZWqigX7cN0zGdth/WZztJzeqogx7qtQUdPLj80DEZwlwOVehpGhMLiR9dIyWU6j pKynHHZq5MpJPO3+26J1jYhnJbe5LRFMlOrzSYY4y3KyJ3cEHHLc/u7Mpvi6froyEE6m FcbhzpR/aUova03OVMN596EPq/xXEl2ndEg/Ty91VsA2TW5zMdjQpjSgYyVsuYFk777W p+6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=tJU+N/X0wPpRyjLNSDyU7/A5nuKKkSG6fh2fZzUVbgg=; fh=i6rGHk/clC1f9Y4mpJyYVOWW6p98QflrI/jjeassMJc=; b=Zg8CZkDLO5i1SrNeD+K/HRz4dBk4TQ45N+yE8Lba8uL6aOygkV+Nlf6wewbfkIcprs Rlpfvxcf3vUMs4ZqH/+4STMAN30LEqq1a8hOuoIXTnCEv2qsu0BsbQ4c3PriYMwP5iDx AI/5pzG2YqWv+mVVMVrJ4hheOcZ6+V6yuCbLFt4FLVWiBw5vRk1Q8CI9LDEovJ3F6D9s h5k3OYkreF5fcWrJ29ZXRo1N414Bz/XwMBHEbqkZ9o1JXrjV2Mn5hmsCYXWxc+qvN2sV Cb2osjSmdAM9JaQxeZiJaoXjk6FISvWfe0a4bQgw6P2y1tl00vt+9TAT7QYNmPhGBmVp 9D1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=khc6y35w; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=khc6y35w; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8305-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8305-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ei22-20020a056a0080d600b006d38c94f324si1406992pfb.362.2023.12.21.03.52.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 03:52:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8305-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=khc6y35w; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=khc6y35w; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8305-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8305-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4B85CB23D50 for ; Thu, 21 Dec 2023 11:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B20546E2D2; Thu, 21 Dec 2023 11:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="khc6y35w"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ld55sd1l"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="khc6y35w"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ld55sd1l" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D5206A327; Thu, 21 Dec 2023 11:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz 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-out1.suse.de (Postfix) with ESMTPS id 767E621E40; Thu, 21 Dec 2023 11:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703159509; 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=tJU+N/X0wPpRyjLNSDyU7/A5nuKKkSG6fh2fZzUVbgg=; b=khc6y35ww4SWPoGtdOWsxicW1xqDkRHHnlvlkWaYajf7RbskdRX3lR/x28jBQPfEk9TvdW rJeq+NMXBp6PVTIg05LqmmhBdF1mtSi+YVUIShZjOQiw1drLVWbgoI2rpeVknC4/HnmB3Y cMXJu6PQ53DKjsyR1p5kX1+s8Dgd2OI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703159509; 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=tJU+N/X0wPpRyjLNSDyU7/A5nuKKkSG6fh2fZzUVbgg=; b=Ld55sd1lsp8FieBhjWWavqqa4BkYb0OMxpzkSjQnRx6UtuPnJY7xDfh3rIANd0A2VNMGbI N7y4zmX2Z8c9nYAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703159509; 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=tJU+N/X0wPpRyjLNSDyU7/A5nuKKkSG6fh2fZzUVbgg=; b=khc6y35ww4SWPoGtdOWsxicW1xqDkRHHnlvlkWaYajf7RbskdRX3lR/x28jBQPfEk9TvdW rJeq+NMXBp6PVTIg05LqmmhBdF1mtSi+YVUIShZjOQiw1drLVWbgoI2rpeVknC4/HnmB3Y cMXJu6PQ53DKjsyR1p5kX1+s8Dgd2OI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703159509; 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=tJU+N/X0wPpRyjLNSDyU7/A5nuKKkSG6fh2fZzUVbgg=; b=Ld55sd1lsp8FieBhjWWavqqa4BkYb0OMxpzkSjQnRx6UtuPnJY7xDfh3rIANd0A2VNMGbI N7y4zmX2Z8c9nYAA== 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 6ACC813725; Thu, 21 Dec 2023 11:51:49 +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 FCcJGtUmhGVkYwAAD6G6ig (envelope-from ); Thu, 21 Dec 2023 11:51:49 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 0F223A07E3; Thu, 21 Dec 2023 12:51:49 +0100 (CET) Date: Thu, 21 Dec 2023 12:51:49 +0100 From: Jan Kara To: Christoph Hellwig Cc: linux-mm@kvack.org, "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/17] writeback: Add for_each_writeback_folio() Message-ID: <20231221115149.ke74ddapwb7q6fdz@quack3> References: <20231218153553.807799-1-hch@lst.de> <20231218153553.807799-16-hch@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231218153553.807799-16-hch@lst.de> X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -3.80 X-Spamd-Result: default: False [-3.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.com:email,infradead.org:email]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Flag: NO On Mon 18-12-23 16:35:51, Christoph Hellwig wrote: > From: "Matthew Wilcox (Oracle)" > > Wrap up the iterator with a nice bit of syntactic sugar. Now the > caller doesn't need to know about wbc->err and can just return error, > not knowing that the iterator took care of storing errors correctly. > > Signed-off-by: Matthew Wilcox (Oracle) > Signed-off-by: Christoph Hellwig Not sure if the trick with 'error' variable isn't a bit too clever for us ;) We'll see how many bugs it will cause in the future... Feel free to add: Reviewed-by: Jan Kara Honza > +#define for_each_writeback_folio(mapping, wbc, folio, error) \ > + for (folio = writeback_iter_init(mapping, wbc); \ > + folio || ((error = wbc->err), false); \ > + folio = writeback_iter_next(mapping, wbc, folio, error)) > + > typedef int (*writepage_t)(struct folio *folio, struct writeback_control *wbc, > void *data); > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index 0771f19950081f..fbffd30a9cc93f 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -2463,7 +2463,7 @@ static struct folio *writeback_get_folio(struct address_space *mapping, > return folio; > } > > -static struct folio *writeback_iter_init(struct address_space *mapping, > +struct folio *writeback_iter_init(struct address_space *mapping, > struct writeback_control *wbc) > { > if (wbc->range_cyclic) > @@ -2479,7 +2479,7 @@ static struct folio *writeback_iter_init(struct address_space *mapping, > return writeback_get_folio(mapping, wbc); > } > > -static struct folio *writeback_iter_next(struct address_space *mapping, > +struct folio *writeback_iter_next(struct address_space *mapping, > struct writeback_control *wbc, struct folio *folio, int error) > { > unsigned long nr = folio_nr_pages(folio); > @@ -2557,9 +2557,7 @@ int write_cache_pages(struct address_space *mapping, > struct folio *folio; > int error; > > - for (folio = writeback_iter_init(mapping, wbc); > - folio; > - folio = writeback_iter_next(mapping, wbc, folio, error)) > + for_each_writeback_folio(mapping, wbc, folio, error) > error = writepage(folio, wbc, data); > > return wbc->err; > -- > 2.39.2 > -- Jan Kara SUSE Labs, CR