From patchwork Wed Nov 3 16:00:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12601093 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3C55C43217 for ; Wed, 3 Nov 2021 16:00:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2570761184 for ; Wed, 3 Nov 2021 16:00:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2570761184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6C9E66B006C; Wed, 3 Nov 2021 12:00:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 652436B0072; Wed, 3 Nov 2021 12:00:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CC54940007; Wed, 3 Nov 2021 12:00:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 3C3E16B006C for ; Wed, 3 Nov 2021 12:00:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E76457144C for ; Wed, 3 Nov 2021 16:00:29 +0000 (UTC) X-FDA: 78768081378.02.4D85E26 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 94BA87001700 for ; Wed, 3 Nov 2021 16:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635955228; 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=Xt+1THW0w5czFIQs7JsvecSiF+2xY6v64T7h7rZxRpI=; b=IW23i2iOCziam2LYOc4/jR4aL2Ic2Xm7QYIbJ/cMwnC2en0OKIaHmV8nlSDUs22i8au5Kq q3dfH6a5iaex59p+4pszLhZ4wkefcJWPQwQbbNsADKIKrvX3knYXWrRabuWBd0j447opyU no9ge3qx4e9dNfT78aT+sXu687ihNNg= 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-318-JcHzKTE2MMCGQupL0xZvdg-1; Wed, 03 Nov 2021 12:00:23 -0400 X-MC-Unique: JcHzKTE2MMCGQupL0xZvdg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18B111922974; Wed, 3 Nov 2021 16:00:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC8C05DEFA; Wed, 3 Nov 2021 16:00:17 +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 From: David Howells In-Reply-To: References: <163584174921.4023316.8927114426959755223.stgit@warthog.procyon.org.uk> <163584187452.4023316.500389675405550116.stgit@warthog.procyon.org.uk> To: Matthew Wilcox Cc: dhowells@redhat.com, Jeff Layton , Marc Dionne , Ilya Dryomov , Dominique Martinet , v9fs-developer@lists.sourceforge.net, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, linux-cachefs@redhat.com, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, devel@lists.orangefs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] folio: Add replacements for page_endio() MIME-Version: 1.0 Content-ID: <1088662.1635955216.1@warthog.procyon.org.uk> Date: Wed, 03 Nov 2021 16:00:16 +0000 Message-ID: <1088663.1635955216@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Rspamd-Queue-Id: 94BA87001700 X-Stat-Signature: e4ped6m4sfz8n3z1whgttz4557ipwu3g Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IW23i2iO; spf=none (imf02.hostedemail.com: domain of dhowells@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam02 X-HE-Tag: 1635955224-480758 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: 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 --- 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 e4b98714f763..29b4ee189cb8 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -845,7 +845,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 bfcef6ff7a27..e4e90f96bf1c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1596,33 +1596,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.