From patchwork Wed Jan 3 08:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509719 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 51A9CC3DA6E for ; Wed, 3 Jan 2024 08:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2F458D0034; Wed, 3 Jan 2024 03:41:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DDEE26B032A; Wed, 3 Jan 2024 03:41:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCE4A8D0034; Wed, 3 Jan 2024 03:41:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BDD036B0329 for ; Wed, 3 Jan 2024 03:41:48 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8AC55A1289 for ; Wed, 3 Jan 2024 08:41:48 +0000 (UTC) X-FDA: 81637356696.19.549A74B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id D01522000A for ; Wed, 3 Jan 2024 08:41:46 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XniNRlGp; dmarc=none; spf=none (imf03.hostedemail.com: domain of BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f852f126c6d693376302+7437+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=1704271306; 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=JlH8UoH4gf0aBQ2yCBHbzkzUIg8ZGDdici8nR6/XNN8=; b=Az7HhHj+S0CeifASTHzBNMdjsO2or9yDSCQ0typ3XMQdhuXmVv1aIpInvmi4KtwSxneudv 36wPqhN3Fr0d0ej0CJbTvOl5xEVAERQ0Lz2P8umiQ3XTz4+Kqkhp1oVI/DyQmfzjsQJgQR 2w/cwUUHWrNkJHukuPHhnlKHr50UgYA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XniNRlGp; dmarc=none; spf=none (imf03.hostedemail.com: domain of BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271306; a=rsa-sha256; cv=none; b=e5RMhxoZlqswgkbdxdXZBLbOmpOyQUR0iW7Ax//IuBRChJBt6Y8s2sD2wrQprwnl81T40N 6vpx4YJ7atHJc8r9VPw3fknG6kU/u4DFUKgKXX5lPkh/mYNP17K742NZOE5F+vm0w7vAG4 Z1s29KEZMoYzATTYXrsOKsBmB/PnV/M= 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=JlH8UoH4gf0aBQ2yCBHbzkzUIg8ZGDdici8nR6/XNN8=; b=XniNRlGp7AkbZwALFoj2xvXQnH vPjeUfHlMb/q3zWmlZnIKQd2+AhipEq0AZ6VRzSPPbH4l2wvCPEMVQr0UsJxiri77g/VS34FQSX1g dqGZOGTTWh1fIa1XiGqZ8nADwC/L5Yq1PgFG7fQq650+EypgpZITgP2HmrqKmQW34myrNmhghWcrO vPH+ufeoy3igPt4HF8hdf8dvxVi0qWJR8/hCnwMS0IKq3NFrXsekcarEER0wl4iGHtcVOWkZ8rahz tyuiw6lyqNOWyU4JmZU2z5COeDjvufmF+I9E7j8rpm1wJgxv3NNducuerNKI09/fVpdEh6zprmnTA 7Ic53zBg==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwon-00A6Y4-0n; Wed, 03 Jan 2024 08:41:41 +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 02/15] shmem: export shmem_get_folio Date: Wed, 3 Jan 2024 08:41:13 +0000 Message-Id: <20240103084126.513354-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103084126.513354-1-hch@lst.de> References: <20240103084126.513354-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D01522000A X-Stat-Signature: fu3aebjkghtku5q8txt5ye55tqjdbb4j X-HE-Tag: 1704271306-851001 X-HE-Meta: U2FsdGVkX18rSuMzGClD0GJXja47IIZK18fxDHJWpbUiH52ErcO16/Osl8TeR6Djd6ZTDtWH4YQ/a2cmCbhn5O+p7O3bAtbmD1ZPyMOewZPcsolwK/sE622nI9DZLVmmaM7/mmWr/jn02p3SsdKUjB1r8V9Dn2+/PgQPQMtOEExWvl0tIZWeAIT+OGMegD8A2n8QUD7yupFcDBzfzM6CitBrPcvyDGcSz8p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h/KdZKMqvrlodCb7Kh6HlWEWngJqdSnSp/tasvz7/7GGHDF1wTbuyrp8p6o8HSt5g5WjTkTp4UQVB1fthMm1Cpwt55KkezlHDKUujKUzoUqzAbG/HF79BdqHvn0qkuVbxQ== 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 --- mm/shmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 3349df6d4e0360..328eb3dbea9f1c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2116,12 +2116,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