Merge branch 'kvm-guestmemfd' into HEAD
[linux-2.6-block.git] / include / linux / pagemap.h
index 351c3b7f93a14ee3e7edafb17dbe128cd0e755f9..bf2965b01b357f9de052c5da373de7acfbd958e5 100644 (file)
@@ -203,7 +203,8 @@ enum mapping_flags {
        /* writeback related tags are not used */
        AS_NO_WRITEBACK_TAGS = 5,
        AS_LARGE_FOLIO_SUPPORT = 6,
-       AS_RELEASE_ALWAYS,      /* Call ->release_folio(), even if no private data */
+       AS_RELEASE_ALWAYS = 7,  /* Call ->release_folio(), even if no private data */
+       AS_UNMOVABLE    = 8,    /* The mapping cannot be moved, ever */
 };
 
 /**
@@ -289,6 +290,22 @@ static inline void mapping_clear_release_always(struct address_space *mapping)
        clear_bit(AS_RELEASE_ALWAYS, &mapping->flags);
 }
 
+static inline void mapping_set_unmovable(struct address_space *mapping)
+{
+       /*
+        * It's expected unmovable mappings are also unevictable. Compaction
+        * migrate scanner (isolate_migratepages_block()) relies on this to
+        * reduce page locking.
+        */
+       set_bit(AS_UNEVICTABLE, &mapping->flags);
+       set_bit(AS_UNMOVABLE, &mapping->flags);
+}
+
+static inline bool mapping_unmovable(struct address_space *mapping)
+{
+       return test_bit(AS_UNMOVABLE, &mapping->flags);
+}
+
 static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
 {
        return mapping->gfp_mask;
@@ -789,9 +806,6 @@ static inline pgoff_t folio_next_index(struct folio *folio)
  */
 static inline struct page *folio_file_page(struct folio *folio, pgoff_t index)
 {
-       /* HugeTLBfs indexes the page cache in units of hpage_size */
-       if (folio_test_hugetlb(folio))
-               return &folio->page;
        return folio_page(folio, index & (folio_nr_pages(folio) - 1));
 }
 
@@ -807,9 +821,6 @@ static inline struct page *folio_file_page(struct folio *folio, pgoff_t index)
  */
 static inline bool folio_contains(struct folio *folio, pgoff_t index)
 {
-       /* HugeTLBfs indexes the page cache in units of hpage_size */
-       if (folio_test_hugetlb(folio))
-               return folio->index == index;
        return index - folio_index(folio) < folio_nr_pages(folio);
 }
 
@@ -867,10 +878,9 @@ static inline struct folio *read_mapping_folio(struct address_space *mapping,
 }
 
 /*
- * Get index of the page within radix-tree (but not for hugetlb pages).
- * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
+ * Get the offset in PAGE_SIZE (even for hugetlb pages).
  */
-static inline pgoff_t page_to_index(struct page *page)
+static inline pgoff_t page_to_pgoff(struct page *page)
 {
        struct page *head;
 
@@ -885,19 +895,6 @@ static inline pgoff_t page_to_index(struct page *page)
        return head->index + page - head;
 }
 
-extern pgoff_t hugetlb_basepage_index(struct page *page);
-
-/*
- * Get the offset in PAGE_SIZE (even for hugetlb pages).
- * (TODO: hugetlb pages should have ->index in PAGE_SIZE)
- */
-static inline pgoff_t page_to_pgoff(struct page *page)
-{
-       if (unlikely(PageHuge(page)))
-               return hugetlb_basepage_index(page);
-       return page_to_index(page);
-}
-
 /*
  * Return byte-offset into filesystem object for page.
  */
@@ -934,24 +931,16 @@ static inline loff_t folio_file_pos(struct folio *folio)
 
 /*
  * Get the offset in PAGE_SIZE (even for hugetlb folios).
- * (TODO: hugetlb folios should have ->index in PAGE_SIZE)
  */
 static inline pgoff_t folio_pgoff(struct folio *folio)
 {
-       if (unlikely(folio_test_hugetlb(folio)))
-               return hugetlb_basepage_index(&folio->page);
        return folio->index;
 }
 
-extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
-                                    unsigned long address);
-
 static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
                                        unsigned long address)
 {
        pgoff_t pgoff;
-       if (unlikely(is_vm_hugetlb_page(vma)))
-               return linear_hugepage_index(vma, address);
        pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
        pgoff += vma->vm_pgoff;
        return pgoff;
@@ -1129,6 +1118,7 @@ static inline void wait_on_page_locked(struct page *page)
        folio_wait_locked(page_folio(page));
 }
 
+void folio_end_read(struct folio *folio, bool success);
 void wait_on_page_writeback(struct page *page);
 void folio_wait_writeback(struct folio *folio);
 int folio_wait_writeback_killable(struct folio *folio);