Skip to content

Commit 4ec373b

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
fs: Pass a folio to page_put_link()
All callers now have a folio. Pass it to page_put_link(), saving a hidden call to compound_head(). Also add kernel-doc for page_get_link() and page_put_link(). Signed-off-by: "Matthew Wilcox (Oracle)" <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent cc8e87f commit 4ec373b

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

fs/fuse/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ static const char *fuse_get_link(struct dentry *dentry, struct inode *inode,
16761676
goto out_err;
16771677
}
16781678

1679-
set_delayed_call(callback, page_put_link, &folio->page);
1679+
set_delayed_call(callback, page_put_link, folio);
16801680

16811681
return folio_address(folio);
16821682

fs/namei.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5387,7 +5387,7 @@ static char *__page_get_link(struct dentry *dentry, struct inode *inode,
53875387
if (IS_ERR(folio))
53885388
return ERR_CAST(folio);
53895389
}
5390-
set_delayed_call(callback, page_put_link, &folio->page);
5390+
set_delayed_call(callback, page_put_link, folio);
53915391
BUG_ON(mapping_gfp_mask(mapping) & __GFP_HIGHMEM);
53925392
return folio_address(folio);
53935393
}
@@ -5399,6 +5399,17 @@ const char *page_get_link_raw(struct dentry *dentry, struct inode *inode,
53995399
}
54005400
EXPORT_SYMBOL_GPL(page_get_link_raw);
54015401

5402+
/**
5403+
* page_get_link() - An implementation of the get_link inode_operation.
5404+
* @dentry: The directory entry which is the symlink.
5405+
* @inode: The inode for the symlink.
5406+
* @callback: Used to drop the reference to the symlink.
5407+
*
5408+
* Filesystems which store their symlinks in the page cache should use
5409+
* this to implement the get_link() member of their inode_operations.
5410+
*
5411+
* Return: A pointer to the NUL-terminated symlink.
5412+
*/
54025413
const char *page_get_link(struct dentry *dentry, struct inode *inode,
54035414
struct delayed_call *callback)
54045415
{
@@ -5408,12 +5419,25 @@ const char *page_get_link(struct dentry *dentry, struct inode *inode,
54085419
nd_terminate_link(kaddr, inode->i_size, PAGE_SIZE - 1);
54095420
return kaddr;
54105421
}
5411-
54125422
EXPORT_SYMBOL(page_get_link);
54135423

5424+
/**
5425+
* page_put_link() - Drop the reference to the symlink.
5426+
* @arg: The folio which contains the symlink.
5427+
*
5428+
* This is used internally by page_get_link(). It is exported for use
5429+
* by filesystems which need to implement a variant of page_get_link()
5430+
* themselves. Despite the apparent symmetry, filesystems which use
5431+
* page_get_link() do not need to call page_put_link().
5432+
*
5433+
* The argument, while it has a void pointer type, must be a pointer to
5434+
* the folio which was retrieved from the page cache. The delayed_call
5435+
* infrastructure is used to drop the reference count once the caller
5436+
* is done with the symlink.
5437+
*/
54145438
void page_put_link(void *arg)
54155439
{
5416-
put_page(arg);
5440+
folio_put(arg);
54175441
}
54185442
EXPORT_SYMBOL(page_put_link);
54195443

fs/nfs/symlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const char *nfs_get_link(struct dentry *dentry,
6363
if (IS_ERR(folio))
6464
return ERR_CAST(folio);
6565
}
66-
set_delayed_call(done, page_put_link, &folio->page);
66+
set_delayed_call(done, page_put_link, folio);
6767
return folio_address(folio);
6868
}
6969

0 commit comments

Comments
 (0)