From patchwork Mon Sep 12 18:22:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12973906 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 AA605C6FA82 for ; Mon, 12 Sep 2022 18:25:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08CC16B0073; Mon, 12 Sep 2022 14:25:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03CA76B0074; Mon, 12 Sep 2022 14:25:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5C178D0001; Mon, 12 Sep 2022 14:25:23 -0400 (EDT) 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 C3A3F6B0073 for ; Mon, 12 Sep 2022 14:25:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9AD64160DAA for ; Mon, 12 Sep 2022 18:25:23 +0000 (UTC) X-FDA: 79904260926.17.E351FDE Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf20.hostedemail.com (Postfix) with ESMTP id 587371C00AE for ; Mon, 12 Sep 2022 18:25:23 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id j12so9417155pfi.11 for ; Mon, 12 Sep 2022 11:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=+d28bepiquHWlxilFueNkEADr0o+je+NLAZFPUKTbIY=; b=UAvqeyyLl/jMM4GcLetiAfdFe+mfb9lKdBJfnSYldnUlLqvzEBn5ucL+x7WyU328TX 0/H9S52HSNuIFSWZ4YunFZhb9lMParyxzhpSfOriqzuEWl4nNQDfXBSCfd6PHcpEoArW hhkS/p47e7LTcdSDzPM5i4xcpSpua30NKF59fo2sfAm71y1h24VA6yU9gVJkZlr/HpKr kqbY0nqvYn5G/9BlH7ySmMvtkJ2+1WrYDojpVBZMQYHQaBxAnxx6msfYZA0Ac2gMEKOu fegLeVBCk9YxpsZnm6jcCKHOUZl7iJDeg1NFYcwjZsYJ40Ns924KMhs4Yi3zIL0Ak4bb eQXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=+d28bepiquHWlxilFueNkEADr0o+je+NLAZFPUKTbIY=; b=rdNL90aTbFiqtU9vPfBs7C87N8nnBMPlprTGnAA76FT2jtp/Fm0CVaXlWqeKEUL562 MwMJUrWsrjwjA61dZKNKqyVs3t9nMSWn8/MpnX3PcsOSAxDC80N5niNzDtBDMAwpJ5Ab J7dpf6W72Lu8bfnYqpc4UInRiF8VyJpeZy+1M32V8AUe3dhl6I7D5HGIOcvupEX9fx9c GAw9jcvRAmzRNVlBgPs+toIFi++jTQLmPpwApgUzXbOJLSP0IyKcZBAIL6wSJh3zT8uH e+uQ9L54pGJp0sljxWaV0EzVvEqi74MvRjA3De9m7RwIfJVgtu+M562XTmi7AlFfHnQE yDaQ== X-Gm-Message-State: ACgBeo2ZD7ePuSrftgm2brUaAZMSmE+SAaH+W8GjNr54dyrpN6KQjTfR WPpEMX3Cqgsj554pDNZm0xY= X-Google-Smtp-Source: AA6agR4Zy8VhOF+ibmC8k8zrBCfvKjb+HhgReHqq+fiRHDk/WfuNUZ7mRsbRn+TR1ll+VP/jfqTVhg== X-Received: by 2002:a05:6a00:1691:b0:53b:3f2c:3257 with SMTP id k17-20020a056a00169100b0053b3f2c3257mr28670886pfc.21.1663007122141; Mon, 12 Sep 2022 11:25:22 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id x127-20020a626385000000b0053b2681b0e0sm5916894pfb.39.2022.09.12.11.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 11:25:21 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v2 01/23] pagemap: Add filemap_grab_folio() Date: Mon, 12 Sep 2022 11:22:02 -0700 Message-Id: <20220912182224.514561-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220912182224.514561-1-vishal.moola@gmail.com> References: <20220912182224.514561-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UAvqeyyL; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663007123; a=rsa-sha256; cv=none; b=GVDWZWBzXLNYz+6lmO4s0mbrGzSgDxghKWCwNsshPQHRhez5MgZkHBBC3Az2dR3ETSNS3D EdvqwprxRWvVhvPhWTPoAsCZxhgdyOfjclKRFG8fstSju37LaK8sMShsBcTMus3t7T2ODS uMrmxtCXC54ZTD2lqNKPg9BcNEIFyQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663007123; 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=+d28bepiquHWlxilFueNkEADr0o+je+NLAZFPUKTbIY=; b=J4WVXnK84pKJFfJdbmIDPXawUBgxtUWccE1r84eOL9lfnEWw4u2wleHjh4i7EKqsguy63m nhnYMxhsBWNLXI3JTknHNliNnTkvfe9YZ0hpp9xXcNJGclx+IRSxh/jkZVIBf+2bOv7Tol L8oyZYeUMzgwX9Y4HQkcnQysqv/vqh8= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UAvqeyyL; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam12 X-Stat-Signature: wpihdoeoz35ushn4yno3mqg7x9x9wce5 X-Rspamd-Queue-Id: 587371C00AE X-Rspam-User: X-HE-Tag: 1663007123-570845 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 function filemap_grab_folio() to grab a folio from the page cache. This function is meant to serve as a folio replacement for grab_cache_page, and is used to facilitate the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0178b2040ea3..4d3092d6b2c0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -547,6 +547,26 @@ static inline struct folio *filemap_lock_folio(struct address_space *mapping, return __filemap_get_folio(mapping, index, FGP_LOCK, 0); } +/** + * filemap_grab_folio - grab a folio from the page cache + * @mapping: The address space to search + * @index: The page index + * + * Looks up the page cache entry at @mapping & @index. If no folio is found, + * a new folio is created. The folio is locked, marked as accessed, and + * returned. + * + * Return: A found or created folio. NULL if no folio is found and failed to + * create a folio. + */ +static inline struct folio *filemap_grab_folio(struct address_space *mapping, + pgoff_t index) +{ + return __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping)); +} + /** * find_get_page - find and get a page reference * @mapping: the address_space to search