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 C03A0C48295 for ; Mon, 5 Feb 2024 15:31:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13B9B6B0074; Mon, 5 Feb 2024 10:31:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EC6C6B0078; Mon, 5 Feb 2024 10:31:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF5906B007B; Mon, 5 Feb 2024 10:31:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DB9BF6B0074 for ; Mon, 5 Feb 2024 10:31:00 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3BEBBA1769 for ; Mon, 5 Feb 2024 15:31:00 +0000 (UTC) X-FDA: 81758138280.08.F878CBB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id E9FBC20027 for ; Mon, 5 Feb 2024 15:30:56 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XYbXvdcp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of bfoster@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707147057; 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=JTCo85pVLToNTQneWe34tWLYUrb02reZxLGls+V2O1E=; b=NK1C12njJl+vMFJfcm8kpTJrHpJNnDEHkVx8c48yE6zbObvJIo4wzrmIkYeiCeGbUIvAu5 T44nBxTUYKo00silig843dcVep0l2TXtBrqJbmRgQebF/Xhr4LSlUmfjAbhT/157pOZC/g j8/UFlIG3/jJCQXL2IpfanBkVtM6zc8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XYbXvdcp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of bfoster@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bfoster@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707147057; a=rsa-sha256; cv=none; b=uut+9gWQp6JSqpo2xQBypJ5u3ELyuXhKjYxoCVpqMX7YuZ82dzXj0DioeXvsPrgd8ZQ+gt vMSIJGDEDm1WLXc3vtVgU6SStcKFWI2ZjWQp10nxW84XtcGJuz1mv4aQLtUqBr746daqqP GK+P0hWIu8bHYg9Lq3uuVVD8K6l44rA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707147056; 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=JTCo85pVLToNTQneWe34tWLYUrb02reZxLGls+V2O1E=; b=XYbXvdcpVW8mS/2ip6bDKeTwyshhT8BlLELTZoOLJB+cM1Bb6OMixZUPwTD+xonRiLP+Pq +p1KLuqTrljPq2Ot0tdM1MBHDiY5kIQzKiaQwsJNmTbH3dJilUUJk/dGvvV25n8UysWGGL dJRE7WV4ShDmVhPdjOzn5ZQuOg3DgAY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-219-4WPZpIx9PXuaNxqotKV2ZA-1; Mon, 05 Feb 2024 10:30:53 -0500 X-MC-Unique: 4WPZpIx9PXuaNxqotKV2ZA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 44E7A3C11C63; Mon, 5 Feb 2024 15:30:52 +0000 (UTC) Received: from bfoster (unknown [10.22.32.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D5336112131D; Mon, 5 Feb 2024 15:30:51 +0000 (UTC) Date: Mon, 5 Feb 2024 10:32:10 -0500 From: Brian Foster To: Christoph Hellwig Cc: 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 05/13] writeback: rework the loop termination condition in write_cache_pages Message-ID: References: <20240203071147.862076-1-hch@lst.de> <20240203071147.862076-6-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240203071147.862076-6-hch@lst.de> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E9FBC20027 X-Stat-Signature: u1y3hfwaugyrgcc89dt8m7bcqtnp1csb X-Rspam-User: X-HE-Tag: 1707147056-989237 X-HE-Meta: U2FsdGVkX18k1j5QHNwUci7OObcFBFBXrrljsjyRLG9DYcGTES1typ0VuUJJmh3pJjlkN78sMKfYn//yyUxUOjZDkDjZYU+jpWCmDAhsltL3DUXm8QqgRO8ikSD4uhhTHYas6R2+ZGn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9tQGvLs0 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 Sat, Feb 03, 2024 at 08:11:39AM +0100, Christoph Hellwig wrote: > Rework the way we deal with the cleanup after the writepage call. > > First handle the magic AOP_WRITEPAGE_ACTIVATE separately from real error > returns to get it out of the way of the actual error handling path. > > The split the handling on intgrity vs non-integrity branches first, > and return early using a goto for the non-ingegrity early loop condition > to remove the need for the done and done_index local variables, and for > assigning the error to ret when we can just return error directly. > > Signed-off-by: Christoph Hellwig > --- > mm/page-writeback.c | 84 ++++++++++++++++++--------------------------- > 1 file changed, 33 insertions(+), 51 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index c7c494526bc650..88b2c4c111c01b 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c ... > @@ -2524,14 +2505,15 @@ int write_cache_pages(struct address_space *mapping, > * of the file if we are called again, which can only happen due to > * -ENOMEM from the file system. > */ > - if (wbc->range_cyclic) { > - if (done) > - mapping->writeback_index = done_index; > - else > - mapping->writeback_index = 0; > - } > - > + if (wbc->range_cyclic) > + mapping->writeback_index = 0; > return ret; > + > +done: > + folio_batch_release(&fbatch); > + if (wbc->range_cyclic) > + mapping->writeback_index = folio->index + folio_nr_pages(folio); Shouldn't this release the batch after we're done accessing folio? With that addressed: Reviewed-by: Brian Foster > + return error; > } > EXPORT_SYMBOL(write_cache_pages); > > -- > 2.39.2 > >