]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm: Add folio_pgoff()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 3 Feb 2022 04:29:45 +0000 (23:29 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 21 Mar 2022 16:59:02 +0000 (12:59 -0400)
This is the folio equivalent of page_to_pgoff().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
include/linux/pagemap.h

index f968b36ad77141aa0df5b497730052a3e91bb217..a73c928e1d748de75a62c7c3768ea8141739c5a1 100644 (file)
@@ -817,6 +817,17 @@ static inline loff_t folio_file_pos(struct folio *folio)
        return page_file_offset(&folio->page);
 }
 
+/*
+ * 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);