]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Coccinelle-based conversion to use ->i_state accessors
authorMateusz Guzik <mjguzik@gmail.com>
Thu, 9 Oct 2025 07:59:18 +0000 (09:59 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 20 Oct 2025 18:22:26 +0000 (20:22 +0200)
All places were patched by coccinelle with the default expecting that
->i_lock is held, afterwards entries got fixed up by hand to use
unlocked variants as needed.

The script:
@@
expression inode, flags;
@@

- inode->i_state & flags
+ inode_state_read(inode) & flags

@@
expression inode, flags;
@@

- inode->i_state &= ~flags
+ inode_state_clear(inode, flags)

@@
expression inode, flag1, flag2;
@@

- inode->i_state &= ~flag1 & ~flag2
+ inode_state_clear(inode, flag1 | flag2)

@@
expression inode, flags;
@@

- inode->i_state |= flags
+ inode_state_set(inode, flags)

@@
expression inode, flags;
@@

- inode->i_state = flags
+ inode_state_assign(inode, flags)

@@
expression inode, flags;
@@

- flags = inode->i_state
+ flags = inode_state_read(inode)

@@
expression inode, flags;
@@

- READ_ONCE(inode->i_state) & flags
+ inode_state_read(inode) & flags

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
66 files changed:
block/bdev.c
drivers/dax/super.c
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c
fs/affs/inode.c
fs/afs/dynroot.c
fs/afs/inode.c
fs/befs/linuxvfs.c
fs/bfs/inode.c
fs/buffer.c
fs/coda/cnode.c
fs/cramfs/inode.c
fs/crypto/keyring.c
fs/crypto/keysetup.c
fs/dcache.c
fs/drop_caches.c
fs/ecryptfs/inode.c
fs/efs/inode.c
fs/erofs/inode.c
fs/ext2/inode.c
fs/freevxfs/vxfs_inode.c
fs/fs-writeback.c
fs/fuse/inode.c
fs/hfs/btree.c
fs/hfs/inode.c
fs/hfsplus/super.c
fs/hostfs/hostfs_kern.c
fs/hpfs/dir.c
fs/hpfs/inode.c
fs/inode.c
fs/isofs/inode.c
fs/jffs2/fs.c
fs/jfs/file.c
fs/jfs/inode.c
fs/jfs/jfs_txnmgr.c
fs/kernfs/inode.c
fs/libfs.c
fs/minix/inode.c
fs/namei.c
fs/netfs/misc.c
fs/netfs/read_single.c
fs/nfs/inode.c
fs/nfs/pnfs.c
fs/nfsd/vfs.c
fs/notify/fsnotify.c
fs/ntfs3/inode.c
fs/ocfs2/dlmglue.c
fs/ocfs2/inode.c
fs/omfs/inode.c
fs/openpromfs/inode.c
fs/orangefs/inode.c
fs/orangefs/orangefs-utils.c
fs/pipe.c
fs/qnx4/inode.c
fs/qnx6/inode.c
fs/quota/dquot.c
fs/romfs/super.c
fs/squashfs/inode.c
fs/sync.c
fs/ubifs/file.c
fs/ubifs/super.c
fs/udf/inode.c
fs/ufs/inode.c
fs/zonefs/super.c
mm/backing-dev.c
security/landlock/fs.c

index 810707cca9703e274affc5a6a1fe0c2bcf169318..c33667e30eb7ca07b923d9a6fced8ded8ea31333 100644 (file)
@@ -67,7 +67,7 @@ static void bdev_write_inode(struct block_device *bdev)
        int ret;
 
        spin_lock(&inode->i_lock);
-       while (inode->i_state & I_DIRTY) {
+       while (inode_state_read(inode) & I_DIRTY) {
                spin_unlock(&inode->i_lock);
                ret = write_inode_now(inode, true);
                if (ret)
@@ -1265,7 +1265,7 @@ void sync_bdevs(bool wait)
                struct block_device *bdev;
 
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW) ||
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW) ||
                    mapping->nrpages == 0) {
                        spin_unlock(&inode->i_lock);
                        continue;
index d7714d8afb0fa06b37bf94511fbc4f0c8d030587..c00b9dff4a06c375c63d30b60ecbd7ffe8fd4c41 100644 (file)
@@ -433,7 +433,7 @@ static struct dax_device *dax_dev_get(dev_t devt)
                return NULL;
 
        dax_dev = to_dax_dev(inode);
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                set_bit(DAXDEV_ALIVE, &dax_dev->flags);
                inode->i_cdev = &dax_dev->cdev;
                inode->i_mode = S_IFCHR;
index 69f378a837753e934c20b599660f8a756127e40a..c3ed137cbf9933f3657d55dfd903a862ab5ba9b1 100644 (file)
@@ -422,7 +422,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
        inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st);
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
        /*
         * initialize the inode with the stat info
index 0b404e8484d22e2cbe60d846e0fa653001cdc4b1..2247cef03c044804a3a81ddbd5fa1c2ed6adddd7 100644 (file)
@@ -112,7 +112,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
        inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode_dotl, st);
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
        /*
         * initialize the inode with the stat info
index 0210df8d3500cd46da9d6f0dfd38ec704a1d9e8a..0bfc7d151dcd383af31d1fa41723e7391ec9d4c0 100644 (file)
@@ -29,7 +29,7 @@ struct inode *affs_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))
                return inode;
 
        pr_debug("affs_iget(%lu)\n", inode->i_ino);
index 8c6130789fde3ae9cf41b5cd2f57dbe578e1ef08..4750125551000e5aafd20c1b2b37401382f21b61 100644 (file)
@@ -64,7 +64,7 @@ static struct inode *afs_iget_pseudo_dir(struct super_block *sb, ino_t ino)
 
        vnode = AFS_FS_I(inode);
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                netfs_inode_init(&vnode->netfs, NULL, false);
                simple_inode_init_ts(inode);
                set_nlink(inode, 2);
@@ -258,7 +258,7 @@ static struct dentry *afs_lookup_atcell(struct inode *dir, struct dentry *dentry
 
        vnode = AFS_FS_I(inode);
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                netfs_inode_init(&vnode->netfs, NULL, false);
                simple_inode_init_ts(inode);
                set_nlink(inode, 1);
@@ -383,7 +383,7 @@ struct inode *afs_dynroot_iget_root(struct super_block *sb)
        vnode = AFS_FS_I(inode);
 
        /* there shouldn't be an existing inode */
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                netfs_inode_init(&vnode->netfs, NULL, false);
                simple_inode_init_ts(inode);
                set_nlink(inode, 2);
index e1cb17b85791396b09dde58124c2e7ae8dcff620..2fe2ccf59c7a538e8a552a2470bfa4048032103d 100644 (file)
@@ -579,7 +579,7 @@ struct inode *afs_iget(struct afs_operation *op, struct afs_vnode_param *vp)
               inode, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
 
        /* deal with an existing inode */
-       if (!(inode->i_state & I_NEW)) {
+       if (!(inode_state_read_once(inode) & I_NEW)) {
                _leave(" = %p", inode);
                return inode;
        }
@@ -639,7 +639,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)
 
        _debug("GOT ROOT INODE %p { vl=%llx }", inode, as->volume->vid);
 
-       BUG_ON(!(inode->i_state & I_NEW));
+       BUG_ON(!(inode_state_read_once(inode) & I_NEW));
 
        vnode = AFS_FS_I(inode);
        vnode->cb_v_check = atomic_read(&as->volume->cb_v_break);
@@ -748,7 +748,7 @@ void afs_evict_inode(struct inode *inode)
 
        if ((S_ISDIR(inode->i_mode) ||
             S_ISLNK(inode->i_mode)) &&
-           (inode->i_state & I_DIRTY) &&
+           (inode_state_read_once(inode) & I_DIRTY) &&
            !sbi->dyn_root) {
                struct writeback_control wbc = {
                        .sync_mode = WB_SYNC_ALL,
index 8f430ff8e4458ffd37a634c5965c4c3e9dc0f1a8..9fcfdd6b8189aaf5cc3b68aa8dff4798af5bdcbc 100644 (file)
@@ -307,7 +307,7 @@ static struct inode *befs_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))
                return inode;
 
        befs_ino = BEFS_I(inode);
index 1d41ce477df58be4919cdd7b016dfc8144278572..cb406a6ee811cb5cc3aef57ebf88805125dbaba7 100644 (file)
@@ -42,7 +42,7 @@ struct inode *bfs_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))
                return inode;
 
        if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) {
index 6a8752f7bbedba06aa21d4cc15c3ec1913af85a5..17b8ce567cc33c44e19df7f43fd2564a43e2c91f 100644 (file)
@@ -611,9 +611,9 @@ int generic_buffers_fsync_noflush(struct file *file, loff_t start, loff_t end,
                return err;
 
        ret = sync_mapping_buffers(inode->i_mapping);
-       if (!(inode->i_state & I_DIRTY_ALL))
+       if (!(inode_state_read_once(inode) & I_DIRTY_ALL))
                goto out;
-       if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
+       if (datasync && !(inode_state_read_once(inode) & I_DIRTY_DATASYNC))
                goto out;
 
        err = sync_inode_metadata(inode, 1);
index 62a3d2565c26165bae988676f105391060ea3b2f..70bb0579b40c49a7e6fd4ce5b0b4e5ce23d219cc 100644 (file)
@@ -70,7 +70,7 @@ retry:
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                cii = ITOC(inode);
                /* we still need to set i_ino for things like stat(2) */
                inode->i_ino = hash;
@@ -148,7 +148,7 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb)
 
        /* we should never see newly created inodes because we intentionally
         * fail in the initialization callback */
-       BUG_ON(inode->i_state & I_NEW);
+       BUG_ON(inode_state_read_once(inode) & I_NEW);
 
        return inode;
 }
