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 74A14C4828D for ; Wed, 7 Feb 2024 13:59:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE0ED6B0071; Wed, 7 Feb 2024 08:59:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B90F66B0072; Wed, 7 Feb 2024 08:59:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A80466B0074; Wed, 7 Feb 2024 08:59:40 -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 99F7B6B0071 for ; Wed, 7 Feb 2024 08:59:40 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 68946140DB5 for ; Wed, 7 Feb 2024 13:59:40 +0000 (UTC) X-FDA: 81765165720.22.CFA58F8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 845F64000E for ; Wed, 7 Feb 2024 13:59:38 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dQhoKu60; spf=pass (imf12.hostedemail.com: domain of bfoster@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707314378; 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=wBR9it5N9UXG0CkxBIj40SLEEuG3r+6CTLKQmmsG/eg=; b=pfUHv+wKMgTcdOLFx6ptif5snyF56FFBqQpdqYoBh7HtTl/feOkR4JJQ40ju7rq9RFjyH8 FGsEU1hyqv+QL9wIRSrFM7KaRgIXKcruwf29Her9GgvWj+27j7WrRb4sdtygdyqH1reO1H BCYf8bH3iTKsftMAR0OqzRAjirdPcgE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707314378; a=rsa-sha256; cv=none; b=rP8bLS5FokNGffvndHIDKD9yo/rUb+r8OPY1hqzzCcmfCy3RIt2XzOspbzQ9c1ZooM9FBX Zr1WMHQm6ClZSsAf3skWmNZ9u+cu3CAJc9x/wHmKdrc7vpmYJAkqUGqO+4U3FlFhmlQFBl TceXfFKKdNTexy+8u36F2HPMy9DRWbc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dQhoKu60; spf=pass (imf12.hostedemail.com: domain of bfoster@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707314377; h=from:from:reply-to:subject:subject: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=wBR9it5N9UXG0CkxBIj40SLEEuG3r+6CTLKQmmsG/eg=; b=dQhoKu60hMF6yTioXU54b8Pfg8Tn7/T6GHQAEtOpcr1pqwwH0pvhKE1mWjnzELwaoSXPCt 9Br/Dve0lG9saP3Rf081JpKsMvz7hhTnAOzThPQJSN+2P29COowmEL2BW1vL89lqM7NIwI 9pfTlA3IrjbJjVaxQ62hBiHi3iCdXw4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-482-RByV5KkYOLWzRUoPJvdsEw-1; Wed, 07 Feb 2024 08:59:36 -0500 X-MC-Unique: RByV5KkYOLWzRUoPJvdsEw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD6B0101FA30; Wed, 7 Feb 2024 13:59:35 +0000 (UTC) Received: from bfoster (unknown [10.22.32.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 136F1C08EF7; Wed, 7 Feb 2024 13:59:35 +0000 (UTC) Date: Wed, 7 Feb 2024 09:00:53 -0500 From: Brian Foster To: Jan Kara 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: References: <20240203071147.862076-1-hch@lst.de> <20240203071147.862076-13-hch@lst.de> <20240207084224.o6nn4l7owwhzb5e3@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240207084224.o6nn4l7owwhzb5e3@quack3> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Stat-Signature: tpfazpb3b147niy3kyzm66os4spk9jyi X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 845F64000E X-Rspam-User: X-HE-Tag: 1707314378-593404 X-HE-Meta: U2FsdGVkX19Q8nRow9SR0SLdqvoRwVvErfCOZvbP/jwWzG0EZqLTHTw5/fMKdWAvJXto/C8mhcyNLpWjfPSk5TbZJ417CGjwWaLkNzphJ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Z1YQXnEWx2ru0IVsaLqn35mO4= 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 Wed, Feb 07, 2024 at 09:42:24AM +0100, Jan Kara wrote: > 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. > Yeah, I wasn't really familiar with the AOP error codes, saw that multiple existed and just assumed they might be arbitrarily relevant across different aop callbacks (and so then filtered the check/clear for WRITEPAGE_ACTIVATE out of my brain ;). On taking a closer look, it seems like the only other one (AOP_TRUNCATED_PAGE) doesn't have any relevance to ->writepage(), so this all makes more sense to me now. Thanks. Brian > Honza > -- > Jan Kara > SUSE Labs, CR >