diff options
author | Mateusz Guzik <mjguzik@gmail.com> | 2024-06-11 14:06:24 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-06-13 13:40:40 +0200 |
commit | 5a9b911b8a24eda19eb0a5ab3b06688299a20711 (patch) | |
tree | 9db0e22c80331e830f326295a4f8dbcdc574f2e0 /fs/xfs/xfs_icache.c | |
parent | ddd4cd4824fa315c799174f2f655a474bf221a6c (diff) |
vfs: partially sanitize i_state zeroing on inode creation
new_inode used to have the following:
spin_lock(&inode_lock);
inodes_stat.nr_inodes++;
list_add(&inode->i_list, &inode_in_use);
list_add(&inode->i_sb_list, &sb->s_inodes);
inode->i_ino = ++last_ino;
inode->i_state = 0;
spin_unlock(&inode_lock);
over time things disappeared, got moved around or got replaced (global
inode lock with a per-inode lock), eventually this got reduced to:
spin_lock(&inode->i_lock);
inode->i_state = 0;
spin_unlock(&inode->i_lock);
But the lock acquire here does not synchronize against anyone.
Additionally iget5_locked performs i_state = 0 assignment without any
locks to begin with, the two combined look confusing at best.
It looks like the current state is a leftover which was not cleaned up.
Ideally it would be an invariant that i_state == 0 to begin with, but
achieving that would require dealing with all filesystem alloc handlers
one by one.
In the meantime drop the misleading locking and move i_state zeroing to
inode_init_always so that others don't need to deal with it by hand.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/r/20240611120626.513952-3-mjguzik@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/xfs/xfs_icache.c')
0 files changed, 0 insertions, 0 deletions