From patchwork Mon Jan 29 14:34: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: 13535763 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 2E315C47DB3 for ; Mon, 29 Jan 2024 14:35:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4BF6B00A4; Mon, 29 Jan 2024 09:35:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4C3D6B00A5; Mon, 29 Jan 2024 09:35:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C5706B00A7; Mon, 29 Jan 2024 09:35:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7262E6B00A4 for ; Mon, 29 Jan 2024 09:35:29 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4FB65C09B6 for ; Mon, 29 Jan 2024 14:35:28 +0000 (UTC) X-FDA: 81732596736.09.64CE016 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 6A6A1A001C for ; Mon, 29 Jan 2024 14:35:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dm2yohlU; spf=none (imf25.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706538926; 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=sbna0CyeYoAgz7SQMNzBd+8sEOvcwkV3+E75n3nY3SM=; b=p0uxiFUI8LfqMjsHfZ9KoyFBceNiNBCYT+i0tYldZ3gijZAbG28LS9+PSCbFVfvvIXnmZf 7ytBoqhfmDUrkx9iQtA1FDP1ZZ+yAbwtAvt26VlLZZnv+UNcgHQBGNrbvZ/ZDJ8Be7eEaT 9fI7a1NqsPJlTd3f2R/8JSxkIRlatXQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538926; a=rsa-sha256; cv=none; b=hfM+oArSNU3nlhhK/aDskLaV3+8gAEKW1HcjRJnuulnKYETZLJX6TNXU9qWTaOsOmo7/WT ja8IGSLWrO+z4ylApQ5mwONLGPQkLUsccQIbfn53POK9EB+LQ49i8OFU52CkTZkJKsGJ+r Di3t2H/goBOCyr0bqGzj8sJbQGK+K8E= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dm2yohlU; spf=none (imf25.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=sbna0CyeYoAgz7SQMNzBd+8sEOvcwkV3+E75n3nY3SM=; b=dm2yohlUA04AgYc6fUHgyd5ApS VtMMvtDqA8FvbyJvysLCIpRSRY+5tRypYODRbJMUkg5khV4Q/nGnnhVRtD6qUkAuCLagjA/jIENrl Zswq/LPZAay+AGzBNV3i1JB3OTqiuljlb+39qmDPrhF5twhzzM2LghfudqIXsIkISWSXFkrmL2WqW JZEL1RXUQLFF0OphQkjfcPn81igW3bBhLA0W+FYUkq3kqb3wNdhbY2PZ7a5viAzLJnd7tMvIoUalI 67M7TWNM979b6PEWzhM6kAf+Vo5QZpybOGg4fQ0CDo7KMKKx1epTdFPHPHRcJXcZ+3p0ask6+uJnB DxZS2doQ==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjL-0000000D69v-0T0M; Mon, 29 Jan 2024 14:35:23 +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, Matthew Wilcox Subject: [PATCH 05/20] shmem: export shmem_get_folio Date: Mon, 29 Jan 2024 15:34:47 +0100 Message-Id: <20240129143502.189370-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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-Queue-Id: 6A6A1A001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xrb31jx9knfsa5ouyi7neqq77s94co5y X-HE-Tag: 1706538926-851123 X-HE-Meta: U2FsdGVkX1+mryusjWTgUZmbKlTT+Zg4P6ana7gfsgNvi2qqS8aHOAXKtQ2gYloP1+Y7MLqg3OJBzP/GJVih/pRyskLD5+t9ncFfiV7oSFkFVKyKXONGmsrXImUeSwgjhAj1qTNr+ZQAjPHFDibk9zQbt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kspAq8YCDcfhjPD6LwU6OvY6YjPu4iXUDAABwE7qawMMJX1qEg4lRxDWEdzJe4eo1lQIdJkVO9BJZls34N9insTnudT5UAFrd2ehj20w2PvjF/C7qz4X13CVe9YQCszVxqmyuWtoP4BrEe7QKd/LF0YtkNwDuwU/7oiMaQr4rVnzLXPV+VRwmAhMQ/05R3oWqB9NExCVijrugyrwwNLSbo2pmSdJwGe2MLIyq9eCt7fu1nsw9KV50LAvZAddmfDftgZqDBi4PZ2wVvt4u2OlAX/+KprQuI9Wk7kfNgXD42hcw8O4BMn6G2pzdzjCsXXqKlfKyvjHdbAgx0oDYv6mIddHOs= 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: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong --- 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