From patchwork Thu Aug 12 21:42:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12434329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC93AC4338F for ; Thu, 12 Aug 2021 21:42:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E2C960FED for ; Thu, 12 Aug 2021 21:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4E2C960FED 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 94BC36B006C; Thu, 12 Aug 2021 17:42:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FB668D0001; Thu, 12 Aug 2021 17:42:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EA0E6B0072; Thu, 12 Aug 2021 17:42:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 60F426B006C for ; Thu, 12 Aug 2021 17:42:19 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D5C522310F for ; Thu, 12 Aug 2021 21:42:18 +0000 (UTC) X-FDA: 78467752356.14.9918CB3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 5C9579008038 for ; Thu, 12 Aug 2021 21:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628804537; 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; bh=3vjVq2GikaMVJqPFGcCye9t/QbMbfbU0vJwIdgocx4k=; b=Fd+DlN1sK1hq2vqlHCHPJNJ5k+eohVnm6Qa0yFqi/9TM0axnSzgfm6MftQ2IG+UPe+qUU7 VhXnQoLbMLvVZwZ4w1TyzYpP21Skj2riLh8EW4aZ7y1kmCiYsVDu4SSYXKHHUSzcs37qof YJ+k+2bjSdicuKODcD1sFMmOn/8PLRo= 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-487-O1M0uqr-NwSrWXiwVMivrQ-1; Thu, 12 Aug 2021 17:42:14 -0400 X-MC-Unique: O1M0uqr-NwSrWXiwVMivrQ-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 88BD1801AEB; Thu, 12 Aug 2021 21:42:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.22.32.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D0E219C79; Thu, 12 Aug 2021 21:42:12 +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: [RFC PATCH] folio: Add a function to get the host inode for a folio From: David Howells To: willy@infradead.org Cc: dhowells@redhat.com, linux-mm@kvack.org Date: Thu, 12 Aug 2021 22:42:11 +0100 Message-ID: <162880453171.3369675.3704943108660112470.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 5C9579008038 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Fd+DlN1s; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf29.hostedemail.com: domain of dhowells@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=dhowells@redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: 3eqiqqodzwjhremnz3ukp7hw9pxxzyqx X-HE-Tag: 1628804538-572856 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 a convenience function, folio_inode() that will get the host inode from a folio's mapping. [Includes netfs and afs changes for illustration, but I'd move those to a different patch]. Signed-off-by: David Howells --- fs/afs/dir.c | 4 ++-- fs/afs/file.c | 4 ++-- fs/afs/write.c | 3 +-- fs/netfs/read_helper.c | 2 +- include/linux/pagemap.h | 14 ++++++++++++++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index db5bc874bf0b..37e6f4713f4f 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -2023,7 +2023,7 @@ static int afs_rename(struct user_namespace *mnt_userns, struct inode *old_dir, static int afs_dir_releasepage(struct page *subpage, gfp_t gfp_flags) { struct folio *folio = page_folio(subpage); - struct afs_vnode *dvnode = AFS_FS_I(folio_mapping(folio)->host); + struct afs_vnode *dvnode = AFS_FS_I(folio_inode(folio)); _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio_index(folio)); @@ -2042,7 +2042,7 @@ static void afs_dir_invalidatepage(struct page *subpage, unsigned int offset, unsigned int length) { struct folio *folio = page_folio(subpage); - struct afs_vnode *dvnode = AFS_FS_I(folio_mapping(folio)->host); + struct afs_vnode *dvnode = AFS_FS_I(folio_inode(folio)); _enter("{%lu},%u,%u", folio_index(folio), offset, length); diff --git a/fs/afs/file.c b/fs/afs/file.c index 8d72ad7571e4..3585b90486af 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -392,7 +392,7 @@ static void afs_readahead(struct readahead_control *ractl) static void afs_invalidate_dirty(struct folio *folio, unsigned int offset, unsigned int length) { - struct afs_vnode *vnode = AFS_FS_I(folio_mapping(folio)->host); + struct afs_vnode *vnode = AFS_FS_I(folio_inode(folio)); unsigned long priv; unsigned int f, t, end = offset + length; @@ -470,7 +470,7 @@ static void afs_invalidatepage(struct page *page, unsigned int offset, static int afs_releasepage(struct page *page, gfp_t gfp_flags) { struct folio *folio = page_folio(page); - struct afs_vnode *vnode = AFS_FS_I(folio_mapping(folio)->host); + struct afs_vnode *vnode = AFS_FS_I(folio_inode(folio)); _enter("{{%llx:%llu}[%lu],%lx},%x", vnode->fid.vid, vnode->fid.vnode, folio_index(folio), folio->flags, diff --git a/fs/afs/write.c b/fs/afs/write.c index a639fb94298c..44f3f2323486 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -911,8 +911,7 @@ void afs_prune_wb_keys(struct afs_vnode *vnode) int afs_launder_page(struct page *subpage) { struct folio *folio = page_folio(subpage); - struct address_space *mapping = folio_mapping(folio); - struct afs_vnode *vnode = AFS_FS_I(mapping->host); + struct afs_vnode *vnode = AFS_FS_I(folio_inode(folio)); struct iov_iter iter; struct bio_vec bv[1]; unsigned long priv; diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c index fd4ca897785f..5a6aa7b1ae79 100644 --- a/fs/netfs/read_helper.c +++ b/fs/netfs/read_helper.c @@ -1024,7 +1024,7 @@ EXPORT_SYMBOL(netfs_readpage); */ static bool netfs_skip_folio_read(struct folio *folio, loff_t pos, size_t len) { - struct inode *inode = folio_mapping(folio)->host; + struct inode *inode = folio_inode(folio); loff_t i_size = i_size_read(inode); size_t offset = offset_in_folio(folio, pos); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 72149be4373b..696306a93e45 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -203,6 +203,20 @@ static inline struct address_space *page_mapping_file(struct page *page) return folio_mapping(folio); } +/** + * folio_inode - Get the host inode for this folio. + * @folio: The folio. + * + * For folios which are in the page cache, return the inode that is hosting + * this folio belongs to. + * + * Do not call this for folios which aren't in the page cache. + */ +static inline struct inode *folio_inode(struct folio *folio) +{ + return folio_mapping(folio)->host; +} + static inline bool page_cache_add_speculative(struct page *page, int count) { VM_BUG_ON_PAGE(PageTail(page), page);