Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp623481pxh; Tue, 9 Nov 2021 16:21:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXn0VZC3r29un1vhTr2R1vSNnbsaYjAUjjpOL1VD8lA6DXNnuUcZNIcprqJt2C4v9onlYy X-Received: by 2002:a02:712c:: with SMTP id n44mr9176605jac.92.1636503693827; Tue, 09 Nov 2021 16:21:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503693; cv=none; d=google.com; s=arc-20160816; b=Xl1pX08O4raP8jivfgyNvagaacVb4K7sQnE1a+L1kiKqVwz7XP7pj/rGm3MR1HvzK1 Qnu0ImWlQVxA4oqQFzg/n2cWJB6c/iGUutrMVX5/CMQivdvolnPPVx5OvxD0aupOOQCW im0ZpyAi21vpv7RStzBIkJIrtsxCJGWcHgqoHTKsszlQWGeCtmywqTFk0NGA11NaNr8X 1wtUbueXuaT6Mwh69DaZqEnHz4cUD4XbSsYSWCyApiFmUwmvgLpH08+lQPM0T85j6qcF xalqeQnC8jVxNiXdEoDwUX6a6PHspUs5uhy6vLmo+dlbgT3p9vrK1bfUfW93IhhFGwdh wY9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=PE1VptDeAs6kmOyj4aRTeb4D8eNBBDr4zH9bU+KmOKU=; b=dX4/+RcbdvCdyNqVttHNKX+JgrTk9q4wuUAP35gL9AGVYTGBOZdZmMoGF7Av4slMut e+rNn2AqAndwe6BJU+bPibcN3UamBbblUYb7UN6JH4tJe5okxBDUKnEk/nW23t2QyKqM 1EVPCvMgvvmSAZAiECmfygTTEkHqBzbv4b5tHv0dM6wK16L9DhVANUDEW2IQFKVwCyOk 0zka1sbsY2YYFT9i3hMc8aCLByufSF6RF7JhhpkV34HTvT76YaXwjyOqPN7m1y3AQk0d 9IWXoe36/bjC53Mcs/ENwiT++wDjPlsB5vExWt7JibZZb84QXe819GVEIanP933OMaca 0JmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PbmsTcNg; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si49016749iow.101.2021.11.09.16.21.21; Tue, 09 Nov 2021 16:21:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PbmsTcNg; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245181AbhKIVc6 (ORCPT + 99 others); Tue, 9 Nov 2021 16:32:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20550 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239398AbhKIVc6 (ORCPT ); Tue, 9 Nov 2021 16:32:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636493411; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PE1VptDeAs6kmOyj4aRTeb4D8eNBBDr4zH9bU+KmOKU=; b=PbmsTcNgbzj7JnDvFFy2dwJ0m0I0y9AF/do9qdrY2rHUM0SjTFInzU/Z5rMgM6opO0+Oli cjlhkBjwJBlN5pkmXBvp7tjG7O3Zn/uSlFtRCzUS4bcaAhv0OUthFEdbjTFlsVI5VSTyB2 rr+XW//QMlpv2vfQfoZeEGXNMRBtAzg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-446-pbeZtQg6M0m7P3otNU44WQ-1; Tue, 09 Nov 2021 16:27:57 -0500 X-MC-Unique: pbeZtQg6M0m7P3otNU44WQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0906887D542; Tue, 9 Nov 2021 21:27:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.37.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1812319729; Tue, 9 Nov 2021 21:27:44 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH v4 3/5] folio: Add replacements for page_endio() From: David Howells To: "Matthew Wilcox (Oracle)" Cc: Jeff Layton , Dominique Martinet , kafs-testing@auristor.com, dhowells@redhat.com, Jeff Layton , Ilya Dryomov , Dominique Martinet , linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, v9fs-developer@lists.sourceforge.net, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, devel@lists.orangefs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 09 Nov 2021 21:27:44 +0000 Message-ID: <163649326420.309189.6029879848780568728.stgit@warthog.procyon.org.uk> In-Reply-To: <163649323416.309189.4637503793406396694.stgit@warthog.procyon.org.uk> References: <163649323416.309189.4637503793406396694.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add three functions to replace page_endio(): (1) folio_end_read(). End a read to a folio. (2) folio_end_write(). End a write from a folio. (3) folio_endio(). A switcher that does one or the other of the above. Change page_endio() to just call folio_endio(). Note that the parameter order is switched so that the folio_endio() stub doesn't have to shuffle the params around, but can rather just test and jump. Signed-off-by: David Howells Tested-by: Jeff Layton Tested-by: Dominique Martinet Tested-by: kafs-testing@auristor.com Link: https://lore.kernel.org/r/1088663.1635955216@warthog.procyon.org.uk/ --- include/linux/pagemap.h | 9 ++++++- mm/filemap.c | 64 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 1a0c646eb6ff..fd90544bb3e4 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -895,7 +895,14 @@ static inline int __must_check write_one_page(struct page *page) int __set_page_dirty_nobuffers(struct page *page); int __set_page_dirty_no_writeback(struct page *page); -void page_endio(struct page *page, bool is_write, int err); +void folio_end_read(struct folio *folio, int err); +void folio_end_write(struct folio *folio, int err); +void folio_endio(struct folio *folio, int err, bool is_write); + +static inline void page_endio(struct page *page, bool is_write, int err) +{ + folio_endio(page_folio(page), err, is_write); +} void folio_end_private_2(struct folio *folio); void folio_wait_private_2(struct folio *folio); diff --git a/mm/filemap.c b/mm/filemap.c index daa0e23a6ee6..841e87b2d6ab 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1612,33 +1612,55 @@ void folio_end_writeback(struct folio *folio) } EXPORT_SYMBOL(folio_end_writeback); -/* - * After completing I/O on a page, call this routine to update the page - * flags appropriately +/** + * folio_end_read - Update the state of a folio after a read + * @folio: The folio to update + * @err: The error code (or 0) to apply */ -void page_endio(struct page *page, bool is_write, int err) +void folio_end_read(struct folio *folio, int err) { - if (!is_write) { - if (!err) { - SetPageUptodate(page); - } else { - ClearPageUptodate(page); - SetPageError(page); - } - unlock_page(page); + if (!err) { + folio_mark_uptodate(folio); } else { - if (err) { - struct address_space *mapping; + folio_clear_uptodate(folio); + folio_set_error(folio); + } + folio_unlock(folio); +} +EXPORT_SYMBOL_GPL(folio_end_read); - SetPageError(page); - mapping = page_mapping(page); - if (mapping) - mapping_set_error(mapping, err); - } - end_page_writeback(page); +/** + * folio_end_write - Update the state of a folio after a write + * @folio: The folio to update + * @err: The error code (or 0) to apply + */ +void folio_end_write(struct folio *folio, int err) +{ + if (err) { + struct address_space *mapping = folio_mapping(folio); + + folio_set_error(folio); + if (mapping) + mapping_set_error(mapping, err); } + folio_end_writeback(folio); +} +EXPORT_SYMBOL_GPL(folio_end_write); + +/** + * folio_endio - Update the state of a folio after a read or write + * @folio: The folio to update + * @err: The error code (or 0) to apply + * @is_write: True if this was a write + */ +void folio_endio(struct folio *folio, int err, bool is_write) +{ + if (is_write) + folio_end_write(folio, err); + else + folio_end_read(folio, err); } -EXPORT_SYMBOL_GPL(page_endio); +EXPORT_SYMBOL_GPL(folio_endio); /** * __folio_lock - Get a lock on the folio, assuming we need to sleep to get it.