diff mbox series

[v3,3/3] tmpfs: use inode_set_cached_link()

Message ID 20241120112037.822078-4-mjguzik@gmail.com (mailing list archive)
State New
Headers show
Series symlink length caching | expand

Commit Message

Mateusz Guzik Nov. 20, 2024, 11:20 a.m. UTC
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 mm/shmem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Jan Kara Nov. 21, 2024, 11:59 a.m. UTC | #1
On Wed 20-11-24 12:20:36, Mateusz Guzik wrote:
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  mm/shmem.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index c7881e16f4be..135f38eb2ff1 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3868,6 +3868,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  	int len;
>  	struct inode *inode;
>  	struct folio *folio;
> +	char *link;
>  
>  	len = strlen(symname) + 1;
>  	if (len > PAGE_SIZE)
> @@ -3889,12 +3890,13 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
>  
>  	inode->i_size = len-1;
>  	if (len <= SHORT_SYMLINK_LEN) {
> -		inode->i_link = kmemdup(symname, len, GFP_KERNEL);
> -		if (!inode->i_link) {
> +		link = kmemdup(symname, len, GFP_KERNEL);
> +		if (!link) {
>  			error = -ENOMEM;
>  			goto out_remove_offset;
>  		}
>  		inode->i_op = &shmem_short_symlink_operations;
> +		inode_set_cached_link(inode, link, len - 1);
>  	} else {
>  		inode_nohighmem(inode);
>  		inode->i_mapping->a_ops = &shmem_aops;
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index c7881e16f4be..135f38eb2ff1 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3868,6 +3868,7 @@  static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
 	int len;
 	struct inode *inode;
 	struct folio *folio;
+	char *link;
 
 	len = strlen(symname) + 1;
 	if (len > PAGE_SIZE)
@@ -3889,12 +3890,13 @@  static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
 
 	inode->i_size = len-1;
 	if (len <= SHORT_SYMLINK_LEN) {
-		inode->i_link = kmemdup(symname, len, GFP_KERNEL);
-		if (!inode->i_link) {
+		link = kmemdup(symname, len, GFP_KERNEL);
+		if (!link) {
 			error = -ENOMEM;
 			goto out_remove_offset;
 		}
 		inode->i_op = &shmem_short_symlink_operations;
+		inode_set_cached_link(inode, link, len - 1);
 	} else {
 		inode_nohighmem(inode);
 		inode->i_mapping->a_ops = &shmem_aops;