index ca54bf24b719f1f62bd98b48d35bfef056dee1da..e54ebe402df79d43a2c7cf491d669829f7ef81b7 100644 (file)
@@ -95,7 +95,7 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
        inode = iget_locked(sb, cramino(cramfs_inode, offset));
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
 
        switch (cramfs_inode->mode & S_IFMT) {
index 3adbd7167055a9ca171c535bc8359f8706cb6da4..5e939ea3ac280dd406e11589012820b31e7717b0 100644 (file)
@@ -945,7 +945,7 @@ static void evict_dentries_for_decrypted_inodes(struct fscrypt_master_key *mk)
        list_for_each_entry(ci, &mk->mk_decrypted_inodes, ci_master_key_link) {
                inode = ci->ci_inode;
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) {
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) {
                        spin_unlock(&inode->i_lock);
                        continue;
                }
index 4bd3918f50e3faad015c16c13a4b2dcf8ef35e6c..40fa05688d3a1d4aa33d29e9508441faf4bca933 100644 (file)
@@ -834,7 +834,7 @@ int fscrypt_drop_inode(struct inode *inode)
         * userspace is still using the files, inodes can be dirtied between
         * then and now.  We mustn't lose any writes, so skip dirty inodes here.
         */
-       if (inode->i_state & I_DIRTY_ALL)
+       if (inode_state_read(inode) & I_DIRTY_ALL)
                return 0;
 
        /*
index 806d6a665124f1e39e76025884c5c1ca0de61ac4..78ffa7b7e824fc7dcc974891011ee45c3ef4587d 100644 (file)
@@ -794,7 +794,7 @@ void d_mark_dontcache(struct inode *inode)
                de->d_flags |= DCACHE_DONTCACHE;
                spin_unlock(&de->d_lock);
        }
-       inode->i_state |= I_DONTCACHE;
+       inode_state_set(inode, I_DONTCACHE);
        spin_unlock(&inode->i_lock);
 }
 EXPORT_SYMBOL(d_mark_dontcache);
@@ -1073,7 +1073,7 @@ struct dentry *d_find_alias_rcu(struct inode *inode)
        spin_lock(&inode->i_lock);
        // ->i_dentry and ->i_rcu are colocated, but the latter won't be
        // used without having I_FREEING set, which means no aliases left
-       if (likely(!(inode->i_state & I_FREEING) && !hlist_empty(l))) {
+       if (likely(!(inode_state_read(inode) & I_FREEING) && !hlist_empty(l))) {
                if (S_ISDIR(inode->i_mode)) {
                        de = hlist_entry(l->first, struct dentry, d_u.d_alias);
                } else {
@@ -1980,12 +1980,12 @@ void d_instantiate_new(struct dentry *entry, struct inode *inode)
        security_d_instantiate(entry, inode);
        spin_lock(&inode->i_lock);
        __d_instantiate(entry, inode);
-       WARN_ON(!(inode->i_state & I_NEW));
+       WARN_ON(!(inode_state_read(inode) & I_NEW));
        /*
         * Pairs with smp_rmb in wait_on_inode().
         */
        smp_wmb();
-       inode->i_state &= ~I_NEW & ~I_CREATING;
+       inode_state_clear(inode, I_NEW | I_CREATING);
        /*
         * Pairs with the barrier in prepare_to_wait_event() to make sure
         * ___wait_var_event() either sees the bit cleared or
index 019a8b4eaaf99645c1fb178e244ef32c93dea28d..49f56a598ecbc82354262606341c0eb8f851bf93 100644 (file)
@@ -28,7 +28,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
                 * inodes without pages but we deliberately won't in case
                 * we need to reschedule to avoid softlockups.
                 */
-               if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
+               if ((inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) ||
                    (mapping_empty(inode->i_mapping) && !need_resched())) {
                        spin_unlock(&inode->i_lock);
                        continue;
index ed1394da8d6bd7065f2a074378331f13fcda17f9..f3c68ef0271f4d330daaa46b5bfb45396641dd71 100644 (file)
@@ -95,7 +95,7 @@ static struct inode *__ecryptfs_get_inode(struct inode *lower_inode,
                iput(lower_inode);
                return ERR_PTR(-EACCES);
        }
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                iput(lower_inode);
 
        return inode;
@@ -106,7 +106,7 @@ struct inode *ecryptfs_get_inode(struct inode *lower_inode,
 {
        struct inode *inode = __ecryptfs_get_inode(lower_inode, sb);
 
-       if (!IS_ERR(inode) && (inode->i_state & I_NEW))
+       if (!IS_ERR(inode) && (inode_state_read_once(inode) & I_NEW))
                unlock_new_inode(inode);
 
        return inode;
@@ -364,7 +364,7 @@ static struct dentry *ecryptfs_lookup_interpose(struct dentry *dentry,
                }
        }
 
-       if (inode->i_state & I_NEW)
+       if (inode_state_read_once(inode) & I_NEW)
                unlock_new_inode(inode);
        return d_splice_alias(inode, dentry);
 }
index 462619e59766f57d0c56ff82d9152f906b2a3ffc..28407578f83ad5db1b8a7b082fa3e990b6b442ec 100644 (file)
@@ -62,7 +62,7 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
        inode = iget_locked(super, ino);
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
 
        in = INODE_INFO(inode);
index cb780c095d282a653211582fd992bb6aa8eb7e20..bce98c845a186f3709553c1338ca8f1398a00c79 100644 (file)
@@ -295,7 +295,7 @@ struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid)
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                int err = erofs_fill_inode(inode);
 
                if (err) {
index e10c376843d7737f1093b0e764f09d99f6ea3348..dbfe9098a1245d97ba97cff24395754197043c33 100644 (file)
@@ -1398,7 +1398,7 @@ struct inode *ext2_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))
                return inode;
 
        ei = EXT2_I(inode);
index 20600e9ea202546c18e0651448fefb549985293d..21fc94b98209fde0931f3001e3292818204eaa39 100644 (file)
@@ -258,7 +258,7 @@ vxfs_iget(struct super_block *sbp, ino_t ino)
        ip = iget_locked(sbp, ino);
        if (!ip)
                return ERR_PTR(-ENOMEM);
-       if (!(ip->i_state & I_NEW))
+       if (!(inode_state_read_once(ip) & I_NEW))
                return ip;
 
        vip = VXFS_INO(ip);
