Now that all filesystems store the fsverity data pointer in their private inode, drop the data pointer from struct inode itself freeing up 8 bytes. Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> --- fs/verity/enable.c | 2 +- fs/verity/fsverity_private.h | 2 +- fs/verity/open.c | 19 +++++-------------- include/linux/fs.h | 4 ---- include/linux/fsverity.h | 14 +++++++------- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/fs/verity/enable.c b/fs/verity/enable.c index c284f46d1b53..255cf73f6c03 100644 --- a/fs/verity/enable.c +++ b/fs/verity/enable.c @@ -287,7 +287,7 @@ static int enable_verity(struct file *filp, /* Successfully enabled verity */ /* - * Readers can start using ->i_verity_info immediately, so it + * Readers can start using ->i_fsverity_info immediately, so it * can't be rolled back once set. So don't set it until just * after the filesystem has successfully enabled verity. */ diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h index b3506f56e180..358cbc3aa7ea 100644 --- a/fs/verity/fsverity_private.h +++ b/fs/verity/fsverity_private.h @@ -58,7 +58,7 @@ struct merkle_tree_params { * fsverity_info - cached verity metadata for an inode * * When a verity file is first opened, an instance of this struct is allocated - * and stored in ->i_verity_info; it remains until the inode is evicted. It + * and stored in ->i_fsverity_info; it remains until the inode is evicted. It * caches information about the Merkle tree that's needed to efficiently verify * data read from the file. It also caches the file digest. The Merkle tree * pages themselves are not cached here, but the filesystem may cache them. diff --git a/fs/verity/open.c b/fs/verity/open.c index 9368eeac6fb6..20c6020d59fa 100644 --- a/fs/verity/open.c +++ b/fs/verity/open.c @@ -250,24 +250,17 @@ struct fsverity_info *fsverity_create_info(const struct inode *inode, void fsverity_set_info(struct inode *inode, struct fsverity_info *vi) { - void *p; - /* - * Multiple tasks may race to set ->i_verity_info, so use + * Multiple tasks may race to set ->i_fsverity_info, so use * cmpxchg_release(). This pairs with the smp_load_acquire() in - * fsverity_get_info(). I.e., here we publish ->i_verity_info with a + * fsverity_get_info(). I.e., here we publish ->i_fsverity_info with a * RELEASE barrier so that other tasks can ACQUIRE it. */ - - if (inode->i_sb->s_op->i_fsverity) - p = cmpxchg_release(fsverity_addr(inode), NULL, vi); - else - p = cmpxchg_release(&inode->i_verity_info, NULL, vi); - if (p != NULL) { + if (cmpxchg_release(fsverity_addr(inode), NULL, vi) != NULL) { /* Lost the race, so free the fsverity_info we allocated. */ fsverity_free_info(vi); /* - * Afterwards, the caller may access ->i_verity_info directly, + * Afterwards, the caller may access ->i_fsverity_info directly, * so make sure to ACQUIRE the winning fsverity_info. */ (void)fsverity_get_info(inode); @@ -364,7 +357,7 @@ int fsverity_get_descriptor(struct inode *inode, return 0; } -/* Ensure the inode has an ->i_verity_info */ +/* Ensure the inode has an ->i_fsverity_info */ static int ensure_verity_info(struct inode *inode) { struct fsverity_info *vi = fsverity_get_info(inode); @@ -412,8 +405,6 @@ void __fsverity_cleanup_inode(struct inode *inode) struct fsverity_info **vi; vi = fsverity_addr(inode); - if (!*vi) - vi = &inode->i_verity_info; fsverity_free_info(*vi); *vi = NULL; } diff --git a/include/linux/fs.h b/include/linux/fs.h index f7acf17550f1..a9031a937959 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_VERITY - struct fsverity_info *i_verity_info; -#endif - void *i_private; /* fs or device private pointer */ } __randomize_layout; diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index 341cb1ec73f8..7c876d149a63 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -133,13 +133,13 @@ static inline struct fsverity_info *fsverity_get_info(const struct inode *inode) { /* * Pairs with the cmpxchg_release() in fsverity_set_info(). - * I.e., another task may publish ->i_verity_info concurrently, + * I.e., another task may publish ->i_fsverity_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_fsverity) return smp_load_acquire(fsverity_addr(inode)); - return smp_load_acquire(&inode->i_verity_info); + return NULL; } /* enable.c */ @@ -163,11 +163,11 @@ void __fsverity_cleanup_inode(struct inode *inode); * fsverity_cleanup_inode() - free the inode's verity info, if present * @inode: an inode being evicted * - * Filesystems must call this on inode eviction to free ->i_verity_info. + * Filesystems must call this on inode eviction to free ->i_fsverity_info. */ static inline void fsverity_cleanup_inode(struct inode *inode) { - if (inode->i_verity_info || inode->i_sb->s_op->i_fsverity) + if (inode->i_sb->s_op->i_fsverity) __fsverity_cleanup_inode(inode); } @@ -274,12 +274,12 @@ static inline bool fsverity_verify_page(struct page *page) * fsverity_active() - do reads from the inode need to go through fs-verity? * @inode: inode to check * - * This checks whether ->i_verity_info has been set. + * This checks whether ->i_fsverity_info has been set. * * Filesystems call this from ->readahead() to check whether the pages need to * be verified or not. Don't use IS_VERITY() for this purpose; it's subject to * a race condition where the file is being read concurrently with - * FS_IOC_ENABLE_VERITY completing. (S_VERITY is set before ->i_verity_info.) + * FS_IOC_ENABLE_VERITY completing. (S_VERITY is set before ->i_fsverity_info.) * * Return: true if reads need to go through fs-verity, otherwise false */ @@ -294,7 +294,7 @@ static inline bool fsverity_active(const struct inode *inode) * @filp: the struct file being set up * * When opening a verity file, deny the open if it is for writing. Otherwise, - * set up the inode's ->i_verity_info if not already done. + * set up the inode's ->i_fsverity_info if not already done. * * When combined with fscrypt, this must be called after fscrypt_file_open(). * Otherwise, we won't have the key set up to decrypt the verity metadata. -- 2.47.2