Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: Convert __page_get_link() to use a folio

Retrieve a folio from the page cache instead of a page and operate
on it. Removes two hidden calls to compound_head().

Signed-off-by: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Link: https://lore.kernel.org/20250514171316.3002934-2-willy@infradead.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Matthew Wilcox (Oracle) and committed by
Christian Brauner
5f152cc0 4fae90d0

+10 -10
+10 -10
fs/namei.c
··· 5371 5371 static char *__page_get_link(struct dentry *dentry, struct inode *inode, 5372 5372 struct delayed_call *callback) 5373 5373 { 5374 - struct page *page; 5374 + struct folio *folio; 5375 5375 struct address_space *mapping = inode->i_mapping; 5376 5376 5377 5377 if (!dentry) { 5378 - page = find_get_page(mapping, 0); 5379 - if (!page) 5378 + folio = filemap_get_folio(mapping, 0); 5379 + if (IS_ERR(folio)) 5380 5380 return ERR_PTR(-ECHILD); 5381 - if (!PageUptodate(page)) { 5382 - put_page(page); 5381 + if (!folio_test_uptodate(folio)) { 5382 + folio_put(folio); 5383 5383 return ERR_PTR(-ECHILD); 5384 5384 } 5385 5385 } else { 5386 - page = read_mapping_page(mapping, 0, NULL); 5387 - if (IS_ERR(page)) 5388 - return (char*)page; 5386 + folio = read_mapping_folio(mapping, 0, NULL); 5387 + if (IS_ERR(folio)) 5388 + return ERR_CAST(folio); 5389 5389 } 5390 - set_delayed_call(callback, page_put_link, page); 5390 + set_delayed_call(callback, page_put_link, &folio->page); 5391 5391 BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM); 5392 - return page_address(page); 5392 + return folio_address(folio); 5393 5393 } 5394 5394 5395 5395 const char *page_get_link_raw(struct dentry *dentry, struct inode *inode,