Skip to content

Commit ec84821

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
include/linux/pagemap.h: rename arguments to find_subpage
This isn't just a random struct page, it's known to be a head page, and calling it head makes the function better self-documenting. The pgoff_t is less confusing if it's named index instead of offset. Also add a couple of comments to explain why we're doing various things. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/20200318140253.6141-3-willy@infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e520e93 commit ec84821

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

include/linux/pagemap.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,19 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
333333
mapping_gfp_mask(mapping));
334334
}
335335

336-
static inline struct page *find_subpage(struct page *page, pgoff_t offset)
336+
/*
337+
* Given the page we found in the page cache, return the page corresponding
338+
* to this index in the file
339+
*/
340+
static inline struct page *find_subpage(struct page *head, pgoff_t index)
337341
{
338-
if (PageHuge(page))
339-
return page;
342+
/* HugeTLBfs wants the head page regardless */
343+
if (PageHuge(head))
344+
return head;
340345

341-
VM_BUG_ON_PAGE(PageTail(page), page);
346+
VM_BUG_ON_PAGE(PageTail(head), head);
342347

343-
return page + (offset & (compound_nr(page) - 1));
348+
return head + (index & (compound_nr(head) - 1));
344349
}
345350

346351
struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);

0 commit comments

Comments
 (0)