From: Matthew Wilcox (Oracle) Date: Thu, 3 Feb 2022 04:29:45 +0000 (-0500) Subject: mm: Add folio_pgoff() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f087b903fc2e4975bff9742a66ee7a837a2f545b;p=linux.git mm: Add folio_pgoff() This is the folio equivalent of page_to_pgoff(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index f968b36ad7714..a73c928e1d748 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -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);