From patchwork Fri Jan 26 13:28:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532568 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10EEDC47DDF for ; Fri, 26 Jan 2024 13:29:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 846096B0081; Fri, 26 Jan 2024 08:29:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F9716B0082; Fri, 26 Jan 2024 08:29:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 673826B0087; Fri, 26 Jan 2024 08:29:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4BF676B0081 for ; Fri, 26 Jan 2024 08:29:29 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2319FA2691 for ; Fri, 26 Jan 2024 13:29:29 +0000 (UTC) X-FDA: 81721544058.18.6D72490 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 7BFAEA0008 for ; Fri, 26 Jan 2024 13:29:27 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pum15BU6; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706275767; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EXl5jDeu7XONmlWbPRrm0Xu8RAKAjEJ+6x3o+QggOTo=; b=4R5C19UNeUp6Sa+mxynPSjYiIFglbw5aAjXw1/M5ELL4nX0rjiXDHjijGSCTR8JtuWFswE 8WL7JxnF81+jdGBD+JXdCbdhBMod8DCVIUiNybij+jIXb5BTp2XoHA5G77s3Gb1OJn/stY Zps7WfFpa7NVp6RVVfNKc0Syw99j4jw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pum15BU6; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275767; a=rsa-sha256; cv=none; b=gwDyIhUpOtjbJewDcFOef+Dr36ctv5+IlmdU9MLJh/nr5Ol/YQAQL+rnhYDFgCNim6UksM +NJH1BMxFnpmDJOPyG9RC7AOnZDh1382YPEfgIzf81rjTdhjNE393mNjHKATnQhwvn8ZNj ouEEh39klB1LgbBM2GLEWUMS1FjzU+0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=EXl5jDeu7XONmlWbPRrm0Xu8RAKAjEJ+6x3o+QggOTo=; b=pum15BU67e0aLpR1792YzR24oi MBaFfufHtCKkulLHA2z5SDqiyeUyDGOqykVa+NNtXdh7PNligs40WxGAynkcqKEJlXH4gbMBOARtv GRVUyHmGU/VqlPahIeBYDKyBRl7QUKQU0nFYi01Ic7e4cbH9acLTb2nBIRGxGdnW+oC1xSGSDhU5s rnVDBPv6nK+lRLt0CxXB6om0Czr+Ylfytg6QF1d8YX1TqaLJeYa2XMtRrGcWKyhoWm5iWzB5n76n7 jzpRM5Z9aTH5QS+ToEDinsikPO9sOsZZDWXVZqAj+dy2scmGcWaZ4ycSS21fnFlZhP+TQh+/uDm3O Sv3vMLDQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTMGq-00000004Cdo-46Cv; Fri, 26 Jan 2024 13:29:25 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/21] shmem: export shmem_get_folio Date: Fri, 26 Jan 2024 14:28:47 +0100 Message-Id: <20240126132903.2700077-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7BFAEA0008 X-Stat-Signature: nzt6ip4z3134e8fa73jziq3hpzdz3bk8 X-Rspam-User: X-HE-Tag: 1706275767-550884 X-HE-Meta: U2FsdGVkX18UT/bvIxjkYVD6Ex3FHmxVgnG1tp+1p6/YBezNEnCqlNHfSWU3WEET3R76h5ZaH9RE2sP5pNOmDqEc17CPPpHFAElF5r/54RBNrQpy+/XmB2LE+ZK6hJYtWEV8j7e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uQe9+k0TnkpZOqcowbFieKarLbO0zgNBEGRFmbFU21p15uARqou7AftmUm68z7so4QqzOj92OZz0hgG5d/rNQk8gP7g4GRRSBSHehlbydn/IvonjNEPSB3jh2G0AghguXSaTETNy5ztzZjg5i34Ow0wafmFgKv9YY8DtdbnCBUSt0e/bzlhLNAiLL5Sw1gCGPsjqWbaiZ+rAcMKVdNJybySJQfrdqJvebNIdPKHQtOmT3JaOfZk7aynR/WMIHTWEOpdx5YENed8Lz+YyDW5GDXpf/IY2RNItNOI6Xofc= 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: List-Subscribe: List-Unsubscribe: Export shmem_get_folio as a slightly lower-level variant of shmem_read_folio_gfp. This will be useful for XFS xfile use cases that want to pass SGP_NOALLOC or get a locked page, which the thin shmem_read_folio_gfp wrapper can't provide. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index ad533b2f0721a7..dae684cd3c99fb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2137,12 +2137,27 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return error; } +/** + * shmem_get_folio - find and get a reference to a shmem folio. + * @inode: inode to search + * @index: the page index. + * @foliop: pointer to the found folio if one was found + * @sgp: SGP_* flags to control behavior + * + * Looks up the page cache entry at @inode & @index. + * + * If this function returns a folio, it is returned with an increased refcount. + * + * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp + * and no folio was found at @index, or an ERR_PTR() otherwise. + */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp) { return shmem_get_folio_gfp(inode, index, foliop, sgp, mapping_gfp_mask(inode->i_mapping), NULL, NULL); } +EXPORT_SYMBOL_GPL(shmem_get_folio); /* * This is like autoremove_wake_function, but it removes the wait queue