[PATCH v4 04/15] ubifs: move fscrypt to filesystem inode

Christian Brauner
2025-07-23T10:58:15Z

Move fscrypt data pointer into the filesystem's private inode and record
the offset from the embedded struct inode.

This will allow us to drop the fscrypt data pointer from struct inode
itself and move it into the filesystem's inode.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/ubifs/crypto.c | 4 ++++
fs/ubifs/ubifs.h | 3 +++
2 files changed, 7 insertions(+)

diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c
index 921f9033d0d2..9f34ed9d5356 100644
--- a/fs/ubifs/crypto.c
+++ b/fs/ubifs/crypto.c
@@ -88,6 +88,10 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
}

const struct fscrypt_operations ubifs_crypt_operations = {
+#ifdef CONFIG_FS_ENCRYPTION
+ .inode_info_offs = offsetof(struct ubifs_inode, i_crypt_info) -
+ offsetof(struct ubifs_inode, vfs_inode),
+#endif
.legacy_key_prefix = "ubifs:",
.get_context = ubifs_crypt_get_context,
.set_context = ubifs_crypt_set_context,
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 256dbaeeb0de..6c1baa11e073 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -416,6 +416,9 @@ struct ubifs_inode {
pgoff_t read_in_a_row;
int data_len;
void *data;
+#ifdef CONFIG_FS_ENCRYPTION
+ struct fscrypt_inode_info *i_crypt_info;
+#endif
};

/**

--
2.47.2