[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190418232923.250800-5-ebiggers@kernel.org>
Date: Thu, 18 Apr 2019 16:29:11 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: linux-fscrypt@...r.kernel.org
Cc: Satya Tangirala <satyat@...gle.com>, linux-api@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, keyrings@...r.kernel.org,
linux-mtd@...ts.infradead.org, linux-crypto@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
Paul Crowley <paulcrowley@...gle.com>
Subject: [PATCH v5 04/16] fscrypt: add ->ci_inode to fscrypt_info
From: Eric Biggers <ebiggers@...gle.com>
Add an inode back-pointer to 'struct fscrypt_info', such that
inode->i_crypt_info->ci_inode == inode.
This will be useful for:
1. Evicting the inodes when a fscrypt key is removed, since we'll track
the inodes using a given key by linking their fscrypt_infos together,
rather than the inodes directly. This avoids bloating 'struct inode'
with a new list_head.
2. Simplifying the per-file key setup, since the inode pointer won't
have to be passed around everywhere just in case something goes wrong
and it's needed for fscrypt_warn().
Signed-off-by: Eric Biggers <ebiggers@...gle.com>
---
fs/crypto/fscrypt_private.h | 3 +++
fs/crypto/keyinfo.c | 2 ++
2 files changed, 5 insertions(+)
diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
index 52e09ef40bfa6..ac24edfc297f1 100644
--- a/fs/crypto/fscrypt_private.h
+++ b/fs/crypto/fscrypt_private.h
@@ -73,6 +73,9 @@ struct fscrypt_info {
*/
struct fscrypt_mode *ci_mode;
+ /* Back-pointer to the inode */
+ struct inode *ci_inode;
+
/*
* If non-NULL, then this inode uses a master key directly rather than a
* derived key, and ci_ctfm will equal ci_master_key->mk_ctfm.
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 16349894ef91d..ed253262b0195 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -542,6 +542,8 @@ int fscrypt_get_encryption_info(struct inode *inode)
if (!crypt_info)
return -ENOMEM;
+ crypt_info->ci_inode = inode;
+
crypt_info->ci_flags = ctx.flags;
crypt_info->ci_data_mode = ctx.contents_encryption_mode;
crypt_info->ci_filename_mode = ctx.filenames_encryption_mode;
--
2.21.0.392.gf8f6787159e-goog
Powered by blists - more mailing lists