Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2478617rdb; Mon, 5 Feb 2024 07:48:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4pogx9O5yxajKiVOQbX/I97aCA0zir/coMBUosKJPxjHEsupk0zKo03cl8va9dzaWuFkX X-Received: by 2002:a17:903:2114:b0:1d8:f249:43e8 with SMTP id o20-20020a170903211400b001d8f24943e8mr10908741ple.18.1707148123546; Mon, 05 Feb 2024 07:48:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148123; cv=pass; d=google.com; s=arc-20160816; b=j93QPs5W7Dy94JzPbUZnJmYv25TFX+omgftJOWCgZg4f/7D8dmiN1ig8SIPMXDsUGO m7eQIKL2FX3kT7vIWCXgJpZ9yyw9amX8QHqcB+Hv+9KnX1oK7uDpSdAgr5w5bhW/O5Z6 Ja9KOH0V8+k8QRvEq/OBF/FB8iqGLHXtFcmBG+L5lOAc1bS7sIej6qnEAq9bquem/Rmt RIcLYg7jtPrc9vuu+F0gkM27dd1iY5nXV2+uc+CfULUvVOu/vs4vdPpFxG6BRqg0qvGA 62JkEILnq0knWsan4JDUgSKi5tWABRfWoam8zHY16O+85SnNulIm+E/pvVbk6AfUUQF8 1p9A== ARC-Message-Signature: i=2; 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; bh=CsHOpyyNz6zLdrRHdpKUhlbdO+IltU0fGAYIWwSsnME=; fh=2zwzYH3IDnMBl+sJyx2kHxiA0txk8RCXSKMz1Mjm8Zs=; b=oTHmC67mwuO7c4pKBR1HTVrG4pJn/PzXa3ZEJORYPqTbfPycsjqaqaGdBS/XyOWYtK gznt3SsJItSqc2CzLsoMh+42iqu8Gz9hiJL5tNUIi0L2yWDYhGY2aZos84pt6q+sX0KH cHYzpOoW4WJ6Jzi0BZ/zPUi5iSY4/CoJU3poO6wzqPjsHQyN0S75RRavJ7bWPa0Se6Nh JE8fSpdJ04hWwM93P8YEYoEGNEvSAkQP5OOzZZBNp5YE2q6s33CcQA4RBd6I8GbONjas dWBsU6O7/FvAs/Wq8SXRzgjHtFzypRd16/tSfwswtbybuvfTT73dpjDM0pXmiuG9WyLE GDCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=clsKQU+3; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-52920-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52920-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVKt4ZgYu2w0K1xMJRTeD4RtduNqV4z31agpT+FSoXzQu7v5in36FEqXaigoVBDuTzEsv/vulEoCI8Y+oSNK/ojIWxp0mJwguDVnV1uiQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b12-20020a170903228c00b001d721ef5b06si14672plh.456.2024.02.05.07.48.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:48:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52920-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=clsKQU+3; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-52920-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52920-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BDB928AC41 for ; Mon, 5 Feb 2024 15:34:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DAD544C68; Mon, 5 Feb 2024 15:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="clsKQU+3" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 330953A8FB for ; Mon, 5 Feb 2024 15:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707147212; cv=none; b=roHKO1KC1oNcPync0Htp5wtav4B11Tg2DNtxMeY9bamiJUYYBTBuJHhyYjujYG82WwNbznT1sEWwZpnLQY+UTWkIm94oDHmXM5253vqcoSUChcxDHTLqOLOiZveUcnH7GFRP2mhvptVD0/3F0XZ8iA5Kni5IHRfjJwfXWr5g3cs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707147212; c=relaxed/simple; bh=YjybTbiH6+mn+QYS0STDNx5/X3rF3BbV/TwjTuDcDTo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dwSfRmTk/Cg7UteC2F7d2yk1oguiIt4x6AZeCuDJuv8c1L1dEL0CSkYb5XCIRFwFRzYQM1sfKt8JqkBVVE6F9du47aN9XYzYm2duHY4gO0RruJ++4QnDd8pmNwE5Ty7hun9M2XGmwUmx93JGuER7xarcejswByKr+rsouHnq19g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=clsKQU+3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707147210; 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=CsHOpyyNz6zLdrRHdpKUhlbdO+IltU0fGAYIWwSsnME=; b=clsKQU+3BMMuh0DeUyvmMVtXzbABTKhyN34e/F7NshHyXOG65QkuBbkJRLSkaKl7AMqwrG Lr4q3yyKmTmGFAwxhP1Vu+XLqFk5rZb9XiaWY+XdNZGPnxuiwSkvRyNr2p+NYA1F4RnSbj VqLP+o67k2uo+H1kQZiBClWM5kD0Og4= 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-217-cs0W5ccaM4ODy2vVK0aelA-1; Mon, 05 Feb 2024 10:32:44 -0500 X-MC-Unique: cs0W5ccaM4ODy2vVK0aelA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 348C0863018; Mon, 5 Feb 2024 15:32:44 +0000 (UTC) Received: from bfoster (unknown [10.22.32.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C14982166B31; Mon, 5 Feb 2024 15:32:43 +0000 (UTC) Date: Mon, 5 Feb 2024 10:34:02 -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 13/13] writeback: Remove a use of write_cache_pages() from do_writepages() Message-ID: References: <20240203071147.862076-1-hch@lst.de> <20240203071147.862076-14-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: <20240203071147.862076-14-hch@lst.de> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 On Sat, Feb 03, 2024 at 08:11:47AM +0100, Christoph Hellwig wrote: > From: "Matthew Wilcox (Oracle)" > > Use the new writeback_iter() directly instead of indirecting > through a callback. > > Signed-off-by: Matthew Wilcox (Oracle) > [hch: ported to the while based iter style] > Signed-off-by: Christoph Hellwig > --- LGTM, modulo Jan's comments: Reviewed-by: Brian Foster > mm/page-writeback.c | 31 +++++++++++++++++++------------ > 1 file changed, 19 insertions(+), 12 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index 5fe4cdb7dbd61a..53ff2d8219ddb6 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -2577,13 +2577,25 @@ int write_cache_pages(struct address_space *mapping, > } > EXPORT_SYMBOL(write_cache_pages); > > -static int writepage_cb(struct folio *folio, struct writeback_control *wbc, > - void *data) > +static int writeback_use_writepage(struct address_space *mapping, > + struct writeback_control *wbc) > { > - struct address_space *mapping = data; > - int ret = mapping->a_ops->writepage(&folio->page, wbc); > - mapping_set_error(mapping, ret); > - return ret; > + struct folio *folio = NULL; > + struct blk_plug plug; > + int err; > + > + blk_start_plug(&plug); > + while ((folio = writeback_iter(mapping, wbc, folio, &err))) { > + err = mapping->a_ops->writepage(&folio->page, wbc); > + mapping_set_error(mapping, err); > + if (err == AOP_WRITEPAGE_ACTIVATE) { > + folio_unlock(folio); > + err = 0; > + } > + } > + blk_finish_plug(&plug); > + > + return err; > } > > int do_writepages(struct address_space *mapping, struct writeback_control *wbc) > @@ -2599,12 +2611,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) > if (mapping->a_ops->writepages) { > ret = mapping->a_ops->writepages(mapping, wbc); > } else if (mapping->a_ops->writepage) { > - struct blk_plug plug; > - > - blk_start_plug(&plug); > - ret = write_cache_pages(mapping, wbc, writepage_cb, > - mapping); > - blk_finish_plug(&plug); > + ret = writeback_use_writepage(mapping, wbc); > } else { > /* deal with chardevs and other special files */ > ret = 0; > -- > 2.39.2 >