mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 06:04:44 +01:00
Merge patch series "Use folios for symlinks in the page cache"
Matthew Wilcox (Oracle) <willy@infradead.org> says: FUSE already uses folios for its symlinks. Mirror that conversion in the generic code and the NFS code. That lets us get rid of a few folio->page->folio conversions in this path, and some of the few remaining users of read_cache_page() / read_mapping_page(). * patches from https://lore.kernel.org/20250514171316.3002934-1-willy@infradead.org: fs: Pass a folio to page_put_link() nfs: Use a folio in nfs_get_link() fs: Convert __page_get_link() to use a folio Link: https://lore.kernel.org/20250514171316.3002934-1-willy@infradead.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
commit
76145cb37f
3 changed files with 47 additions and 23 deletions
|
|
@ -1676,7 +1676,7 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode,
|
|||
goto out_err;
|
||||
}
|
||||
|
||||
set_delayed_call(callback, page_put_link, &folio->page);
|
||||
set_delayed_call(callback, page_put_link, folio);
|
||||
|
||||
return folio_address(folio);
|
||||
|
||||
|
|
|
|||
48
fs/namei.c
48
fs/namei.c
|
|
@ -5371,25 +5371,25 @@ EXPORT_SYMBOL(vfs_get_link);
|
|||
static char *__page_get_link(struct dentry *dentry, struct inode *inode,
|
||||
struct delayed_call *callback)
|
||||
{
|
||||
struct page *page;
|
||||
struct folio *folio;
|
||||
struct address_space *mapping = inode->i_mapping;
|
||||
|
||||
if (!dentry) {
|
||||
page = find_get_page(mapping, 0);
|
||||
if (!page)
|
||||
folio = filemap_get_folio(mapping, 0);
|
||||
if (IS_ERR(folio))
|
||||
return ERR_PTR(-ECHILD);
|
||||
if (!PageUptodate(page)) {
|
||||
put_page(page);
|
||||
if (!folio_test_uptodate(folio)) {
|
||||
folio_put(folio);
|
||||
return ERR_PTR(-ECHILD);
|
||||
}
|
||||
} else {
|
||||
page = read_mapping_page(mapping, 0, NULL);
|
||||
if (IS_ERR(page))
|
||||
return (char*)page;
|
||||
folio = read_mapping_folio(mapping, 0, NULL);
|
||||
if (IS_ERR(folio))
|
||||
return ERR_CAST(folio);
|
||||
}
|
||||
set_delayed_call(callback, page_put_link, page);
|
||||
set_delayed_call(callback, page_put_link, folio);
|
||||
BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM);
|
||||
return page_address(page);
|
||||
return folio_address(folio);
|
||||
}
|
||||
|
||||
const char *page_get_link_raw(struct dentry *dentry, struct inode *inode,
|
||||
|
|
@ -5399,6 +5399,17 @@ const char *page_get_link_raw(struct dentry *dentry, struct inode *inode,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(page_get_link_raw);
|
||||
|
||||
/**
|
||||
* page_get_link() - An implementation of the get_link inode_operation.
|
||||
* @dentry: The directory entry which is the symlink.
|
||||
* @inode: The inode for the symlink.
|
||||
* @callback: Used to drop the reference to the symlink.
|
||||
*
|
||||
* Filesystems which store their symlinks in the page cache should use
|
||||
* this to implement the get_link() member of their inode_operations.
|
||||
*
|
||||
* Return: A pointer to the NUL-terminated symlink.
|
||||
*/
|
||||
const char *page_get_link(struct dentry *dentry, struct inode *inode,
|
||||
struct delayed_call *callback)
|
||||
{
|
||||
|
|
@ -5408,12 +5419,25 @@ const char *page_get_link(struct dentry *dentry, struct inode *inode,
|
|||
nd_terminate_link(kaddr, inode->i_size, PAGE_SIZE - 1);
|
||||
return kaddr;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(page_get_link);
|
||||
|
||||
/**
|
||||
* page_put_link() - Drop the reference to the symlink.
|
||||
* @arg: The folio which contains the symlink.
|
||||
*
|
||||
* This is used internally by page_get_link(). It is exported for use
|
||||
* by filesystems which need to implement a variant of page_get_link()
|
||||
* themselves. Despite the apparent symmetry, filesystems which use
|
||||
* page_get_link() do not need to call page_put_link().
|
||||
*
|
||||
* The argument, while it has a void pointer type, must be a pointer to
|
||||
* the folio which was retrieved from the page cache. The delayed_call
|
||||
* infrastructure is used to drop the reference count once the caller
|
||||
* is done with the symlink.
|
||||
*/
|
||||
void page_put_link(void *arg)
|
||||
{
|
||||
put_page(arg);
|
||||
folio_put(arg);
|
||||
}
|
||||
EXPORT_SYMBOL(page_put_link);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,31 +40,31 @@ static const char *nfs_get_link(struct dentry *dentry,
|
|||
struct inode *inode,
|
||||
struct delayed_call *done)
|
||||
{
|
||||
struct page *page;
|
||||
struct folio *folio;
|
||||
void *err;
|
||||
|
||||
if (!dentry) {
|
||||
err = ERR_PTR(nfs_revalidate_mapping_rcu(inode));
|
||||
if (err)
|
||||
return err;
|
||||
page = find_get_page(inode->i_mapping, 0);
|
||||
if (!page)
|
||||
folio = filemap_get_folio(inode->i_mapping, 0);
|
||||
if (IS_ERR(folio))
|
||||
return ERR_PTR(-ECHILD);
|
||||
if (!PageUptodate(page)) {
|
||||
put_page(page);
|
||||
if (!folio_test_uptodate(folio)) {
|
||||
folio_put(folio);
|
||||
return ERR_PTR(-ECHILD);
|
||||
}
|
||||
} else {
|
||||
err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping));
|
||||
if (err)
|
||||
return err;
|
||||
page = read_cache_page(&inode->i_data, 0, nfs_symlink_filler,
|
||||
folio = read_cache_folio(&inode->i_data, 0, nfs_symlink_filler,
|
||||
NULL);
|
||||
if (IS_ERR(page))
|
||||
return ERR_CAST(page);
|
||||
if (IS_ERR(folio))
|
||||
return ERR_CAST(folio);
|
||||
}
|
||||
set_delayed_call(done, page_put_link, page);
|
||||
return page_address(page);
|
||||
set_delayed_call(done, page_put_link, folio);
|
||||
return folio_address(folio);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue