mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 10:01:39 -05:00
Manual conversion to use ->i_state accessors of all places not covered by coccinelle
Nothing to look at apart from iput_final(). Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
b4dbfd8653
commit
f5aa78e2be
@@ -211,7 +211,7 @@ test and set for you.
|
||||
e.g.::
|
||||
|
||||
inode = iget_locked(sb, ino);
|
||||
if (inode->i_state & I_NEW) {
|
||||
if (inode_state_read_once(inode) & I_NEW) {
|
||||
err = read_inode_from_disk(inode);
|
||||
if (err < 0) {
|
||||
iget_failed(inode);
|
||||
|
||||
@@ -427,7 +427,7 @@ static void afs_fetch_status_success(struct afs_operation *op)
|
||||
struct afs_vnode *vnode = vp->vnode;
|
||||
int ret;
|
||||
|
||||
if (vnode->netfs.inode.i_state & I_NEW) {
|
||||
if (inode_state_read_once(&vnode->netfs.inode) & I_NEW) {
|
||||
ret = afs_inode_init_from_status(op, vp, vnode);
|
||||
afs_op_set_error(op, ret);
|
||||
if (ret == 0)
|
||||
|
||||
@@ -425,7 +425,7 @@ void ext4_check_map_extents_env(struct inode *inode)
|
||||
if (!S_ISREG(inode->i_mode) ||
|
||||
IS_NOQUOTA(inode) || IS_VERITY(inode) ||
|
||||
is_special_ino(inode->i_sb, inode->i_ino) ||
|
||||
(inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) ||
|
||||
(inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) ||
|
||||
ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE) ||
|
||||
ext4_verity_in_progress(inode))
|
||||
return;
|
||||
@@ -3473,7 +3473,7 @@ static bool ext4_inode_datasync_dirty(struct inode *inode)
|
||||
/* Any metadata buffers to write? */
|
||||
if (!list_empty(&inode->i_mapping->i_private_list))
|
||||
return true;
|
||||
return inode->i_state & I_DIRTY_DATASYNC;
|
||||
return inode_state_read_once(inode) & I_DIRTY_DATASYNC;
|
||||
}
|
||||
|
||||
static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
|
||||
@@ -4552,7 +4552,7 @@ int ext4_truncate(struct inode *inode)
|
||||
* or it's a completely new inode. In those cases we might not
|
||||
* have i_rwsem locked because it's not necessary.
|
||||
*/
|
||||
if (!(inode->i_state & (I_NEW|I_FREEING)))
|
||||
if (!(inode_state_read_once(inode) & (I_NEW | I_FREEING)))
|
||||
WARN_ON(!inode_is_locked(inode));
|
||||
trace_ext4_truncate_enter(inode);
|
||||
|
||||
@@ -5210,7 +5210,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
|
||||
inode = iget_locked(sb, ino);
|
||||
if (!inode)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
if (!(inode->i_state & I_NEW)) {
|
||||
if (!(inode_state_read_once(inode) & I_NEW)) {
|
||||
ret = check_igot_inode(inode, flags, function, line);
|
||||
if (ret) {
|
||||
iput(inode);
|
||||
@@ -5541,7 +5541,7 @@ static void __ext4_update_other_inode_time(struct super_block *sb,
|
||||
if (inode_is_dirtytime_only(inode)) {
|
||||
struct ext4_inode_info *ei = EXT4_I(inode);
|
||||
|
||||
inode->i_state &= ~I_DIRTY_TIME;
|
||||
inode_state_clear(inode, I_DIRTY_TIME);
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
||||
spin_lock(&ei->i_raw_lock);
|
||||
|
||||
@@ -107,7 +107,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
|
||||
if (!sbi->s_journal || is_bad_inode(inode))
|
||||
return 0;
|
||||
|
||||
WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
|
||||
WARN_ON_ONCE(!(inode_state_read_once(inode) & (I_NEW | I_FREEING)) &&
|
||||
!inode_is_locked(inode));
|
||||
if (ext4_inode_orphan_tracked(inode))
|
||||
return 0;
|
||||
@@ -232,7 +232,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
|
||||
if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
|
||||
return 0;
|
||||
|
||||
WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
|
||||
WARN_ON_ONCE(!(inode_state_read_once(inode) & (I_NEW | I_FREEING)) &&
|
||||
!inode_is_locked(inode));
|
||||
if (ext4_test_inode_state(inode, EXT4_STATE_ORPHAN_FILE))
|
||||
return ext4_orphan_file_del(handle, inode);
|
||||
|
||||
18
fs/inode.c
18
fs/inode.c
@@ -829,7 +829,7 @@ static void evict(struct inode *inode)
|
||||
* This also means we don't need any fences for the call below.
|
||||
*/
|
||||
inode_wake_up_bit(inode, __I_NEW);
|
||||
BUG_ON(inode->i_state != (I_FREEING | I_CLEAR));
|
||||
BUG_ON(inode_state_read_once(inode) != (I_FREEING | I_CLEAR));
|
||||
|
||||
destroy_inode(inode);
|
||||
}
|
||||
@@ -1883,7 +1883,6 @@ static void iput_final(struct inode *inode)
|
||||
{
|
||||
struct super_block *sb = inode->i_sb;
|
||||
const struct super_operations *op = inode->i_sb->s_op;
|
||||
unsigned long state;
|
||||
int drop;
|
||||
|
||||
WARN_ON(inode_state_read(inode) & I_NEW);
|
||||
@@ -1908,20 +1907,19 @@ static void iput_final(struct inode *inode)
|
||||
*/
|
||||
VFS_BUG_ON_INODE(atomic_read(&inode->i_count) != 0, inode);
|
||||
|
||||
state = inode_state_read(inode);
|
||||
if (!drop) {
|
||||
WRITE_ONCE(inode->i_state, state | I_WILL_FREE);
|
||||
if (drop) {
|
||||
inode_state_set(inode, I_FREEING);
|
||||
} else {
|
||||
inode_state_set(inode, I_WILL_FREE);
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
||||
write_inode_now(inode, 1);
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
state = inode_state_read(inode);
|
||||
WARN_ON(state & I_NEW);
|
||||
state &= ~I_WILL_FREE;
|
||||
WARN_ON(inode_state_read(inode) & I_NEW);
|
||||
inode_state_replace(inode, I_WILL_FREE, I_FREEING);
|
||||
}
|
||||
|
||||
WRITE_ONCE(inode->i_state, state | I_FREEING);
|
||||
if (!list_empty(&inode->i_lru))
|
||||
inode_lru_list_del(inode);
|
||||
spin_unlock(&inode->i_lock);
|
||||
@@ -2985,7 +2983,7 @@ void dump_inode(struct inode *inode, const char *reason)
|
||||
pr_warn("%s encountered for inode %px\n"
|
||||
"fs %s mode %ho opflags 0x%hx flags 0x%x state 0x%x count %d\n",
|
||||
reason, inode, sb->s_type->name, inode->i_mode, inode->i_opflags,
|
||||
inode->i_flags, inode->i_state, atomic_read(&inode->i_count));
|
||||
inode->i_flags, inode_state_read_once(inode), atomic_read(&inode->i_count));
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dump_inode);
|
||||
|
||||
@@ -280,7 +280,7 @@ unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)
|
||||
* Paired with a release fence in inode_do_switch_wbs() and
|
||||
* ensures that we see the new wb if we see cleared I_WB_SWITCH.
|
||||
*/
|
||||
cookie->locked = inode->i_state & I_WB_SWITCH;
|
||||
cookie->locked = inode_state_read_once(inode) & I_WB_SWITCH;
|
||||
smp_rmb();
|
||||
|
||||
if (unlikely(cookie->locked))
|
||||
|
||||
@@ -1026,7 +1026,7 @@ static inline void inode_fake_hash(struct inode *inode)
|
||||
static inline void wait_on_inode(struct inode *inode)
|
||||
{
|
||||
wait_var_event(inode_state_wait_address(inode, __I_NEW),
|
||||
!(READ_ONCE(inode->i_state) & I_NEW));
|
||||
!(inode_state_read_once(inode) & I_NEW));
|
||||
/*
|
||||
* Pairs with routines clearing I_NEW.
|
||||
*/
|
||||
@@ -2719,8 +2719,8 @@ static inline int icount_read(const struct inode *inode)
|
||||
*/
|
||||
static inline bool inode_is_dirtytime_only(struct inode *inode)
|
||||
{
|
||||
return (inode->i_state & (I_DIRTY_TIME | I_NEW |
|
||||
I_FREEING | I_WILL_FREE)) == I_DIRTY_TIME;
|
||||
return (inode_state_read_once(inode) &
|
||||
(I_DIRTY_TIME | I_NEW | I_FREEING | I_WILL_FREE)) == I_DIRTY_TIME;
|
||||
}
|
||||
|
||||
extern void inc_nlink(struct inode *inode);
|
||||
|
||||
@@ -227,7 +227,7 @@ static inline void inode_attach_wb(struct inode *inode, struct folio *folio)
|
||||
static inline void inode_detach_wb(struct inode *inode)
|
||||
{
|
||||
if (inode->i_wb) {
|
||||
WARN_ON_ONCE(!(inode->i_state & I_CLEAR));
|
||||
WARN_ON_ONCE(!(inode_state_read_once(inode) & I_CLEAR));
|
||||
wb_put(inode->i_wb);
|
||||
inode->i_wb = NULL;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
|
||||
/* may be called for files on pseudo FSes w/ unregistered bdi */
|
||||
strscpy_pad(__entry->name, bdi_dev_name(bdi), 32);
|
||||
__entry->ino = inode->i_ino;
|
||||
__entry->state = inode->i_state;
|
||||
__entry->state = inode_state_read_once(inode);
|
||||
__entry->flags = flags;
|
||||
),
|
||||
|
||||
@@ -748,7 +748,7 @@ TRACE_EVENT(writeback_sb_inodes_requeue,
|
||||
strscpy_pad(__entry->name,
|
||||
bdi_dev_name(inode_to_bdi(inode)), 32);
|
||||
__entry->ino = inode->i_ino;
|
||||
__entry->state = inode->i_state;
|
||||
__entry->state = inode_state_read_once(inode);
|
||||
__entry->dirtied_when = inode->dirtied_when;
|
||||
__entry->cgroup_ino = __trace_wb_assign_cgroup(inode_to_wb(inode));
|
||||
),
|
||||
@@ -787,7 +787,7 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template,
|
||||
strscpy_pad(__entry->name,
|
||||
bdi_dev_name(inode_to_bdi(inode)), 32);
|
||||
__entry->ino = inode->i_ino;
|
||||
__entry->state = inode->i_state;
|
||||
__entry->state = inode_state_read_once(inode);
|
||||
__entry->dirtied_when = inode->dirtied_when;
|
||||
__entry->writeback_index = inode->i_mapping->writeback_index;
|
||||
__entry->nr_to_write = nr_to_write;
|
||||
@@ -839,7 +839,7 @@ DECLARE_EVENT_CLASS(writeback_inode_template,
|
||||
TP_fast_assign(
|
||||
__entry->dev = inode->i_sb->s_dev;
|
||||
__entry->ino = inode->i_ino;
|
||||
__entry->state = inode->i_state;
|
||||
__entry->state = inode_state_read_once(inode);
|
||||
__entry->mode = inode->i_mode;
|
||||
__entry->dirtied_when = inode->dirtied_when;
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user