[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230104211448.4804-2-vishal.moola@gmail.com>
Date: Wed, 4 Jan 2023 13:14:26 -0800
From: "Vishal Moola (Oracle)" <vishal.moola@...il.com>
To: linux-fsdevel@...r.kernel.org
Cc: linux-afs@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-btrfs@...r.kernel.org, ceph-devel@...r.kernel.org,
linux-cifs@...r.kernel.org, linux-ext4@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, cluster-devel@...hat.com,
linux-nilfs@...r.kernel.org, linux-mm@...ck.org,
"Vishal Moola (Oracle)" <vishal.moola@...il.com>,
Matthew Wilcox <willy@...radead.org>
Subject: [PATCH v5 01/23] pagemap: Add filemap_grab_folio()
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) <vishal.moola@...il.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@...radead.org>
---
include/linux/pagemap.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 29e1f9e76eb6..468183be67be 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -546,6 +546,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
Powered by blists - more mailing lists