Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp47993rwi; Wed, 2 Nov 2022 09:11:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zyOdBxMJzXQcySfE3w7dUxdkmTNZ6RIe6IpEB222P/7GzS2QrskKCwHDySjksZkj9EiAC X-Received: by 2002:a17:90a:f001:b0:213:bf4:ee29 with SMTP id bt1-20020a17090af00100b002130bf4ee29mr42954591pjb.98.1667405505055; Wed, 02 Nov 2022 09:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405505; cv=none; d=google.com; s=arc-20160816; b=byWN/yASE1jQEoaahT99bCPKNPrczBYa9xoo5b5H78bguXsO/HtCfQEq6Lq3YJV7fn tRKizbpx3Fxd/r2WuUv8LK8LDtpbY/AqXxDTha8Wo249sYdSda4b69ZLJ7hwNphOSGmi rZfZEVjQZJH/1/fGRqKw5HPVSRbrn91zn5gxXnCbtBYrj0kKUlByw7QHJDxkQ/5Gkh9b aCNgNFbvsB/U9Z45Sslfre4c6GGKnNwbI+ImVXT2+ybmcYbwWqLkuk7UJfQ1qMeKruML sXBVBXbvAGiqsmB2A6w9Ni/BM5XVaCxbM9PpQzUGnztH3FoqQNuKV98YMnh7HbqdDYyZ iSSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=X60xt/zeAJ5sd2Vm94auFFKCU5VSw5KddInks2NvcFrqlUsJG92hRRQjToOeApqPRM UJt89ibwJyTKJnsZ+kmQ9E43/3bXjItW0/G66haIzYdQlWGYeIRKjzSpaqoEzFx94Z9h NBa94I2jBsWDl7sNqIVc8BrxxOJP0Vpz129bnIRTrvA25C1TzvwCsp0poqFqYG5naSyW BfqMDBejUopWyhEk3J9j2+IxvAj5z5AHLp+4o4a+uv7O6Ig1WF0T4xugtI5ozEyTqbIL P6FmJSskKCb4jsXGOJ+DyxxCTj+EOkninnp8jTcmdxTgPqDrC0sPIs3JQo9+glJZ/neN yE6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b22oyujJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r3-20020a63ec43000000b0046f6d8e7482si16568713pgj.229.2022.11.02.09.11.26; Wed, 02 Nov 2022 09:11:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b22oyujJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231312AbiKBQLO (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231288AbiKBQLJ (ORCPT ); Wed, 2 Nov 2022 12:11:09 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 599DA2B1A4; Wed, 2 Nov 2022 09:11:09 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 128so16663848pga.1; Wed, 02 Nov 2022 09:11:09 -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 :message-id:reply-to; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=b22oyujJhcmEnIoOWyXlmdwFsWtvDDEbrYWi+tTl/IKQZadCXIum/ufaWsfiuhgQWs P0ejMWAXsFFxmUJWgjcqRWL6iDvmTJOBHMdvrWNuXSDSGhujg7k49tnS+xBECZ0DDC1D QEeKOjhkuj2U1fYHa3KM1TSvYvE4FrIPOrf/CN/DjK2k7Ii76jHakZpfzft8GgAI2TOi 3dtL4HfeEfRRNgP7Mp0GAgu1ZDeKvnGqK9CY4nsrmEB3lEEy5PFMtwvBwHVV7JaSQ4Oc JqTTGwFIB+4o1Aa2ylRSznqsjRcz5BF5gANEbFRauGWLvr7/47QbInfDSn9b5QQsOYI/ 8XPQ== 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:message-id:reply-to; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=bZr6SYFBhkg2VMPqctbSETcwnfQl7anND/+vJLe0zdxMHOnOklnyfCxLdCly8B7WDB /JT/PmwbiTrND26z6HdJI6+4Kyn9h2gZICOkH5jmqLY4SwG1HVn8ffhEw2Xyp4C6Q8Z9 FDk5l/bVr0JdPA6T1Wg/UP3ftoieVLW9m8/xbxIlLBbqHYI4A+delvZNH7ZA8anuXLX3 C7PTnlqaHE9WqAe522eFeuqedReN6Z9+8V42oznMt/85JC2KchhRPbudbYEJ+vOZjFaO eJjYeQEPlCdsLH+PjnH3pKJWJneZuYlDfqjA5S1VsWV8OIWKJJ1PuSB6hJjYIrufDxqz BjLg== X-Gm-Message-State: ACrzQf0Hud1OdEkphoDf60hwbg9/iDjP6R0qU96/ZpL5U39kErGr4+hC ZhxNHn2Iojxd2IvFLpe/gIAF2fpiXae8uQ== X-Received: by 2002:a05:6a00:1253:b0:56d:8742:a9ff with SMTP id u19-20020a056a00125300b0056d8742a9ffmr15514058pfi.5.1667405468483; Wed, 02 Nov 2022 09:11:08 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:08 -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)" , Matthew Wilcox Subject: [PATCH v4 01/23] pagemap: Add filemap_grab_folio() Date: Wed, 2 Nov 2022 09:10:09 -0700 Message-Id: <20221102161031.5820-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bbccb4044222..74d87e37a142 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 -- 2.38.1