Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp623349pxh; Tue, 9 Nov 2021 16:21:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0MPEu9Ws4AYRM8itsXA86Lmq5dGLEwLmO8+N97pw12mKZVnbeEJK31J9akaq5JaGhilAe X-Received: by 2002:a05:6602:29c7:: with SMTP id z7mr8132964ioq.93.1636503686594; Tue, 09 Nov 2021 16:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503686; cv=none; d=google.com; s=arc-20160816; b=vts434igXnf01Eil0vk3IxIOslb1kxLIhq4QKak1DmFkD31lmuofCaLy2l+YHUuUtH ciOUFxcJLy0C8eFXjCSF28RJQUrOBIL63Z+3vfHpTwK/X2HrlFTBTzIZjN7NngtZCHy6 1vEnt/HwbZBWT85oamgJ49TjE1u/lgV0ZzCcrFjv2MsnjJmzZtIqdwXKbgtX30nV7EOW BkLR5LCN1DBjf4BvzZkppnYzphakZ6ayBb67b1T6knF3f5M/ErJ4U/pEzt2NpVk2XLkP hI3sv/9smoqBhrD2hufohhZbZuzrI5de0DTxukZIISd8MJFA+97CQyTFpQpQWo4lYWdU IiVQ== 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=BOSFjmze2lq+KCADzfQWnIbaZ/LmbdWfVW3/mH571yI=; b=IL5QO8qtTUc9pENO00c8F3Zy9lhX3JTAWSA9rfbqKJnLcvYq8bhozXRWZR4Fx8Xyfx pXHTwdULsR3hLQAuvxOH8C9xJPQr7pLY4foggA9KHiaupGr/qvssElZNLFxm/0QLTpRX /mFZ9ouMUc0lTT1dw+9dr1g/3lJpYmVPBVTCN2HBTXv9pCllKFBnsbtdpACF9mv0cLz+ RYcalJ9IdYksDDZaHObH0HM3smxF0S8tQUdH2MZUObbv7jinhWY+/nUcjDbtzkGxjHRA FWJREDNau/k6/YODzylDAr19iY+Cubc37JNhV5ngI6u5TRv1cA1vDUJkIRnGHD4hjRTh iG4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dAUsvP44; 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 j23si43656237ila.32.2021.11.09.16.21.14; Tue, 09 Nov 2021 16:21:26 -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=dAUsvP44; 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 S239142AbhKIVfU (ORCPT + 99 others); Tue, 9 Nov 2021 16:35:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48852 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245229AbhKIVfT (ORCPT ); Tue, 9 Nov 2021 16:35:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636493552; 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=BOSFjmze2lq+KCADzfQWnIbaZ/LmbdWfVW3/mH571yI=; b=dAUsvP44RHT3erissgb1cTEEIa0Y/JTzMeJn5dBbibGpDKb9rtL4MeUjJ8Q/pQkUJa+XAH 5l49WGWbX90GY5QLbpGv7Pp5IMa1GL4/9AnvipP4rtcXi2iu1zk84VWDIkZb6d3slhvUcb mr4UrHeMF7bxWt3f8PEU8fe75ffCVhk= 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-280-tj2_vvt-PxSmzOnxbJoAxw-1; Tue, 09 Nov 2021 16:27:40 -0500 X-MC-Unique: tj2_vvt-PxSmzOnxbJoAxw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE03787D54C; Tue, 9 Nov 2021 21:27:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.37.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23BB710016F4; Tue, 9 Nov 2021 21:27:35 +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 2/5] folio: Add a function to get the host inode for a folio 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:35 +0000 Message-ID: <163649325519.309189.15072332908703129455.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.22 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a convenience function, folio_inode() that will get the host inode from a folio's mapping. Changes: ver #3: - Fix mistake in function description[2]. ver #2: - Fix contradiction between doc and implementation by disallowing use with swap caches[1]. Signed-off-by: David Howells Reviewed-by: Matthew Wilcox (Oracle) Tested-by: Jeff Layton Tested-by: Dominique Martinet Tested-by: kafs-testing@auristor.com Link: https://lore.kernel.org/r/YST8OcVNy02Rivbm@casper.infradead.org/ [1] Link: https://lore.kernel.org/r/YYKLkBwQdtn4ja+i@casper.infradead.org/ [2] Link: https://lore.kernel.org/r/162880453171.3369675.3704943108660112470.stgit@warthog.procyon.org.uk/ # rfc Link: https://lore.kernel.org/r/162981151155.1901565.7010079316994382707.stgit@warthog.procyon.org.uk/ Link: https://lore.kernel.org/r/163005744370.2472992.18324470937328925723.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163584184628.4023316.9386282630968981869.stgit@warthog.procyon.org.uk/ # v3 --- include/linux/pagemap.h | 14 ++++++++++++++ mm/page-writeback.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 1f560aecd9b5..1a0c646eb6ff 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -253,6 +253,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 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->host; +} + static inline bool page_cache_add_speculative(struct page *page, int count) { VM_BUG_ON_PAGE(PageTail(page), page); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 2d498bb62248..a613f8ef6a02 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2967,7 +2967,7 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); */ void folio_wait_stable(struct folio *folio) { - if (folio->mapping->host->i_sb->s_iflags & SB_I_STABLE_WRITES) + if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) folio_wait_writeback(folio); } EXPORT_SYMBOL_GPL(folio_wait_stable);