From: Christian Brauner <brauner@kernel.org>
To: Jeff Layton <jlayton@kernel.org>, Jan Kara <jack@suse.com>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
Josef Bacik <josef@toxicpanda.com>
Cc: Christian Brauner <brauner@kernel.org>,
Eric Biggers <ebiggers@kernel.org>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org,
fsverity@lists.linux.dev
Subject: [PATCH v3 07/13] fs: drop i_crypt_info from struct inode
Date: Tue, 22 Jul 2025 21:27:25 +0200 [thread overview]
Message-ID: <20250722-work-inode-fscrypt-v3-7-bdc1033420a0@kernel.org> (raw)
In-Reply-To: <20250722-work-inode-fscrypt-v3-0-bdc1033420a0@kernel.org>
Now that all filesystems store the fscrypt data pointer in their private
inode, drop the data pointer from struct inode itself freeing up 8
bytes.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/crypto/fscrypt_private.h | 2 +-
fs/crypto/keysetup.c | 25 ++++++++++++-------------
include/linux/fs.h | 4 ----
include/linux/fscrypt.h | 21 ++++++---------------
4 files changed, 19 insertions(+), 33 deletions(-)
diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
index c1d92074b65c..53a72dc909d9 100644
--- a/fs/crypto/fscrypt_private.h
+++ b/fs/crypto/fscrypt_private.h
@@ -231,7 +231,7 @@ struct fscrypt_prepared_key {
* fscrypt_inode_info - the "encryption key" for an inode
*
* When an encrypted file's key is made available, an instance of this struct is
- * allocated and stored in ->i_crypt_info. Once created, it remains until the
+ * allocated and stored in ->i_fscrypt_info. Once created, it remains until the
* inode is evicted.
*/
struct fscrypt_inode_info {
diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
index 0f0ebe819783..13fe17d87e97 100644
--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -639,14 +639,14 @@ fscrypt_setup_encryption_info(struct inode *inode,
goto out;
/*
- * For existing inodes, multiple tasks may race to set ->i_crypt_info.
+ * For existing inodes, multiple tasks may race to set ->i_fscrypt_info.
* So use cmpxchg_release(). This pairs with the smp_load_acquire() in
- * fscrypt_get_inode_info(). I.e., here we publish ->i_crypt_info with
+ * fscrypt_get_inode_info(). I.e., here we publish ->i_fscrypt_info with
* a RELEASE barrier so that other tasks can ACQUIRE it.
*/
if (fscrypt_set_inode_info(inode, crypt_info)) {
/*
- * We won the race and set ->i_crypt_info to our crypt_info.
+ * We won the race and set ->i_fscrypt_info to our crypt_info.
* Now link it into the master key's inode list.
*/
if (mk) {
@@ -678,12 +678,12 @@ fscrypt_setup_encryption_info(struct inode *inode,
* %false unless the operation being performed is needed in
* order for files (or directories) to be deleted.
*
- * Set up ->i_crypt_info, if it hasn't already been done.
+ * Set up ->i_fscrypt_info, if it hasn't already been done.
*
- * Note: unless ->i_crypt_info is already set, this isn't %GFP_NOFS-safe. So
+ * Note: unless ->i_fscrypt_info is already set, this isn't %GFP_NOFS-safe. So
* generally this shouldn't be called from within a filesystem transaction.
*
- * Return: 0 if ->i_crypt_info was set or was already set, *or* if the
+ * Return: 0 if ->i_fscrypt_info was set or was already set, *or* if the
* encryption key is unavailable. (Use fscrypt_has_encryption_key() to
* distinguish these cases.) Also can return another -errno code.
*/
@@ -738,9 +738,9 @@ int fscrypt_get_encryption_info(struct inode *inode, bool allow_unsupported)
* ->i_ino doesn't need to be set yet.
* @encrypt_ret: (output) set to %true if the new inode will be encrypted
*
- * If the directory is encrypted, set up its ->i_crypt_info in preparation for
+ * If the directory is encrypted, set up its ->i_fscrypt_info in preparation for
* encrypting the name of the new file. Also, if the new inode will be
- * encrypted, set up its ->i_crypt_info and set *encrypt_ret=true.
+ * encrypted, set up its ->i_fscrypt_info and set *encrypt_ret=true.
*
* This isn't %GFP_NOFS-safe, and therefore it should be called before starting
* any filesystem transaction to create the inode. For this reason, ->i_ino
@@ -799,12 +799,11 @@ void fscrypt_put_encryption_info(struct inode *inode)
{
struct fscrypt_inode_info **crypt_info;
- if (inode->i_sb->s_op->i_fscrypt)
+ if (inode->i_sb->s_op->i_fscrypt) {
crypt_info = fscrypt_addr(inode);
- else
- crypt_info = &inode->i_crypt_info;
- put_crypt_info(*crypt_info);
- *crypt_info = NULL;
+ put_crypt_info(*crypt_info);
+ *crypt_info = NULL;
+ }
}
EXPORT_SYMBOL(fscrypt_put_encryption_info);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 991089969e71..a2bf23b51bb9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -778,10 +778,6 @@ struct inode {
struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
#endif
-#ifdef CONFIG_FS_ENCRYPTION
- struct fscrypt_inode_info *i_crypt_info;
-#endif
-
#ifdef CONFIG_FS_VERITY
struct fsverity_info *i_verity_info;
#endif
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index 685780ce3579..988e48ea9775 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -203,28 +203,20 @@ static inline struct fscrypt_inode_info **fscrypt_addr(const struct inode *inode
static inline bool fscrypt_set_inode_info(struct inode *inode,
struct fscrypt_inode_info *crypt_info)
{
- void *p;
-
/*
- * For existing inodes, multiple tasks may race to set ->i_crypt_info.
+ * For existing inodes, multiple tasks may race to set ->i_fscrypt_info.
* So use cmpxchg_release(). This pairs with the smp_load_acquire() in
- * fscrypt_get_inode_info(). I.e., here we publish ->i_crypt_info with
+ * fscrypt_get_inode_info(). I.e., here we publish ->i_fscrypt_info with
* a RELEASE barrier so that other tasks can ACQUIRE it.
*/
- if (inode->i_sb->s_op->i_fscrypt)
- p = cmpxchg_release(fscrypt_addr(inode), NULL, crypt_info);
- else
- p = cmpxchg_release(&inode->i_crypt_info, NULL, crypt_info);
- return p == NULL;
+ return cmpxchg_release(fscrypt_addr(inode), NULL, crypt_info) == NULL;
}
static inline struct fscrypt_inode_info *
fscrypt_get_inode_info_raw(const struct inode *inode)
{
- if (inode->i_sb->s_op->i_fscrypt)
- return *fscrypt_addr(inode);
- return inode->i_crypt_info;
+ return *fscrypt_addr(inode);
}
static inline struct fscrypt_inode_info *
@@ -232,15 +224,14 @@ fscrypt_get_inode_info(const struct inode *inode)
{
/*
* Pairs with the cmpxchg_release() in fscrypt_setup_encryption_info().
- * I.e., another task may publish ->i_crypt_info concurrently, executing
+ * I.e., another task may publish ->i_fscrypt_info concurrently, executing
* a RELEASE barrier. We need to use smp_load_acquire() here to safely
* ACQUIRE the memory the other task published.
*/
if (inode->i_sb->s_op->i_fscrypt)
return smp_load_acquire(fscrypt_addr(inode));
-
- return smp_load_acquire(&inode->i_crypt_info);
+ return NULL;
}
/**
--
2.47.2
next prev parent reply other threads:[~2025-07-22 19:28 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 14:35 [PATCH RFC DRAFT DOESNOTBUILD] inode: free up more space Christian Brauner
2025-07-15 14:52 ` Jeff Layton
2025-07-15 16:09 ` Matthew Wilcox
2025-07-16 12:53 ` Christian Brauner
2025-07-16 13:02 ` Christoph Hellwig
2025-07-17 7:48 ` Christian Brauner
2025-07-17 7:51 ` Christoph Hellwig
2025-07-17 15:55 ` Darrick J. Wong
2025-07-16 9:15 ` Jan Kara
2025-07-16 9:50 ` Christian Brauner
2025-07-16 11:21 ` Christoph Hellwig
2025-07-16 12:19 ` Christian Brauner
2025-07-16 12:38 ` Jeff Layton
2025-07-16 14:08 ` Matthew Wilcox
2025-07-16 14:10 ` Christoph Hellwig
2025-07-17 8:32 ` Christian Brauner
2025-07-17 10:54 ` Jan Kara
2025-07-17 11:40 ` Christian Brauner
2025-07-17 11:43 ` Christoph Hellwig
2025-07-17 12:57 ` Jan Kara
2025-07-18 8:24 ` Christian Brauner
2025-07-18 8:32 ` Christoph Hellwig
2025-07-18 8:58 ` Christian Brauner
2025-07-18 16:04 ` Eric Biggers
2025-07-18 17:11 ` Eric Biggers
2025-07-21 6:14 ` Christoph Hellwig
2025-07-21 23:55 ` Eric Biggers
2025-07-22 5:49 ` Christoph Hellwig
2025-07-22 7:52 ` Jan Kara
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 00/13] Move fscrypt and fsverity out of struct inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 01/13] fs: add fscrypt offset Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 02/13] fs/crypto: use accessors Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 03/13] ext4: move fscrypt to filesystem inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 04/13] ubifs: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 05/13] f2fs: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 06/13] ceph: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 07/13] fs: drop i_crypt_info from struct inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 08/13] fs: add fsverity offset Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 09/13] fs/verity: use accessors Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 10/13] btrfs: move fsverity to filesystem inode Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 11/13] ext4: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 12/13] f2fs: " Christian Brauner
2025-07-22 12:57 ` [PATCH RFC DRAFT v2 13/13] fs: drop i_verity_info from struct inode Christian Brauner
2025-07-22 13:09 ` [PATCH RFC DRAFT v2 00/13] Move fscrypt and fsverity out of " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 01/13] fs: add fscrypt offset Christian Brauner
2025-07-22 20:02 ` Eric Biggers
2025-07-23 7:48 ` Christian Brauner
2025-07-23 3:49 ` Al Viro
2025-07-22 19:27 ` [PATCH v3 02/13] fs/crypto: use accessors Christian Brauner
2025-07-22 19:27 ` [PATCH v3 03/13] ext4: move fscrypt to filesystem inode Christian Brauner
2025-07-22 20:07 ` Eric Biggers
2025-07-23 8:59 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 04/13] ubifs: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 05/13] f2fs: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 06/13] ceph: " Christian Brauner
2025-07-22 20:14 ` Eric Biggers
2025-07-23 8:58 ` Christian Brauner
2025-07-22 19:27 ` Christian Brauner [this message]
2025-07-22 20:19 ` [PATCH v3 07/13] fs: drop i_crypt_info from struct inode Eric Biggers
2025-07-23 8:52 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 08/13] fs: add fsverity offset Christian Brauner
2025-07-23 3:53 ` Al Viro
2025-07-22 19:27 ` [PATCH v3 09/13] fs/verity: use accessors Christian Brauner
2025-07-22 20:25 ` Eric Biggers
2025-07-23 8:55 ` Christian Brauner
2025-07-22 19:27 ` [PATCH v3 10/13] btrfs: move fsverity to filesystem inode Christian Brauner
2025-07-22 19:27 ` [PATCH v3 11/13] ext4: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 12/13] f2fs: " Christian Brauner
2025-07-22 19:27 ` [PATCH v3 13/13] fs: drop i_verity_info from struct inode Christian Brauner
2025-07-23 10:57 ` [PATCH v4 00/15] Move fscrypt and fsverity out of " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 01/15] fs: add fscrypt offset Christian Brauner
2025-07-23 10:57 ` [PATCH v4 02/15] fs/crypto: use accessors Christian Brauner
2025-07-25 0:29 ` Eric Biggers
2025-07-25 4:01 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 03/15] ext4: move fscrypt to filesystem inode Christian Brauner
2025-07-25 0:32 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 04/15] ubifs: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 05/15] f2fs: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 06/15] ceph: " Christian Brauner
2025-07-25 0:34 ` Eric Biggers
2025-07-25 8:15 ` Christian Brauner
2025-07-23 10:57 ` [PATCH v4 07/15] fs: drop i_crypt_info from struct inode Christian Brauner
2025-07-25 0:38 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 08/15] fscrypt: rephrase documentation and comments Christian Brauner
2025-07-25 0:35 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 09/15] fs: add fsverity offset Christian Brauner
2025-07-25 0:45 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 10/15] fs/verity: use accessors Christian Brauner
2025-07-23 10:57 ` [PATCH v4 11/15] btrfs: move fsverity to filesystem inode Christian Brauner
2025-07-23 10:57 ` [PATCH v4 12/15] ext4: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 13/15] f2fs: " Christian Brauner
2025-07-23 10:57 ` [PATCH v4 14/15] fs: drop i_verity_info from struct inode Christian Brauner
2025-07-25 0:43 ` Eric Biggers
2025-07-23 10:57 ` [PATCH v4 15/15] fsverity: rephrase documentation and comments Christian Brauner
2025-07-22 13:50 ` [PATCH RFC DRAFT v2 00/13] Move fscrypt and fsverity out of struct inode Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250722-work-inode-fscrypt-v3-7-bdc1033420a0@kernel.org \
--to=brauner@kernel.org \
--cc=axboe@kernel.dk \
--cc=ebiggers@kernel.org \
--cc=fsverity@lists.linux.dev \
--cc=hch@lst.de \
--cc=jack@suse.com \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).