From patchwork Thu Sep 1 22:01:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 12963264 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 1D9F3ECAAD3 for ; Thu, 1 Sep 2022 22:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 725288005C; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D3318000D; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 574268005C; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4348A8000D for ; Thu, 1 Sep 2022 18:02:37 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2D5A01C6107 for ; Thu, 1 Sep 2022 22:02:37 +0000 (UTC) X-FDA: 79864891554.16.6524401 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf13.hostedemail.com (Postfix) with ESMTP id E255620044 for ; Thu, 1 Sep 2022 22:02:36 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso3779273pjk.0 for ; Thu, 01 Sep 2022 15:02:36 -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=ghwmH7OBtODEG3q6T97VdwhOtKpgroD8O6/eJME6RxcE0RCt6y1f0k8Z+Nf438szjC f1Tz2jCtqotWMYX7jAfk8pOks8r2uw1MbNfVxQq0DoggwzPzqUI1rjL/zYCVH96CDWOv 6N+BySbmSBpBiAynr3+ZISEA0FDbCfqFR2qcMY0YXtQvpxu9mYXWpYrIjN0m8121kRUK taJIkqf7L0HTr7GIXny4HPFg0cC9mjsMx0m7GnMMBPB1n6WD1zCiOVAj8NMqjbSN/CwY UiWg2L5Utibhg+ppDHvNeQZKqE6Q7TMiSRDWsRr05n+F5Hbq6n90JrOCXpSrF4pvJHUr 61YA== 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=A7kpC8NmQZe9GrOen4yFyLZP8BJg5by8WFnRnJeWcUpra5vIO7pqmtV898ytRd2D2k HlVGbufaTmtFiB1NV0rYeIFrttm7tOwm+TvTC8VKKV/lOrynuFCKmKV8jOhEVpTOm6Nd G1gT17Hc7EV15yHBEaRp17Zh6SHkbveMkLl9DVHBZHR9F1JMvIVHRZiy+wHgBAtM6bz9 HK60hvrokhqY6gURH7cFaJ0tTf6EjD91yxb8bpfeSQlox9vc0/gC+tr8dAFbUJdGFLf0 rSjGKVUbv/NGmwN7+fVRCV5v2CcI5GwSedJyFpkSf5Hnjtmmvx7Oz6eASxngmq9f+VYR BHuA== X-Gm-Message-State: ACgBeo1F+9mBIkV8Cl5BWL+yysyeYB2FcBWAemLx1A6HKDbOEtlGguam HKMfnRGSj9sNIFDtycNkcLw= X-Google-Smtp-Source: AA6agR66279h5kRGOp1743YusbEZncu2V+e3ESCBIyAmjv+FQyjI4ExArRN8AnvHyGVWNl+1uieWjw== X-Received: by 2002:a17:902:e88c:b0:175:2471:8d8a with SMTP id w12-20020a170902e88c00b0017524718d8amr13575643plg.0.1662069755764; Thu, 01 Sep 2022 15:02:35 -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 fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:35 -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 01/23] pagemap: Add filemap_grab_folio() Date: Thu, 1 Sep 2022 15:01:16 -0700 Message-Id: <20220901220138.182896-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662069756; 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=sTUk5bPGxNIZTDWNu2MdF2QSZZVykMU739dpg5AFkZJfLAzRn1L2o1l7Iqz6D8rv+Acz8N gWpjkustIHuxuGjZGaqxpwUdkdnTEdGPXaZVgYqRheM+qKYIPNrLQD7RWf6fugN615NtRb x5aFXblamjekt7wNRdyGc1Q3z8pR74E= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ghwmH7OB; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 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=1662069756; a=rsa-sha256; cv=none; b=FObzZTSOrwKWrZrgfSHq1y+JXblpKVkpdDWcXrlwGFaoKoiede1FDbJUjZJFlpNocxmys4 IBN/D9rxtnPXyTXUSuAz2u+3zazJ7wCwnuv6wwN8+6Yo3DQ+MBuUDzJZpocCbkJa/PcUVN iL6zOnOCI06/nDrVtgTyJ5vMq8jTDqQ= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ghwmH7OB; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: 1ouowwoankck53dd3ewu64hajniw1cgf X-Rspamd-Queue-Id: E255620044 X-Rspamd-Server: rspam05 X-HE-Tag: 1662069756-911867 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