Skip to content

Commit ab90c2d

Browse files
Eric Biggersbrauner
authored andcommitted
fs: remove inode::i_crypt_info
Now that all fscrypt-capable filesystems store the pointer to fscrypt_inode_info in the filesystem-specific part of the inode structure, inode::i_crypt_info is no longer needed. Update fscrypt_inode_info_addr() to no longer support the fallback to inode::i_crypt_info. Finally, remove inode::i_crypt_info itself along with the now-unnecessary forward declaration of fscrypt_inode_info. The end result of the migration to the filesystem-specific pointer is memory savings on CONFIG_FS_ENCRYPTION=y kernels for all filesystems that don't support fscrypt. Specifically, their in-memory inodes are now smaller by the size of a pointer: either 4 or 8 bytes. Co-developed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Link: https://lore.kernel.org/20250810075706.172910-8-ebiggers@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent bbe395d commit ab90c2d

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

include/linux/fs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ struct swap_info_struct;
7272
struct seq_file;
7373
struct workqueue_struct;
7474
struct iov_iter;
75-
struct fscrypt_inode_info;
7675
struct fscrypt_operations;
7776
struct fsverity_info;
7877
struct fsverity_operations;
@@ -780,10 +779,6 @@ struct inode {
780779
struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
781780
#endif
782781

783-
#ifdef CONFIG_FS_ENCRYPTION
784-
struct fscrypt_inode_info *i_crypt_info;
785-
#endif
786-
787782
#ifdef CONFIG_FS_VERITY
788783
struct fsverity_info *i_verity_info;
789784
#endif

include/linux/fscrypt.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,15 @@ struct fscrypt_operations {
201201
int fscrypt_d_revalidate(struct inode *dir, const struct qstr *name,
202202
struct dentry *dentry, unsigned int flags);
203203

204+
/*
205+
* Returns the address of the fscrypt info pointer within the
206+
* filesystem-specific part of the inode. (To save memory on filesystems that
207+
* don't support fscrypt, a field in 'struct inode' itself is no longer used.)
208+
*/
204209
static inline struct fscrypt_inode_info **
205210
fscrypt_inode_info_addr(const struct inode *inode)
206211
{
207-
if (inode->i_sb->s_cop->inode_info_offs == 0)
208-
return (struct fscrypt_inode_info **)&inode->i_crypt_info;
212+
VFS_WARN_ON_ONCE(inode->i_sb->s_cop->inode_info_offs == 0);
209213
return (void *)inode + inode->i_sb->s_cop->inode_info_offs;
210214
}
211215

0 commit comments

Comments
 (0)