mm: Remove folio_test_single
[linux-2.6-block.git] / include / linux / pagemap.h
index 6a30916b76e541a5cd22897dafa0fac5beae23c6..1a0c646eb6ff7cf34ce2c79a29930c5b5af71201 100644 (file)
@@ -253,6 +253,20 @@ static inline struct address_space *page_mapping_file(struct page *page)
        return folio_mapping(folio);
 }
 
+/**
+ * folio_inode - Get the host inode for this folio.
+ * @folio: The folio.
+ *
+ * For folios which are in the page cache, return the inode that this folio
+ * belongs to.
+ *
+ * Do not call this for folios which aren't in the page cache.
+ */
+static inline struct inode *folio_inode(struct folio *folio)
+{
+       return folio->mapping->host;
+}
+
 static inline bool page_cache_add_speculative(struct page *page, int count)
 {
        VM_BUG_ON_PAGE(PageTail(page), page);
@@ -279,6 +293,25 @@ static inline void folio_attach_private(struct folio *folio, void *data)
        folio_set_private(folio);
 }
 
+/**
+ * folio_change_private - Change private data on a folio.
+ * @folio: Folio to change the data on.
+ * @data: Data to set on the folio.
+ *
+ * Change the private data attached to a folio and return the old
+ * data.  The page must previously have had data attached and the data
+ * must be detached before the folio will be freed.
+ *
+ * Return: Data that was previously attached to the folio.
+ */
+static inline void *folio_change_private(struct folio *folio, void *data)
+{
+       void *old = folio_get_private(folio);
+
+       folio->private = data;
+       return old;
+}
+
 /**
  * folio_detach_private - Detach private data from a folio.
  * @folio: Folio to detach data from.