Message ID | 20241120112037.822078-3-mjguzik@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | symlink length caching | expand |
On Wed 20-11-24 12:20:35, Mateusz Guzik wrote: > Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Looks good to me. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/ext4/inode.c | 3 ++- > fs/ext4/namei.c | 4 +++- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 89aade6f45f6..7c54ae5fcbd4 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -5006,10 +5006,11 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, > if (IS_ENCRYPTED(inode)) { > inode->i_op = &ext4_encrypted_symlink_inode_operations; > } else if (ext4_inode_is_fast_symlink(inode)) { > - inode->i_link = (char *)ei->i_data; > inode->i_op = &ext4_fast_symlink_inode_operations; > nd_terminate_link(ei->i_data, inode->i_size, > sizeof(ei->i_data) - 1); > + inode_set_cached_link(inode, (char *)ei->i_data, > + inode->i_size); > } else { > inode->i_op = &ext4_symlink_inode_operations; > } > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index bcf2737078b8..536d56d15072 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -3418,7 +3418,6 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, > inode->i_op = &ext4_symlink_inode_operations; > } else { > inode->i_op = &ext4_fast_symlink_inode_operations; > - inode->i_link = (char *)&EXT4_I(inode)->i_data; > } > } > > @@ -3434,6 +3433,9 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, > disk_link.len); > inode->i_size = disk_link.len - 1; > EXT4_I(inode)->i_disksize = inode->i_size; > + if (!IS_ENCRYPTED(inode)) > + inode_set_cached_link(inode, (char *)&EXT4_I(inode)->i_data, > + inode->i_size); > } > err = ext4_add_nondir(handle, dentry, &inode); > if (handle) > -- > 2.43.0 >
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 89aade6f45f6..7c54ae5fcbd4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5006,10 +5006,11 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, if (IS_ENCRYPTED(inode)) { inode->i_op = &ext4_encrypted_symlink_inode_operations; } else if (ext4_inode_is_fast_symlink(inode)) { - inode->i_link = (char *)ei->i_data; inode->i_op = &ext4_fast_symlink_inode_operations; nd_terminate_link(ei->i_data, inode->i_size, sizeof(ei->i_data) - 1); + inode_set_cached_link(inode, (char *)ei->i_data, + inode->i_size); } else { inode->i_op = &ext4_symlink_inode_operations; } diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index bcf2737078b8..536d56d15072 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3418,7 +3418,6 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, inode->i_op = &ext4_symlink_inode_operations; } else { inode->i_op = &ext4_fast_symlink_inode_operations; - inode->i_link = (char *)&EXT4_I(inode)->i_data; } } @@ -3434,6 +3433,9 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, disk_link.len); inode->i_size = disk_link.len - 1; EXT4_I(inode)->i_disksize = inode->i_size; + if (!IS_ENCRYPTED(inode)) + inode_set_cached_link(inode, (char *)&EXT4_I(inode)->i_data, + inode->i_size); } err = ext4_add_nondir(handle, dentry, &inode); if (handle)
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> --- fs/ext4/inode.c | 3 ++- fs/ext4/namei.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)