index 9cda19a40ca2ed7567f8b13c2513fa8a5e41fd8a..f784d8b09b04996c697ef988578f10a07b7fbdb6 100644 (file)
@@ -121,7 +121,7 @@ static bool inode_io_list_move_locked(struct inode *inode,
 {
        assert_spin_locked(&wb->list_lock);
        assert_spin_locked(&inode->i_lock);
-       WARN_ON_ONCE(inode->i_state & I_FREEING);
+       WARN_ON_ONCE(inode_state_read(inode) & I_FREEING);
 
        list_move(&inode->i_io_list, head);
 
@@ -304,9 +304,9 @@ static void inode_cgwb_move_to_attached(struct inode *inode,
 {
        assert_spin_locked(&wb->list_lock);
        assert_spin_locked(&inode->i_lock);
-       WARN_ON_ONCE(inode->i_state & I_FREEING);
+       WARN_ON_ONCE(inode_state_read(inode) & I_FREEING);
 
-       inode->i_state &= ~I_SYNC_QUEUED;
+       inode_state_clear(inode, I_SYNC_QUEUED);
        if (wb != &wb->bdi->wb)
                list_move(&inode->i_io_list, &wb->b_attached);
        else
@@ -408,7 +408,7 @@ static bool inode_do_switch_wbs(struct inode *inode,
         * Once I_FREEING or I_WILL_FREE are visible under i_lock, the eviction
         * path owns the inode and we shouldn't modify ->i_io_list.
         */
-       if (unlikely(inode->i_state & (I_FREEING | I_WILL_FREE)))
+       if (unlikely(inode_state_read(inode) & (I_FREEING | I_WILL_FREE)))
                goto skip_switch;
 
        trace_inode_switch_wbs(inode, old_wb, new_wb);
@@ -451,7 +451,7 @@ static bool inode_do_switch_wbs(struct inode *inode,
        if (!list_empty(&inode->i_io_list)) {
                inode->i_wb = new_wb;
 
-               if (inode->i_state & I_DIRTY_ALL) {
+               if (inode_state_read(inode) & I_DIRTY_ALL) {
                        /*
                         * We need to keep b_dirty list sorted by
                         * dirtied_time_when. However properly sorting the
@@ -480,7 +480,7 @@ skip_switch:
         * ensures that the new wb is visible if they see !I_WB_SWITCH.
         */
        smp_wmb();
-       inode->i_state &= ~I_WB_SWITCH;
+       inode_state_clear(inode, I_WB_SWITCH);
 
        xa_unlock_irq(&mapping->i_pages);
        spin_unlock(&inode->i_lock);
@@ -601,12 +601,12 @@ static bool inode_prepare_wbs_switch(struct inode *inode,
        /* while holding I_WB_SWITCH, no one else can update the association */
        spin_lock(&inode->i_lock);
        if (!(inode->i_sb->s_flags & SB_ACTIVE) ||
-           inode->i_state & (I_WB_SWITCH | I_FREEING | I_WILL_FREE) ||
+           inode_state_read(inode) & (I_WB_SWITCH | I_FREEING | I_WILL_FREE) ||
            inode_to_wb(inode) == new_wb) {
                spin_unlock(&inode->i_lock);
                return false;
        }
-       inode->i_state |= I_WB_SWITCH;
+       inode_state_set(inode, I_WB_SWITCH);
        __iget(inode);
        spin_unlock(&inode->i_lock);
 
@@ -636,7 +636,7 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
        struct bdi_writeback *new_wb = NULL;
 
        /* noop if seems to be already in progress */
-       if (inode->i_state & I_WB_SWITCH)
+       if (inode_state_read_once(inode) & I_WB_SWITCH)
                return;
 
        /* avoid queueing a new switch if too many are already in flight */
@@ -1237,9 +1237,9 @@ static void inode_cgwb_move_to_attached(struct inode *inode,
 {
        assert_spin_locked(&wb->list_lock);
        assert_spin_locked(&inode->i_lock);
-       WARN_ON_ONCE(inode->i_state & I_FREEING);
+       WARN_ON_ONCE(inode_state_read(inode) & I_FREEING);
 
-       inode->i_state &= ~I_SYNC_QUEUED;
+       inode_state_clear(inode, I_SYNC_QUEUED);
        list_del_init(&inode->i_io_list);
        wb_io_lists_depopulated(wb);
 }
@@ -1352,7 +1352,7 @@ void inode_io_list_del(struct inode *inode)
        wb = inode_to_wb_and_lock_list(inode);
        spin_lock(&inode->i_lock);
 
-       inode->i_state &= ~I_SYNC_QUEUED;
+       inode_state_clear(inode, I_SYNC_QUEUED);
        list_del_init(&inode->i_io_list);
        wb_io_lists_depopulated(wb);
 
@@ -1410,13 +1410,13 @@ static void redirty_tail_locked(struct inode *inode, struct bdi_writeback *wb)
 {
        assert_spin_locked(&inode->i_lock);
 
-       inode->i_state &= ~I_SYNC_QUEUED;
+       inode_state_clear(inode, I_SYNC_QUEUED);
        /*
         * When the inode is being freed just don't bother with dirty list
         * tracking. Flush worker will ignore this inode anyway and it will
         * trigger assertions in inode_io_list_move_locked().
         */
-       if (inode->i_state & I_FREEING) {
+       if (inode_state_read(inode) & I_FREEING) {
                list_del_init(&inode->i_io_list);
                wb_io_lists_depopulated(wb);
                return;
@@ -1450,7 +1450,7 @@ static void inode_sync_complete(struct inode *inode)
 {
        assert_spin_locked(&inode->i_lock);
 
-       inode->i_state &= ~I_SYNC;
+       inode_state_clear(inode, I_SYNC);
        /* If inode is clean an unused, put it into LRU now... */
        inode_add_lru(inode);
        /* Called with inode->i_lock which ensures memory ordering. */
@@ -1494,7 +1494,7 @@ static int move_expired_inodes(struct list_head *delaying_queue,
                spin_lock(&inode->i_lock);
                list_move(&inode->i_io_list, &tmp);
                moved++;
-               inode->i_state |= I_SYNC_QUEUED;
+               inode_state_set(inode, I_SYNC_QUEUED);
                spin_unlock(&inode->i_lock);
                if (sb_is_blkdev_sb(inode->i_sb))
                        continue;
@@ -1580,14 +1580,14 @@ void inode_wait_for_writeback(struct inode *inode)
 
        assert_spin_locked(&inode->i_lock);
 
-       if (!(inode->i_state & I_SYNC))
+       if (!(inode_state_read(inode) & I_SYNC))
                return;
 
        wq_head = inode_bit_waitqueue(&wqe, inode, __I_SYNC);
        for (;;) {
                prepare_to_wait_event(wq_head, &wqe.wq_entry, TASK_UNINTERRUPTIBLE);
                /* Checking I_SYNC with inode->i_lock guarantees memory ordering. */
-               if (!(inode->i_state & I_SYNC))
+               if (!(inode_state_read(inode) & I_SYNC))
                        break;
                spin_unlock(&inode->i_lock);
                schedule();
@@ -1613,7 +1613,7 @@ static void inode_sleep_on_writeback(struct inode *inode)
        wq_head = inode_bit_waitqueue(&wqe, inode, __I_SYNC);
        prepare_to_wait_event(wq_head, &wqe.wq_entry, TASK_UNINTERRUPTIBLE);
        /* Checking I_SYNC with inode->i_lock guarantees memory ordering. */
-       sleep = !!(inode->i_state & I_SYNC);
+       sleep = !!(inode_state_read(inode) & I_SYNC);
        spin_unlock(&inode->i_lock);
        if (sleep)
                schedule();
@@ -1632,7 +1632,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
                          struct writeback_control *wbc,
                          unsigned long dirtied_before)
 {
-       if (inode->i_state & I_FREEING)
+       if (inode_state_read(inode) & I_FREEING)
                return;
 
        /*
@@ -1640,7 +1640,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
         * shot. If still dirty, it will be redirty_tail()'ed below.  Update
         * the dirty time to prevent enqueue and sync it again.
         */
-       if ((inode->i_state & I_DIRTY) &&
+       if ((inode_state_read(inode) & I_DIRTY) &&
            (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages))
                inode->dirtied_when = jiffies;
 
@@ -1651,7 +1651,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
                 * is odd for clean inodes, it can happen for some
                 * filesystems so handle that gracefully.
                 */
-               if (inode->i_state & I_DIRTY_ALL)
+               if (inode_state_read(inode) & I_DIRTY_ALL)
                        redirty_tail_locked(inode, wb);
                else
                        inode_cgwb_move_to_attached(inode, wb);
@@ -1677,17 +1677,17 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
                         */
                        redirty_tail_locked(inode, wb);
                }
-       } else if (inode->i_state & I_DIRTY) {
+       } else if (inode_state_read(inode) & I_DIRTY) {
                /*
                 * Filesystems can dirty the inode during writeback operations,
                 * such as delayed allocation during submission or metadata
                 * updates after data IO completion.
                 */
                redirty_tail_locked(inode, wb);
-       } else if (inode->i_state & I_DIRTY_TIME) {
+       } else if (inode_state_read(inode) & I_DIRTY_TIME) {
                inode->dirtied_when = jiffies;
                inode_io_list_move_locked(inode, wb, &wb->b_dirty_time);
-               inode->i_state &= ~I_SYNC_QUEUED;
+               inode_state_clear(inode, I_SYNC_QUEUED);
        } else {
                /* The inode is clean. Remove from writeback lists. */
                inode_cgwb_move_to_attached(inode, wb);
@@ -1713,7 +1713,7 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
        unsigned dirty;
        int ret;
 
-       WARN_ON(!(inode->i_state & I_SYNC));
+       WARN_ON(!(inode_state_read_once(inode) & I_SYNC));
 
        trace_writeback_single_inode_start(inode, wbc, nr_to_write);
 
@@ -1737,7 +1737,7 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
         * mark_inode_dirty_sync() to notify the filesystem about it and to
         * change I_DIRTY_TIME into I_DIRTY_SYNC.
         */
-       if ((inode->i_state & I_DIRTY_TIME) &&
+       if ((inode_state_read_once(inode) & I_DIRTY_TIME) &&
            (wbc->sync_mode == WB_SYNC_ALL ||
             time_after(jiffies, inode->dirtied_time_when +
                        dirtytime_expire_interval * HZ))) {
@@ -1752,8 +1752,8 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
         * after handling timestamp expiration, as that may dirty the inode too.
         */
        spin_lock(&inode->i_lock);
-       dirty = inode->i_state & I_DIRTY;
-       inode->i_state &= ~dirty;
+       dirty = inode_state_read(inode) & I_DIRTY;
+       inode_state_clear(inode, dirty);
 
        /*
         * Paired with smp_mb() in __mark_inode_dirty().  This allows
@@ -1769,10 +1769,10 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
        smp_mb();
 
        if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
-               inode->i_state |= I_DIRTY_PAGES;
-       else if (unlikely(inode->i_state & I_PINNING_NETFS_WB)) {
-               if (!(inode->i_state & I_DIRTY_PAGES)) {
-                       inode->i_state &= ~I_PINNING_NETFS_WB;
+               inode_state_set(inode, I_DIRTY_PAGES);
+       else if (unlikely(inode_state_read(inode) & I_PINNING_NETFS_WB)) {
+               if (!(inode_state_read(inode) & I_DIRTY_PAGES)) {
+                       inode_state_clear(inode, I_PINNING_NETFS_WB);
                        wbc->unpinned_netfs_wb = true;
                        dirty |= I_PINNING_NETFS_WB; /* Cause write_inode */
                }
@@ -1808,11 +1808,11 @@ static int writeback_single_inode(struct inode *inode,
 
        spin_lock(&inode->i_lock);
        if (!icount_read(inode))
-               WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING)));
+               WARN_ON(!(inode_state_read(inode) & (I_WILL_FREE | I_FREEING)));
        else
-               WARN_ON(inode->i_state & I_WILL_FREE);
+               WARN_ON(inode_state_read(inode) & I_WILL_FREE);
 
-       if (inode->i_state & I_SYNC) {
+       if (inode_state_read(inode) & I_SYNC) {
                /*
                 * Writeback is already running on the inode.  For WB_SYNC_NONE,
                 * that's enough and we can just return.  For WB_SYNC_ALL, we
@@ -1823,7 +1823,7 @@ static int writeback_single_inode(struct inode *inode,
                        goto out;
                inode_wait_for_writeback(inode);
        }
-       WARN_ON(inode->i_state & I_SYNC);
+       WARN_ON(inode_state_read(inode) & I_SYNC);
        /*
         * If the inode is already fully clean, then there's nothing to do.
         *
@@ -1831,11 +1831,11 @@ static int writeback_single_inode(struct inode *inode,
         * still under writeback, e.g. due to prior WB_SYNC_NONE writeback.  If
         * there are any such pages, we'll need to wait for them.
         */
-       if (!(inode->i_state & I_DIRTY_ALL) &&
+       if (!(inode_state_read(inode) & I_DIRTY_ALL) &&
            (wbc->sync_mode != WB_SYNC_ALL ||
             !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)))
                goto out;
-       inode->i_state |= I_SYNC;
+       inode_state_set(inode, I_SYNC);
        wbc_attach_and_unlock_inode(wbc, inode);
 
        ret = __writeback_single_inode(inode, wbc);
@@ -1848,18 +1848,18 @@ static int writeback_single_inode(struct inode *inode,
         * If the inode is freeing, its i_io_list shoudn't be updated
         * as it can be finally deleted at this moment.
         */
-       if (!(inode->i_state & I_FREEING)) {
+       if (!(inode_state_read(inode) & I_FREEING)) {
                /*
                 * If the inode is now fully clean, then it can be safely
                 * removed from its writeback list (if any). Otherwise the
                 * flusher threads are responsible for the writeback lists.
                 */
-               if (!(inode->i_state & I_DIRTY_ALL))
+               if (!(inode_state_read(inode) & I_DIRTY_ALL))
                        inode_cgwb_move_to_attached(inode, wb);
-               else if (!(inode->i_state & I_SYNC_QUEUED)) {
-                       if ((inode->i_state & I_DIRTY))
+               else if (!(inode_state_read(inode) & I_SYNC_QUEUED)) {
+                       if ((inode_state_read(inode) & I_DIRTY))
                                redirty_tail_locked(inode, wb);
-                       else if (inode->i_state & I_DIRTY_TIME) {
+                       else if (inode_state_read(inode) & I_DIRTY_TIME) {
                                inode->dirtied_when = jiffies;
                                inode_io_list_move_locked(inode,
                                                          wb,
@@ -1968,12 +1968,12 @@ static long writeback_sb_inodes(struct super_block *sb,
                 * kind writeout is handled by the freer.
                 */
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
+               if (inode_state_read(inode) & (I_NEW | I_FREEING | I_WILL_FREE)) {
                        redirty_tail_locked(inode, wb);
                        spin_unlock(&inode->i_lock);
                        continue;
                }
-               if ((inode->i_state & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) {
+               if ((inode_state_read(inode) & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) {
                        /*
                         * If this inode is locked for writeback and we are not
                         * doing writeback-for-data-integrity, move it to
@@ -1995,14 +1995,14 @@ static long writeback_sb_inodes(struct super_block *sb,
                 * are doing WB_SYNC_NONE writeback. So this catches only the
                 * WB_SYNC_ALL case.
                 */
-               if (inode->i_state & I_SYNC) {
+               if (inode_state_read(inode) & I_SYNC) {
                        /* Wait for I_SYNC. This function drops i_lock... */
                        inode_sleep_on_writeback(inode);
                        /* Inode may be gone, start again */
                        spin_lock(&wb->list_lock);
                        continue;
                }
-               inode->i_state |= I_SYNC;
+               inode_state_set(inode, I_SYNC);
                wbc_attach_and_unlock_inode(&wbc, inode);
 
                write_chunk = writeback_chunk_size(wb, work);
@@ -2040,7 +2040,7 @@ static long writeback_sb_inodes(struct super_block *sb,
                 */
                tmp_wb = inode_to_wb_and_lock_list(inode);
                spin_lock(&inode->i_lock);
-               if (!(inode->i_state & I_DIRTY_ALL))
+               if (!(inode_state_read(inode) & I_DIRTY_ALL))
                        total_wrote++;
                requeue_inode(inode, tmp_wb, &wbc, dirtied_before);
                inode_sync_complete(inode);
@@ -2546,10 +2546,10 @@ void __mark_inode_dirty(struct inode *inode, int flags)
                 * We tell ->dirty_inode callback that timestamps need to
                 * be updated by setting I_DIRTY_TIME in flags.
                 */
-               if (inode->i_state & I_DIRTY_TIME) {
+               if (inode_state_read_once(inode) & I_DIRTY_TIME) {
                        spin_lock(&inode->i_lock);
-                       if (inode->i_state & I_DIRTY_TIME) {
-                               inode->i_state &= ~I_DIRTY_TIME;
+                       if (inode_state_read(inode) & I_DIRTY_TIME) {
+                               inode_state_clear(inode, I_DIRTY_TIME);
                                flags |= I_DIRTY_TIME;
                        }
                        spin_unlock(&inode->i_lock);
@@ -2586,16 +2586,16 @@ void __mark_inode_dirty(struct inode *inode, int flags)
         */
        smp_mb();
 
-       if ((inode->i_state & flags) == flags)
+       if ((inode_state_read_once(inode) & flags) == flags)
                return;
 
        spin_lock(&inode->i_lock);
-       if ((inode->i_state & flags) != flags) {
-               const int was_dirty = inode->i_state & I_DIRTY;
+       if ((inode_state_read(inode) & flags) != flags) {
+               const int was_dirty = inode_state_read(inode) & I_DIRTY;
 
                inode_attach_wb(inode, NULL);
 
-               inode->i_state |= flags;
+               inode_state_set(inode, flags);
 
                /*
                 * Grab inode's wb early because it requires dropping i_lock and we
@@ -2614,7 +2614,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
                 * the inode it will place it on the appropriate superblock
                 * list, based upon its state.
                 */
-               if (inode->i_state & I_SYNC_QUEUED)
+               if (inode_state_read(inode) & I_SYNC_QUEUED)
                        goto out_unlock;
 
                /*
@@ -2625,7 +2625,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
                        if (inode_unhashed(inode))
                                goto out_unlock;
                }
-               if (inode->i_state & I_FREEING)
+               if (inode_state_read(inode) & I_FREEING)
                        goto out_unlock;
 
                /*
@@ -2640,7 +2640,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
                        if (dirtytime)
                                inode->dirtied_time_when = jiffies;
 
-                       if (inode->i_state & I_DIRTY)
+                       if (inode_state_read(inode) & I_DIRTY)
                                dirty_list = &wb->b_dirty;
                        else
                                dirty_list = &wb->b_dirty_time;
@@ -2737,7 +2737,7 @@ static void wait_sb_inodes(struct super_block *sb)
                spin_unlock_irq(&sb->s_inode_wblist_lock);
 
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) {
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) {
                        spin_unlock(&inode->i_lock);
 
                        spin_lock_irq(&sb->s_inode_wblist_lock);
index d1babf56f25470fcc08fe400467b3450e8b7464a..bbecd0e5855d99e7db5c329b8fd6c10a0df66112 100644 (file)
@@ -160,7 +160,7 @@ static void fuse_evict_inode(struct inode *inode)
        struct fuse_inode *fi = get_fuse_inode(inode);
 
        /* Will write inode on close/munmap and in all other dirtiers */
-       WARN_ON(inode->i_state & I_DIRTY_INODE);
+       WARN_ON(inode_state_read_once(inode) & I_DIRTY_INODE);
 
        if (FUSE_IS_DAX(inode))
                dax_break_layout_final(inode);
@@ -505,7 +505,7 @@ retry:
        if (!inode)
                return NULL;
 
-       if ((inode->i_state & I_NEW)) {
+       if ((inode_state_read_once(inode) & I_NEW)) {
                inode->i_flags |= S_NOATIME;
                if (!fc->writeback_cache || !S_ISREG(attr->mode))
                        inode->i_flags |= S_NOCMTIME;
index 22e62fe7448bf8fcec22dcbb1ffaf3e5d4d75f65..54c20d01c34272b259961a4ee767f74f9a90c7fd 100644 (file)
@@ -42,7 +42,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        tree->inode = iget_locked(sb, id);
        if (!tree->inode)
                goto free_tree;
-       BUG_ON(!(tree->inode->i_state & I_NEW));
+       BUG_ON(!(inode_state_read_once(tree->inode) & I_NEW));
        {
        struct hfs_mdb *mdb = HFS_SB(sb)->mdb;
        HFS_I(tree->inode)->flags = 0;
index 9cd449913dc82a244d7191b6cf35c21b689c6d49..81ad93e6312f616c4a4d783f9ed503f0f1580df7 100644 (file)
@@ -412,7 +412,7 @@ struct inode *hfs_iget(struct super_block *sb, struct hfs_cat_key *key, hfs_cat_
                return NULL;
        }
        inode = iget5_locked(sb, cnid, hfs_test_inode, hfs_read_inode, &data);
-       if (inode && (inode->i_state & I_NEW))
+       if (inode && (inode_state_read_once(inode) & I_NEW))
                unlock_new_inode(inode);
        return inode;
 }
index 16bc4abc67e08febcb71a774d9c0aa192699f2de..54e85e25a2590baf8ef4cfe32b04544c16b2fe1d 100644 (file)
@@ -65,7 +65,7 @@ struct inode *hfsplus_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))
                return inode;
 
        atomic_set(&HFSPLUS_I(inode)->opencnt, 0);
index 1e1acf5775ab5f6daf13bb917966d05f410d5ff5..76b643f7d05c2f2389fb5bfad9f2c70a7302e658 100644 (file)
@@ -581,7 +581,7 @@ static struct inode *hostfs_iget(struct super_block *sb, char *name)
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                unlock_new_inode(inode);
        } else {
                spin_lock(&inode->i_lock);
index 49dd585c2b176dc6b6b837d2b3515c8143bb7873..ceb50b2dc91a9da02997a40836d6543786d883d3 100644 (file)
@@ -247,7 +247,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
                result = ERR_PTR(-ENOMEM);
                goto bail1;
        }
-       if (result->i_state & I_NEW) {
+       if (inode_state_read_once(result) & I_NEW) {
                hpfs_init_inode(result);
                if (de->directory)
                        hpfs_read_inode(result);
index 34008442ee265f156f707a638cc4b9a84e74e524..93d528f4f4f28d5070162faacd65d3fc2341248a 100644 (file)
@@ -196,7 +196,7 @@ void hpfs_write_inode(struct inode *i)
        parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
        if (parent) {
                hpfs_inode->i_dirty = 0;
-               if (parent->i_state & I_NEW) {
+               if (inode_state_read_once(parent) & I_NEW) {
                        hpfs_init_inode(parent);
                        hpfs_read_inode(parent);
                        unlock_new_inode(parent);
index 37fc7a72aba55b64a722f0af43f6e5a84b19daf0..f094ed3e6f301d73a56c00a448ed19e0a5d5c920 100644 (file)
@@ -233,7 +233,7 @@ int inode_init_always_gfp(struct super_block *sb, struct inode *inode, gfp_t gfp
        inode->i_sb = sb;
        inode->i_blkbits = sb->s_blocksize_bits;
        inode->i_flags = 0;
-       inode->i_state = 0;
+       inode_state_assign_raw(inode, 0);
        atomic64_set(&inode->i_sequence, 0);
        atomic_set(&inode->i_count, 1);
        inode->i_op = &empty_iops;
@@ -471,7 +471,7 @@ EXPORT_SYMBOL(set_nlink);
 void inc_nlink(struct inode *inode)
 {
        if (unlikely(inode->i_nlink == 0)) {
-               WARN_ON(!(inode->i_state & I_LINKABLE));
+               WARN_ON(!(inode_state_read_once(inode) & I_LINKABLE));
                atomic_long_dec(&inode->i_sb->s_remove_count);
        }
 
@@ -532,7 +532,7 @@ EXPORT_SYMBOL(ihold);
 
 static void __inode_add_lru(struct inode *inode, bool rotate)
 {
-       if (inode->i_state & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE))
+       if (inode_state_read(inode) & (I_DIRTY_ALL | I_SYNC | I_FREEING | I_WILL_FREE))
                return;
        if (icount_read(inode))
                return;
@@ -544,7 +544,7 @@ static void __inode_add_lru(struct inode *inode, bool rotate)
        if (list_lru_add_obj(&inode->i_sb->s_inode_lru, &inode->i_lru))
                this_cpu_inc(nr_unused);
        else if (rotate)
-               inode->i_state |= I_REFERENCED;
+               inode_state_set(inode, I_REFERENCED);
 }
 
 struct wait_queue_head *inode_bit_waitqueue(struct wait_bit_queue_entry *wqe,
@@ -577,15 +577,15 @@ static void inode_lru_list_del(struct inode *inode)
 static void inode_pin_lru_isolating(struct inode *inode)
 {
        lockdep_assert_held(&inode->i_lock);
-       WARN_ON(inode->i_state & (I_LRU_ISOLATING | I_FREEING | I_WILL_FREE));
-       inode->i_state |= I_LRU_ISOLATING;
+       WARN_ON(inode_state_read(inode) & (I_LRU_ISOLATING | I_FREEING | I_WILL_FREE));
+       inode_state_set(inode, I_LRU_ISOLATING);
 }
 
 static void inode_unpin_lru_isolating(struct inode *inode)
 {
        spin_lock(&inode->i_lock);
-       WARN_ON(!(inode->i_state & I_LRU_ISOLATING));
-       inode->i_state &= ~I_LRU_ISOLATING;
+       WARN_ON(!(inode_state_read(inode) & I_LRU_ISOLATING));
+       inode_state_clear(inode, I_LRU_ISOLATING);
        /* Called with inode->i_lock which ensures memory ordering. */
        inode_wake_up_bit(inode, __I_LRU_ISOLATING);
        spin_unlock(&inode->i_lock);
@@ -597,7 +597,7 @@ static void inode_wait_for_lru_isolating(struct inode *inode)
        struct wait_queue_head *wq_head;
 
        lockdep_assert_held(&inode->i_lock);
-       if (!(inode->i_state & I_LRU_ISOLATING))
+       if (!(inode_state_read(inode) & I_LRU_ISOLATING))
                return;
 
        wq_head = inode_bit_waitqueue(&wqe, inode, __I_LRU_ISOLATING);
@@ -607,14 +607,14 @@ static void inode_wait_for_lru_isolating(struct inode *inode)
                 * Checking I_LRU_ISOLATING with inode->i_lock guarantees
                 * memory ordering.
                 */
-               if (!(inode->i_state & I_LRU_ISOLATING))
+               if (!(inode_state_read(inode) & I_LRU_ISOLATING))
                        break;
                spin_unlock(&inode->i_lock);
                schedule();
                spin_lock(&inode->i_lock);
        }
        finish_wait(wq_head, &wqe.wq_entry);
-       WARN_ON(inode->i_state & I_LRU_ISOLATING);
+       WARN_ON(inode_state_read(inode) & I_LRU_ISOLATING);
 }
 
 /**
@@ -761,11 +761,11 @@ void clear_inode(struct inode *inode)
         */
        xa_unlock_irq(&inode->i_data.i_pages);
        BUG_ON(!list_empty(&inode->i_data.i_private_list));
-       BUG_ON(!(inode->i_state & I_FREEING));
-       BUG_ON(inode->i_state & I_CLEAR);
+       BUG_ON(!(inode_state_read_once(inode) & I_FREEING));
+       BUG_ON(inode_state_read_once(inode) & I_CLEAR);
        BUG_ON(!list_empty(&inode->i_wb_list));
        /* don't need i_lock here, no concurrent mods to i_state */
-       inode->i_state = I_FREEING | I_CLEAR;
+       inode_state_assign_raw(inode, I_FREEING | I_CLEAR);
 }
 EXPORT_SYMBOL(clear_inode);
 
@@ -786,7 +786,7 @@ static void evict(struct inode *inode)
 {
        const struct super_operations *op = inode->i_sb->s_op;
 
-       BUG_ON(!(inode->i_state & I_FREEING));
+       BUG_ON(!(inode_state_read_once(inode) & I_FREEING));
        BUG_ON(!list_empty(&inode->i_lru));
 
        if (!list_empty(&inode->i_io_list))
@@ -879,12 +879,12 @@ again:
                        spin_unlock(&inode->i_lock);
                        continue;
                }
-               if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
+               if (inode_state_read(inode) & (I_NEW | I_FREEING | I_WILL_FREE)) {
                        spin_unlock(&inode->i_lock);
                        continue;
                }
 
-               inode->i_state |= I_FREEING;
+               inode_state_set(inode, I_FREEING);
                inode_lru_list_del(inode);
                spin_unlock(&inode->i_lock);
                list_add(&inode->i_lru, &dispose);
@@ -938,7 +938,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
         * sync, or the last page cache deletion will requeue them.
         */
        if (icount_read(inode) ||
-           (inode->i_state & ~I_REFERENCED) ||
+           (inode_state_read(inode) & ~I_REFERENCED) ||
            !mapping_shrinkable(&inode->i_data)) {
                list_lru_isolate(lru, &inode->i_lru);
                spin_unlock(&inode->i_lock);
@@ -947,8 +947,8 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
        }
 
        /* Recently referenced inodes get one more pass */
-       if (inode->i_state & I_REFERENCED) {
-               inode->i_state &= ~I_REFERENCED;
+       if (inode_state_read(inode) & I_REFERENCED) {
+               inode_state_clear(inode, I_REFERENCED);
                spin_unlock(&inode->i_lock);
                return LRU_ROTATE;
        }
@@ -975,8 +975,8 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
                return LRU_RETRY;
        }
 
-       WARN_ON(inode->i_state & I_NEW);
-       inode->i_state |= I_FREEING;
+       WARN_ON(inode_state_read(inode) & I_NEW);
+       inode_state_set(inode, I_FREEING);
        list_lru_isolate_move(lru, &inode->i_lru, freeable);
        spin_unlock(&inode->i_lock);
 
@@ -1025,11 +1025,11 @@ repeat:
                if (!test(inode, data))
                        continue;
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE)) {
                        __wait_on_freeing_inode(inode, is_inode_hash_locked);
                        goto repeat;
                }
-               if (unlikely(inode->i_state & I_CREATING)) {
+               if (unlikely(inode_state_read(inode) & I_CREATING)) {
                        spin_unlock(&inode->i_lock);
                        rcu_read_unlock();
                        return ERR_PTR(-ESTALE);
@@ -1066,11 +1066,11 @@ repeat:
                if (inode->i_sb != sb)
                        continue;
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE)) {
                        __wait_on_freeing_inode(inode, is_inode_hash_locked);
                        goto repeat;
                }
-               if (unlikely(inode->i_state & I_CREATING)) {
+               if (unlikely(inode_state_read(inode) & I_CREATING)) {
                        spin_unlock(&inode->i_lock);
                        rcu_read_unlock();
                        return ERR_PTR(-ESTALE);
@@ -1180,12 +1180,12 @@ void unlock_new_inode(struct inode *inode)
 {
        lockdep_annotate_inode_mutex_key(inode);
        spin_lock(&inode->i_lock);
-       WARN_ON(!(inode->i_state & I_NEW));
+       WARN_ON(!(inode_state_read(inode) & I_NEW));
        /*
         * Pairs with smp_rmb in wait_on_inode().
         */
        smp_wmb();
-       inode->i_state &= ~I_NEW & ~I_CREATING;
+       inode_state_clear(inode, I_NEW | I_CREATING);
        /*
         * Pairs with the barrier in prepare_to_wait_event() to make sure
         * ___wait_var_event() either sees the bit cleared or
@@ -1201,12 +1201,12 @@ void discard_new_inode(struct inode *inode)
 {
        lockdep_annotate_inode_mutex_key(inode);
        spin_lock(&inode->i_lock);
-       WARN_ON(!(inode->i_state & I_NEW));
+       WARN_ON(!(inode_state_read(inode) & I_NEW));
        /*
         * Pairs with smp_rmb in wait_on_inode().
         */
        smp_wmb();
-       inode->i_state &= ~I_NEW;
+       inode_state_clear(inode, I_NEW);
        /*
         * Pairs with the barrier in prepare_to_wait_event() to make sure
         * ___wait_var_event() either sees the bit cleared or
@@ -1318,7 +1318,7 @@ again:
         * caller is responsible for filling in the contents
         */
        spin_lock(&inode->i_lock);
-       inode->i_state |= I_NEW;
+       inode_state_set(inode, I_NEW);
        hlist_add_head_rcu(&inode->i_hash, head);
        spin_unlock(&inode->i_lock);
 
@@ -1460,7 +1460,7 @@ again:
                if (!old) {
                        inode->i_ino = ino;
                        spin_lock(&inode->i_lock);
-                       inode->i_state = I_NEW;
+                       inode_state_assign(inode, I_NEW);
                        hlist_add_head_rcu(&inode->i_hash, head);
                        spin_unlock(&inode->i_lock);
                        spin_unlock(&inode_hash_lock);
@@ -1553,7 +1553,7 @@ EXPORT_SYMBOL(iunique);
 struct inode *igrab(struct inode *inode)
 {
        spin_lock(&inode->i_lock);
-       if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) {
+       if (!(inode_state_read(inode) & (I_FREEING | I_WILL_FREE))) {
                __iget(inode);
                spin_unlock(&inode->i_lock);
        } else {
@@ -1749,7 +1749,7 @@ struct inode *find_inode_rcu(struct super_block *sb, unsigned long hashval,
 
        hlist_for_each_entry_rcu(inode, head, i_hash) {
                if (inode->i_sb == sb &&
-                   !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)) &&
+                   !(inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE)) &&
                    test(inode, data))
                        return inode;
        }
@@ -1788,7 +1788,7 @@ struct inode *find_inode_by_ino_rcu(struct super_block *sb,
        hlist_for_each_entry_rcu(inode, head, i_hash) {
                if (inode->i_ino == ino &&
                    inode->i_sb == sb &&
-                   !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)))
+                   !(inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE)))
                    return inode;
        }
        return NULL;
@@ -1812,7 +1812,7 @@ int insert_inode_locked(struct inode *inode)
                        if (old->i_sb != sb)
                                continue;
                        spin_lock(&old->i_lock);
-                       if (old->i_state & (I_FREEING|I_WILL_FREE)) {
+                       if (inode_state_read(old) & (I_FREEING | I_WILL_FREE)) {
                                spin_unlock(&old->i_lock);
                                continue;
                        }
@@ -1820,13 +1820,13 @@ int insert_inode_locked(struct inode *inode)
                }
                if (likely(!old)) {
                        spin_lock(&inode->i_lock);
-                       inode->i_state |= I_NEW | I_CREATING;
+                       inode_state_set(inode, I_NEW | I_CREATING);
                        hlist_add_head_rcu(&inode->i_hash, head);
                        spin_unlock(&inode->i_lock);
                        spin_unlock(&inode_hash_lock);
                        return 0;
                }
-               if (unlikely(old->i_state & I_CREATING)) {
+               if (unlikely(inode_state_read(old) & I_CREATING)) {
                        spin_unlock(&old->i_lock);
                        spin_unlock(&inode_hash_lock);
                        return -EBUSY;
@@ -1851,7 +1851,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
 
        might_sleep();
 
-       inode->i_state |= I_CREATING;
+       inode_state_set_raw(inode, I_CREATING);
        old = inode_insert5(inode, hashval, test, NULL, data);
 
        if (old != inode) {
@@ -1886,7 +1886,7 @@ static void iput_final(struct inode *inode)
        unsigned long state;
        int drop;
 
-       WARN_ON(inode->i_state & I_NEW);
+       WARN_ON(inode_state_read(inode) & I_NEW);
        VFS_BUG_ON_INODE(atomic_read(&inode->i_count) != 0, inode);
 
        if (op->drop_inode)
@@ -1895,7 +1895,7 @@ static void iput_final(struct inode *inode)
                drop = inode_generic_drop(inode);
 
        if (!drop &&
-           !(inode->i_state & I_DONTCACHE) &&
+           !(inode_state_read(inode) & I_DONTCACHE) &&
            (sb->s_flags & SB_ACTIVE)) {
                __inode_add_lru(inode, true);
                spin_unlock(&inode->i_lock);
@@ -1908,7 +1908,7 @@ static void iput_final(struct inode *inode)
         */
        VFS_BUG_ON_INODE(atomic_read(&inode->i_count) != 0, inode);
 
-       state = inode->i_state;
+       state = inode_state_read(inode);
        if (!drop) {
                WRITE_ONCE(inode->i_state, state | I_WILL_FREE);
                spin_unlock(&inode->i_lock);
@@ -1916,7 +1916,7 @@ static void iput_final(struct inode *inode)
                write_inode_now(inode, 1);
 
                spin_lock(&inode->i_lock);
-               state = inode->i_state;
+               state = inode_state_read(inode);
                WARN_ON(state & I_NEW);
                state &= ~I_WILL_FREE;
        }
@@ -1946,7 +1946,7 @@ void iput(struct inode *inode)
 
 retry:
        lockdep_assert_not_held(&inode->i_lock);
-       VFS_BUG_ON_INODE(inode->i_state & I_CLEAR, inode);
+       VFS_BUG_ON_INODE(inode_state_read_once(inode) & I_CLEAR, inode);
        /*
         * Note this assert is technically racy as if the count is bogusly
         * equal to one, then two CPUs racing to further drop it can both
@@ -1957,14 +1957,14 @@ retry:
        if (atomic_add_unless(&inode->i_count, -1, 1))
                return;
 
-       if ((inode->i_state & I_DIRTY_TIME) && inode->i_nlink) {
+       if ((inode_state_read_once(inode) & I_DIRTY_TIME) && inode->i_nlink) {
                trace_writeback_lazytime_iput(inode);
                mark_inode_dirty_sync(inode);
                goto retry;
        }
 
        spin_lock(&inode->i_lock);
-       if (unlikely((inode->i_state & I_DIRTY_TIME) && inode->i_nlink)) {
+       if (unlikely((inode_state_read(inode) & I_DIRTY_TIME) && inode->i_nlink)) {
                spin_unlock(&inode->i_lock);
                goto retry;
        }
index 6f0e6b19383c87673b79c686dcc50b09f7d59b6e..0d51f57f7ad7f071f300b2c3ee8a00f7f6fe87a2 100644 (file)
@@ -1515,7 +1515,7 @@ struct inode *__isofs_iget(struct super_block *sb,
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                ret = isofs_read_inode(inode, relocated);
                if (ret < 0) {
                        iget_failed(inode);
index d175cccb7c554bc90cda915eedaccf2558f737ff..764bba8ba999ff682cc7856ad36ad0eb87f33254 100644 (file)
@@ -265,7 +265,7 @@ struct inode *jffs2_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))
                return inode;
 
        f = JFFS2_INODE_INFO(inode);
@@ -373,7 +373,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
 {
        struct iattr iattr;
 
-       if (!(inode->i_state & I_DIRTY_DATASYNC)) {
+       if (!(inode_state_read_once(inode) & I_DIRTY_DATASYNC)) {
                jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n",
                          __func__, inode->i_ino);
                return;
index 2a4a288b821c0f9025672d4a47b605a389944333..87ad042221e78959200cce12a59a3ffd6d06c0d7 100644 (file)
@@ -26,8 +26,8 @@ int jfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
                return rc;
 
        inode_lock(inode);
-       if (!(inode->i_state & I_DIRTY_ALL) ||
-           (datasync && !(inode->i_state & I_DIRTY_DATASYNC))) {
+       if (!(inode_state_read_once(inode) & I_DIRTY_ALL) ||
+           (datasync && !(inode_state_read_once(inode) & I_DIRTY_DATASYNC))) {
                /* Make sure committed changes hit the disk */
                jfs_flush_journal(JFS_SBI(inode->i_sb)->log, 1);
                inode_unlock(inode);
index 21f3d029da7dd5d4846aaa942a94198380847353..4709762713efc5f1c6199ccfd9ecefe933e13f67 100644 (file)
@@ -29,7 +29,7 @@ struct inode *jfs_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))
                return inode;
 
        ret = diRead(inode);
index 7840a03e5bcb760b127faba3868d31b67091119c..c16578af3a77ea94c3617c02ab3f21cf9f9b40b3 100644 (file)
@@ -1287,7 +1287,7 @@ int txCommit(tid_t tid,           /* transaction identifier */
                 * to verify this, only a trivial s/I_LOCK/I_SYNC/ was done.
                 * Joern
                 */
-               if (tblk->u.ip->i_state & I_SYNC)
+               if (inode_state_read_once(tblk->u.ip) & I_SYNC)
                        tblk->xflag &= ~COMMIT_LAZY;
        }
 
index 457f91c412d4835b1cffd7ad73a160c596730281..a36aaee98dcec5b8a658ab5bb706b7007c4e62ec 100644 (file)
@@ -251,7 +251,7 @@ struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
        struct inode *inode;
 
        inode = iget_locked(sb, kernfs_ino(kn));
-       if (inode && (inode->i_state & I_NEW))
+       if (inode && (inode_state_read_once(inode) & I_NEW))
                kernfs_init_inode(kn, inode);
 
        return inode;
index ce8c496a6940ac4727e845ac57d8e2645d2ab36f..96e3d7fc7fc66551167a66a08d80da4aeac8d364 100644 (file)
@@ -1542,9 +1542,9 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end,
 
        inode_lock(inode);
        ret = sync_mapping_buffers(inode->i_mapping);
-       if (!(inode->i_state & I_DIRTY_ALL))
+       if (!(inode_state_read_once(inode) & I_DIRTY_ALL))
                goto out;
-       if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
+       if (datasync && !(inode_state_read_once(inode) & I_DIRTY_DATASYNC))
                goto out;
 
        err = sync_inode_metadata(inode, 1);
@@ -1664,7 +1664,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
         * list because mark_inode_dirty() will think
         * that it already _is_ on the dirty list.
         */
-       inode->i_state = I_DIRTY;
+       inode_state_assign_raw(inode, I_DIRTY);
        /*
         * Historically anonymous inodes don't have a type at all and
         * userspace has come to rely on this.
index 32db676127a9eda1ea7f8982ebff6ce2a2354ff6..f220d0e4aedf0f7460862463d4f470a2003844d8 100644 (file)
@@ -589,7 +589,7 @@ struct inode *minix_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))
                return inode;
 
        if (INODE_VERSION(inode) == MINIX_V1)
index 7377020a2cba02501483020e0fc93c279fb38d3e..354a9e84472192990dc4ffb4f9c04ba2df0ef1cb 100644 (file)
@@ -4036,7 +4036,7 @@ int vfs_tmpfile(struct mnt_idmap *idmap,
        inode = file_inode(file);
        if (!(open_flag & O_EXCL)) {
                spin_lock(&inode->i_lock);
-               inode->i_state |= I_LINKABLE;
+               inode_state_set(inode, I_LINKABLE);
                spin_unlock(&inode->i_lock);
        }
        security_inode_post_create_tmpfile(idmap, inode);
@@ -4931,7 +4931,7 @@ int vfs_link(struct dentry *old_dentry, struct mnt_idmap *idmap,
 
        inode_lock(inode);
        /* Make sure we don't allow creating hardlink to an unlinked file */
-       if (inode->i_nlink == 0 && !(inode->i_state & I_LINKABLE))
+       if (inode->i_nlink == 0 && !(inode_state_read_once(inode) & I_LINKABLE))
                error =  -ENOENT;
        else if (max_links && inode->i_nlink >= max_links)
                error = -EMLINK;
@@ -4941,9 +4941,9 @@ int vfs_link(struct dentry *old_dentry, struct mnt_idmap *idmap,
                        error = dir->i_op->link(old_dentry, dir, new_dentry);
        }
 
-       if (!error && (inode->i_state & I_LINKABLE)) {
+       if (!error && (inode_state_read_once(inode) & I_LINKABLE)) {
                spin_lock(&inode->i_lock);
-               inode->i_state &= ~I_LINKABLE;
+               inode_state_clear(inode, I_LINKABLE);
                spin_unlock(&inode->i_lock);
        }
        inode_unlock(inode);
index 486166460e177d52806b41b46cca8f325deb1ef4..3b97bc35de772e505975a798a8f2b2f685bd2d59 100644 (file)
@@ -147,10 +147,10 @@ bool netfs_dirty_folio(struct address_space *mapping, struct folio *folio)
        if (!fscache_cookie_valid(cookie))
                return true;
 
-       if (!(inode->i_state & I_PINNING_NETFS_WB)) {
+       if (!(inode_state_read_once(inode) & I_PINNING_NETFS_WB)) {
                spin_lock(&inode->i_lock);
-               if (!(inode->i_state & I_PINNING_NETFS_WB)) {
-                       inode->i_state |= I_PINNING_NETFS_WB;
+               if (!(inode_state_read(inode) & I_PINNING_NETFS_WB)) {
+                       inode_state_set(inode, I_PINNING_NETFS_WB);
                        need_use = true;
                }
                spin_unlock(&inode->i_lock);
@@ -192,7 +192,7 @@ void netfs_clear_inode_writeback(struct inode *inode, const void *aux)
 {
        struct fscache_cookie *cookie = netfs_i_cookie(netfs_inode(inode));
 
-       if (inode->i_state & I_PINNING_NETFS_WB) {
+       if (inode_state_read_once(inode) & I_PINNING_NETFS_WB) {
                loff_t i_size = i_size_read(inode);
                fscache_unuse_cookie(cookie, aux, &i_size);
        }
index 5c0dc4efc7922767a8a1260d1b6776acba72f2f7..8e6264f62a8f381fefc14905d8c31cb851414841 100644 (file)
@@ -36,12 +36,12 @@ void netfs_single_mark_inode_dirty(struct inode *inode)
 
        mark_inode_dirty(inode);
 
-       if (caching && !(inode->i_state & I_PINNING_NETFS_WB)) {
+       if (caching && !(inode_state_read_once(inode) & I_PINNING_NETFS_WB)) {
                bool need_use = false;
 
                spin_lock(&inode->i_lock);
-               if (!(inode->i_state & I_PINNING_NETFS_WB)) {
-                       inode->i_state |= I_PINNING_NETFS_WB;
+               if (!(inode_state_read(inode) & I_PINNING_NETFS_WB)) {
+                       inode_state_set(inode, I_PINNING_NETFS_WB);
                        need_use = true;
                }
                spin_unlock(&inode->i_lock);
index 18b57c7c2f97b43208f9d61a74453b289aa5dd7b..9e3b1f10ce803fa7c2e176b52516727a490de35a 100644 (file)
@@ -475,7 +475,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                goto out_no_inode;
        }
 
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                struct nfs_inode *nfsi = NFS_I(inode);
                unsigned long now = jiffies;
 
index a3135b5af7eeca201e5a6e6e3c7f692ad9e0b250..f157d43d1312227d9677861ac4e50a4254ff3ad6 100644 (file)
@@ -317,7 +317,7 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
                        WARN_ONCE(1, "NFS: BUG unfreed layout segments.\n");
                pnfs_detach_layout_hdr(lo);
                /* Notify pnfs_destroy_layout_final() that we're done */
-               if (inode->i_state & (I_FREEING | I_CLEAR))
+               if (inode_state_read(inode) & (I_FREEING | I_CLEAR))
                        wake_up_var_locked(lo, &inode->i_lock);
                spin_unlock(&inode->i_lock);
                pnfs_free_layout_hdr(lo);
index 9cb20d4aeab159ef3ba3584d1a3a33ef16ba4dea..cf4062ac092a94420cb3478a9a4b410fb63b41e1 100644 (file)
@@ -1159,7 +1159,7 @@ static int wait_for_concurrent_writes(struct file *file)
                dprintk("nfsd: write resume %d\n", task_pid_nr(current));
        }
 
-       if (inode->i_state & I_DIRTY) {
+       if (inode_state_read_once(inode) & I_DIRTY) {
                dprintk("nfsd: write sync %d\n", task_pid_nr(current));
                err = vfs_fsync(file, 0);
        }
index 46bfc543f9467c9efb8df3fdcfe15bd8513d33f4..d27ff5e5f165b9059aa4ae747f01e19577c66433 100644 (file)
@@ -52,7 +52,7 @@ static void fsnotify_unmount_inodes(struct super_block *sb)
                 * the inode cannot have any associated watches.
                 */
                spin_lock(&inode->i_lock);
-               if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) {
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) {
                        spin_unlock(&inode->i_lock);
                        continue;
                }
index 3959f23c487a2c8ef0875bdf8a54c78851190d53..08266adc42ba4887f087531aca3f7aa7e183f441 100644 (file)
@@ -537,7 +537,7 @@ struct inode *ntfs_iget5(struct super_block *sb, const struct MFT_REF *ref,
                return ERR_PTR(-ENOMEM);
 
        /* If this is a freshly allocated inode, need to read it now. */
-       if (inode->i_state & I_NEW)
+       if (inode_state_read_once(inode) & I_NEW)
                inode = ntfs_read_mft(inode, name, ref);
        else if (ref->seq != ntfs_i(inode)->mi.mrec->seq) {
                /*
index 92a6149da9c102c39227b8785c5d78c1e999fb79..619ff03b15d63706a9058505708fe664455fcbdc 100644 (file)
@@ -2487,7 +2487,7 @@ update:
         * which hasn't been populated yet, so clear the refresh flag
         * and let the caller handle it.
         */
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                status = 0;
                if (lockres)
                        ocfs2_complete_lock_res_refresh(lockres, 0);
index 84115bf8b464f8ecf7d809128fc1a3bfdf8c40d9..78f81950c9eec9bb697c3fa4f90c6283cd68b8aa 100644 (file)
@@ -152,8 +152,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
                mlog_errno(PTR_ERR(inode));
                goto bail;
        }
-       trace_ocfs2_iget5_locked(inode->i_state);
-       if (inode->i_state & I_NEW) {
+       trace_ocfs2_iget5_locked(inode_state_read_once(inode));
+       if (inode_state_read_once(inode) & I_NEW) {
                rc = ocfs2_read_locked_inode(inode, &args);
                unlock_new_inode(inode);
        }
index 135c49c5d848cd65fe59d3f32f19919577a96135..db80af312678e71d4687c06ab6857370dd9bc4de 100644 (file)
@@ -212,7 +212,7 @@ struct inode *omfs_iget(struct super_block *sb, ino_t 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))
                return inode;
 
        bh = omfs_bread(inode->i_sb, ino);
index 26ecda0e4d19dcf33576584d398ea027bda91684..fb8d84bdedfb20ace799207db4e6c3951edbd8de 100644 (file)
@@ -236,7 +236,7 @@ found:
        mutex_unlock(&op_mutex);
        if (IS_ERR(inode))
                return ERR_CAST(inode);
-       if (inode->i_state & I_NEW) {
+       if (inode_state_read_once(inode) & I_NEW) {
                simple_inode_init_ts(inode);
                ent_oi = OP_I(inode);
                ent_oi->type = ent_type;
index a01400cd41fdfc5b48c814b9e708d81760723221..1eb4fbe35a4620f61e23e3e9545753494610671c 100644 (file)
@@ -1041,7 +1041,7 @@ struct inode *orangefs_iget(struct super_block *sb,
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
 
        error = orangefs_inode_getattr(inode, ORANGEFS_GETATTR_NEW);
index 0fdceb00ca07047117408c6c5ba177218aba3ede..9ab1119ebd28a08d775579009e6ed6602df491a7 100644 (file)
@@ -247,7 +247,7 @@ again:
        spin_lock(&inode->i_lock);
        /* Must have all the attributes in the mask and be within cache time. */
        if ((!flags && time_before(jiffies, orangefs_inode->getattr_time)) ||
-           orangefs_inode->attr_valid || inode->i_state & I_DIRTY_PAGES) {
+           orangefs_inode->attr_valid || inode_state_read(inode) & I_DIRTY_PAGES) {
                if (orangefs_inode->attr_valid) {
                        spin_unlock(&inode->i_lock);
                        write_inode_now(inode, 1);
@@ -281,13 +281,13 @@ again2:
        spin_lock(&inode->i_lock);
        /* Must have all the attributes in the mask and be within cache time. */
        if ((!flags && time_before(jiffies, orangefs_inode->getattr_time)) ||
-           orangefs_inode->attr_valid || inode->i_state & I_DIRTY_PAGES) {
+           orangefs_inode->attr_valid || inode_state_read(inode) & I_DIRTY_PAGES) {
                if (orangefs_inode->attr_valid) {
                        spin_unlock(&inode->i_lock);
                        write_inode_now(inode, 1);
                        goto again2;
                }
-               if (inode->i_state & I_DIRTY_PAGES) {
+               if (inode_state_read(inode) & I_DIRTY_PAGES) {
                        ret = 0;
                        goto out_unlock;
                }
index 42fead1efe520491e5be8e1e4cf848cea4828fbb..2d0fed2ecbfddc572acd1bf416ea98ff448f77a8 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -908,7 +908,7 @@ static struct inode * get_pipe_inode(void)
         * list because "mark_inode_dirty()" will think
         * that it already _is_ on the dirty list.
         */
-       inode->i_state = I_DIRTY;
+       inode_state_assign_raw(inode, I_DIRTY);
        inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR;
        inode->i_uid = current_fsuid();
        inode->i_gid = current_fsgid();
index e399e2dd3a1248c36f6fef045a80564dc1034077..31d78da203eade6928976cb9a0e1297038a81281 100644 (file)
@@ -290,7 +290,7 @@ struct inode *qnx4_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))
                return inode;
 
        qnx4_inode = qnx4_raw_inode(inode);
index 3310d1ad4d0e9875872227f66a2dade02fe7f1c3..88d28500508328a4ac3df7889552823f4f8c25db 100644 (file)
@@ -521,7 +521,7 @@ struct inode *qnx6_iget(struct super_block *sb, unsigned 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))
                return inode;
 
        ei = QNX6_I(inode);
index 6c4a6ee1fa2b6f1dbd531ab6e772589cb6283ab8..376739f6420ed5a415fe7c2d2bcfab65c0820208 100644 (file)
@@ -1033,7 +1033,7 @@ static int add_dquot_ref(struct super_block *sb, int type)
        spin_lock(&sb->s_inode_list_lock);
        list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
                spin_lock(&inode->i_lock);
-               if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) ||
+               if ((inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) ||
                    !atomic_read(&inode->i_writecount) ||
                    !dqinit_needed(inode, type)) {
                        spin_unlock(&inode->i_lock);
index 0addcc849ff2ca9412955ab1d6eb3f1ec8134d98..360b008541154e4e289b2ef967e34bcb01d76836 100644 (file)
@@ -302,7 +302,7 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
        if (!i)
                return ERR_PTR(-ENOMEM);
 
-       if (!(i->i_state & I_NEW))
+       if (!(inode_state_read_once(i) & I_NEW))
                return i;
 
        /* precalculate the data offset */
index cceae3b78698c3cd1d412ceff6d48aa7e0059b83..82b687414e65e66e292e45fe6f74346af3be8e59 100644 (file)
@@ -86,7 +86,7 @@ struct inode *squashfs_iget(struct super_block *sb, long long ino,
 
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
 
        err = squashfs_read_inode(inode, ino);
index 2955cd4c77a3edf3a58ed67dd6c62786b713c1b2..73b3efb35b26c1dc0ccd751146e3265a553c5957 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -182,7 +182,7 @@ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync)
 
        if (!file->f_op->fsync)
                return -EINVAL;
-       if (!datasync && (inode->i_state & I_DIRTY_TIME))
+       if (!datasync && (inode_state_read_once(inode) & I_DIRTY_TIME))
                mark_inode_dirty_sync(inode);
        return file->f_op->fsync(file, start, end, datasync);
 }
index ca41ce8208c461b3a509761c271fd8e41f87f337..c3265b8804f5f6243eeeab034a362c0e1088c2f1 100644 (file)
@@ -1323,7 +1323,7 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
        inode_lock(inode);
 
        /* Synchronize the inode unless this is a 'datasync()' call. */
-       if (!datasync || (inode->i_state & I_DIRTY_DATASYNC)) {
+       if (!datasync || (inode_state_read_once(inode) & I_DIRTY_DATASYNC)) {
                err = inode->i_sb->s_op->write_inode(inode, NULL);
                if (err)
                        goto out;
index 46952a33c4e6fa0e1890f1dd992403e57e154496..f453c37cee376a19278f57dbdbdf6fcb5c19449f 100644 (file)
@@ -114,7 +114,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
        inode = iget_locked(sb, inum);
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (!(inode->i_state & I_NEW))
+       if (!(inode_state_read_once(inode) & I_NEW))
                return inode;
        ui = ubifs_inode(inode);
 
index a79d73f28aa788e16027ae04fc2a2ee6bccb33ef..7fae8002344a0e1e7e51022e97f1e0e2424185f9 100644 (file)
@@ -1962,7 +1962,7 @@ struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino,
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
-       if (!(inode->i_state & I_NEW)) {
+       if (!(inode_state_read_once(inode) & I_NEW)) {
                if (UDF_I(inode)->i_hidden != hidden_inode) {
                        iput(inode);
                        return ERR_PTR(-EFSCORRUPTED);
index 8361c00e8fa6fecf592d25d19504f5631a08a509..e2b0a35de2a7000f46a298114c1dcaffa17c43dc 100644 (file)
@@ -655,7 +655,7 @@ struct inode *ufs_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))
                return inode;
 
        ufsi = UFS_I(inode);
index 70be0b3dda496625fa879b368dc453824d57d664..086a31269198414a5aefe87a6f82edecdbed3948 100644 (file)
@@ -644,7 +644,7 @@ static struct inode *zonefs_get_file_inode(struct inode *dir,
        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)) {
                WARN_ON_ONCE(inode->i_private != z);
                return inode;
        }
@@ -683,7 +683,7 @@ static struct inode *zonefs_get_zgroup_inode(struct super_block *sb,
        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))
                return inode;
 
        inode->i_ino = ino;
index 41b6c9386b692482b073649080b4ad4b55516c19..c5740c6d37a2c4e3dafe37ac383d7b525b596f45 100644 (file)
@@ -72,7 +72,7 @@ static void collect_wb_stats(struct wb_stats *stats,
        list_for_each_entry(inode, &wb->b_more_io, i_io_list)
                stats->nr_more_io++;
        list_for_each_entry(inode, &wb->b_dirty_time, i_io_list)
-               if (inode->i_state & I_DIRTY_TIME)
+               if (inode_state_read_once(inode) & I_DIRTY_TIME)
                        stats->nr_dirty_time++;
        spin_unlock(&wb->list_lock);
 
index 0bade2c5aa1d007e6e13951aba19ae01d21a9baf..d4d72f406d5834f6a3b5cfe0eed692cb3c9b59d4 100644 (file)
@@ -1296,7 +1296,7 @@ static void hook_sb_delete(struct super_block *const sb)
                 * second call to iput() for the same Landlock object.  Also
                 * checks I_NEW because such inode cannot be tied to an object.
                 */
-               if (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) {
+               if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) {
                        spin_unlock(&inode->i_lock);
                        continue;
                }