hide ->i_state behind accessors
Subsystems (52)
v4 cover hide ->i_state behind accessors
This is generated against:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?h=vfs-6.18.inode.refcount.preliminaries
First commit message quoted verbatim with rationable + API:
[quote]
Open-coded accesses prevent asserting they are done correctly. One obvious aspect is locking, but significantly more can checked. For example it can be detected when the code is clearing flags which are already missing, or is setting flags when it is illegal (e.g., I_FREEING when ->i_count > 0).
In order to keep things manageable this patchset merely gets the thing off the ground with only lockdep checks baked in.
Current consumers can be trivially converted.
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode)inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B)inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B)inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode)inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B)inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B)inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
The "_once" vs "_raw" discrepancy stems from the read variant differing by READ_ONCE as opposed to just lockdep checks.
[/quote]
A series with one patch per subsystem/filesystem is quite big (over 50 largely trivial mails) and that's probably not warranted. Instead, core kernel was handled in one commit and only file systems with changes which should be looked at got split (all the rest is one combined commit). This all mostly mechanical churn and that alone should not be objectional. If someone does not like the API, they should raise it here.
per-fs postings are there in case something is correctly marked as unlocked access.
Note that in the worst case should a mistake be made here, it either will fail to spot ->i_lock not being held (which is equivalent to the stock state) OR it will generate a lockdep splat. While not pretty, it is loud and readily fixable. Otherwise this patchset is a NOP.
Testing was limited:
kernel with CONFIG_DEBUG_VFS + lockdep was booted with ext4, survived kernel builds and whatnot. xfs and btrfs filesystems were mounted had files linked and unlinked on them.
I very much will need someone with more resources to give this a beating. I tried to err on the side of expecting the caller does *need* ->i_lock and it is possible something is using inode_state_read() instead of inode_state_read_once() as a result. If so, there will be a lockdep splat though.
Coccinelle was used to do the conversion, with all changes audited + some manual fixups (more eyes welcome):
@@
expression inode, flags;
@@
- inode->i_state & flags
+ inode_state_read(inode) & flags
@@
expression inode, flags;
@@
- inode->i_state &= ~flags
+ inode_state_del(inode, flags)
@@
expression inode, flags;
@@
- inode->i_state |= flags
+ inode_state_add(inode, flags)
@@
expression inode, flags;
@@
- inode->i_state = flags
+ inode_state_set_raw(inode, flags)
Patch breakdown:
fs: provide accessors for ->i_state
This only adds the routines, nothing is using them and overall it's a NOP.
fs: use ->i_state accessors in core kernel
Converts the entirety of the kernel modulo specific file systems.
fs: mechanically convert most filesystems to use ->i_state accessors
This includes all trivial changes (mostly when the filesystem just checks for I_NEW after getting the inode from the hash).
btrfs: use the new ->i_state accessors
netfs: use the new ->i_state accessors
nilfs2: use the new ->i_state accessors
xfs: use the new ->i_state accessors
ext4: use the new ->i_state accessors
f2fs: use the new ->i_state accessors
ceph: use the new ->i_state accessors
overlayfs: use the new ->i_state accessors
Per-fs split if there was more work in the area just to sanity check by interested parties.
fs: make plain ->i_state access fail to compile
This hides ->i_state behind a struct, so things nicely fail to compile if someone open-codes plain access.
v3:
- rename accessors (s/unchecked/raw; s/unstable/once/)
- rebase
- provide actual commit messages
- per fs patches as I deemed applicable
Mateusz Guzik (12):
fs: provide accessors for ->i_state
fs: use ->i_state accessors in core kernel
fs: mechanically convert most filesystems to use ->i_state accessors
btrfs: use the new ->i_state accessors
netfs: use the new ->i_state accessors
nilfs2: use the new ->i_state accessors
xfs: use the new ->i_state accessors
ext4: use the new ->i_state accessors
f2fs: use the new ->i_state accessors
ceph: use the new ->i_state accessors
overlayfs: use the new ->i_state accessors
fs: make plain ->i_state access fail to compile
block/bdev.c | 4 +- drivers/dax/super.c | 2 +- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/affs/inode.c | 2 +- fs/afs/dynroot.c | 6 +- fs/afs/inode.c | 8 +- fs/bcachefs/fs.c | 7 +- fs/befs/linuxvfs.c | 2 +- fs/bfs/inode.c | 2 +- fs/btrfs/inode.c | 10 +-- fs/buffer.c | 4 +- fs/ceph/cache.c | 2 +- fs/ceph/crypto.c | 4 +- fs/ceph/file.c | 4 +- fs/ceph/inode.c | 28 +++---- fs/coda/cnode.c | 4 +- fs/cramfs/inode.c | 2 +- fs/crypto/keyring.c | 2 +- fs/crypto/keysetup.c | 2 +- fs/dcache.c | 8 +- fs/drop_caches.c | 2 +- fs/ecryptfs/inode.c | 6 +- fs/efs/inode.c | 2 +- fs/erofs/inode.c | 2 +- fs/ext2/inode.c | 2 +- fs/ext4/inode.c | 10 +-- fs/ext4/orphan.c | 4 +- fs/f2fs/data.c | 2 +- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 4 +- fs/f2fs/super.c | 2 +- fs/freevxfs/vxfs_inode.c | 2 +- fs/fs-writeback.c | 123 ++++++++++++++++--------------- fs/fuse/inode.c | 4 +- fs/gfs2/file.c | 2 +- fs/gfs2/glops.c | 2 +- fs/gfs2/inode.c | 4 +- fs/gfs2/ops_fstype.c | 2 +- fs/hfs/btree.c | 2 +- fs/hfs/inode.c | 2 +- fs/hfsplus/super.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/dir.c | 2 +- fs/hpfs/inode.c | 2 +- fs/inode.c | 104 +++++++++++++------------- fs/isofs/inode.c | 2 +- fs/jffs2/fs.c | 4 +- fs/jfs/file.c | 4 +- fs/jfs/inode.c | 2 +- fs/jfs/jfs_txnmgr.c | 2 +- fs/kernfs/inode.c | 2 +- fs/libfs.c | 6 +- fs/minix/inode.c | 2 +- fs/namei.c | 8 +- fs/netfs/misc.c | 8 +- fs/netfs/read_single.c | 6 +- fs/nfs/inode.c | 2 +- fs/nfs/pnfs.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/nilfs2/cpfile.c | 2 +- fs/nilfs2/dat.c | 2 +- fs/nilfs2/ifile.c | 2 +- fs/nilfs2/inode.c | 10 +-- fs/nilfs2/sufile.c | 2 +- fs/notify/fsnotify.c | 2 +- fs/ntfs3/inode.c | 2 +- fs/ocfs2/dlmglue.c | 2 +- fs/ocfs2/inode.c | 10 +-- fs/omfs/inode.c | 2 +- fs/openpromfs/inode.c | 2 +- fs/orangefs/inode.c | 2 +- fs/orangefs/orangefs-utils.c | 6 +- fs/overlayfs/dir.c | 2 +- fs/overlayfs/inode.c | 6 +- fs/overlayfs/util.c | 10 +-- fs/pipe.c | 2 +- fs/qnx4/inode.c | 2 +- fs/qnx6/inode.c | 2 +- fs/quota/dquot.c | 2 +- fs/romfs/super.c | 2 +- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/inode.c | 14 ++-- fs/squashfs/inode.c | 2 +- fs/sync.c | 2 +- fs/ubifs/file.c | 2 +- fs/ubifs/super.c | 2 +- fs/udf/inode.c | 2 +- fs/ufs/inode.c | 2 +- fs/xfs/scrub/common.c | 2 +- fs/xfs/scrub/inode_repair.c | 2 +- fs/xfs/scrub/parent.c | 2 +- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_health.c | 4 +- fs/xfs/xfs_icache.c | 6 +- fs/xfs/xfs_inode.c | 6 +- fs/xfs/xfs_inode_item.c | 4 +- fs/xfs/xfs_iops.c | 2 +- fs/xfs/xfs_reflink.h | 2 +- fs/zonefs/super.c | 4 +- include/linux/backing-dev.h | 5 +- include/linux/fs.h | 70 +++++++++++++++++- include/linux/writeback.h | 4 +- include/trace/events/writeback.h | 8 +- mm/backing-dev.c | 2 +- security/landlock/fs.c | 2 +- 106 files changed, 371 insertions(+), 310 deletions(-)
Signature · 1 line
2.43.0
PATCH v4 1/12 fs: provide accessors for ->i_state
Open-coded accesses prevent asserting they are done correctly. One obvious aspect is locking, but significantly more can checked. For example it can be detected when the code is clearing flags which are already missing, or is setting flags when it is illegal (e.g., I_FREEING when ->i_count > 0).
In order to keep things manageable this patchset merely gets the thing off the ground with only lockdep checks baked in.
Current consumers can be trivially converted.
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode)inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B)inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B)inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode)inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B)inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B)inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
The "_once" vs "_raw" discrepancy stems from the read variant differing by READ_ONCE as opposed to just lockdep checks.
--- include/linux/fs.h | 59 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-)
include/linux/fs.h +57 -2
@@ -756,7 +756,7 @@ enum inode_state_bits {/* reserved wait address bit 3 */ }; -enum inode_state_flags_t { +enum inode_state_flags_enum {I_NEW = (1U << __I_NEW),I_SYNC = (1U << __I_SYNC),I_LRU_ISOLATING = (1U << __I_LRU_ISOLATING),
@@ -840,7 +840,7 @@ struct inode {#endif /* Misc */ -enum inode_state_flags_t i_state; +enum inode_state_flags_enum i_state;/* 32-bit hole */ struct rw_semaphore i_rwsem;
@@ -899,6 +899,61 @@ struct inode {void *i_private;/* fs or device private pointer */ } __randomize_layout; +/* +* i_state handling +* +* We hide all of it behind helpers so that we can validate consumers. +*/ +static inline enum inode_state_flags_enum inode_state_read_once (struct inode *inode) +{ +return READ_ONCE (inode->i_state); +} + +static inline enum inode_state_flags_enum inode_state_read (struct inode *inode) +{ +lockdep_assert_held (&inode->i_lock); +return inode->i_state; +} + +static inline void inode_state_add_raw (struct inode *inode, +enum inode_state_flags_enum addflags) +{ +WRITE_ONCE (inode->i_state, inode->i_state | addflags); +} + +static inline void inode_state_add (struct inode *inode, +enum inode_state_flags_enum addflags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_add_raw (inode, addflags); +} + +static inline void inode_state_del_raw (struct inode *inode, +enum inode_state_flags_enum delflags) +{ +WRITE_ONCE (inode->i_state, inode->i_state & ~delflags); +} + +static inline void inode_state_del (struct inode *inode, +enum inode_state_flags_enum delflags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_del_raw (inode, delflags); +} + +static inline void inode_state_set_raw (struct inode *inode, +enum inode_state_flags_enum setflags) +{ +WRITE_ONCE (inode->i_state, setflags); +} + +static inline void inode_state_set (struct inode *inode, +enum inode_state_flags_enum setflags) +{ +lockdep_assert_held (&inode->i_lock); +inode_state_set_raw (inode, setflags); +} +static inline void inode_set_cached_link (struct inode *inode,char *link,int linklen) {VFS_WARN_ON_INODE (strlen (link) != linklen, inode);
Signature · 1 line
2.43.0
PATCH v4 2/12 fs: use ->i_state accessors in core kernel
In reply to Mateusz Guzik---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
block/bdev.c | 4 +- drivers/dax/super.c | 2 +- fs/buffer.c | 4 +- fs/crypto/keyring.c | 2 +- fs/crypto/keysetup.c | 2 +- fs/dcache.c | 8 +- fs/drop_caches.c | 2 +- fs/fs-writeback.c | 123 ++++++++++++++++--------------- fs/inode.c | 104 +++++++++++++------------- fs/libfs.c | 6 +- fs/namei.c | 8 +- fs/notify/fsnotify.c | 2 +- fs/pipe.c | 2 +- fs/quota/dquot.c | 2 +- fs/sync.c | 2 +- include/linux/backing-dev.h | 5 +- include/linux/fs.h | 4 +- include/linux/writeback.h | 4 +- include/trace/events/writeback.h | 8 +- mm/backing-dev.c | 2 +- security/landlock/fs.c | 2 +- 21 files changed, 149 insertions(+), 149 deletions(-)
block/bdev.c +2 -2
@@ -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 ;
drivers/dax/super.c +1 -1
@@ -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 ;
fs/buffer.c +2 -2
@@ -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 );
fs/crypto/keyring.c +1 -1
@@ -957,7 +957,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 ; }
fs/crypto/keysetup.c +1 -1
@@ -859,7 +859,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 ;/*
fs/dcache.c +4 -4
@@ -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_add (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,8 +1980,8 @@ 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 )); - inode->i_state &= ~I_NEW & ~I_CREATING ; +WARN_ON (!(inode_state_read (inode) &I_NEW )); +inode_state_del (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
fs/drop_caches.c +1 -1
@@ -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 ;
fs/fs-writeback.c +62 -61
389 lines not on this page · raw message
fs/inode.c +51 -53
340 lines not on this page · raw message
fs/libfs.c +3 -3
@@ -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_set_raw (inode,I_DIRTY );/* * Historically anonymous inodes don't have a type at all and * userspace has come to rely on this.
fs/namei.c +4 -4
@@ -3948,7 +3948,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_add (inode,I_LINKABLE );spin_unlock (&inode->i_lock); }security_inode_post_create_tmpfile (idmap, inode);
@@ -4844,7 +4844,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 ;
@@ -4854,9 +4854,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_del (inode,I_LINKABLE );spin_unlock (&inode->i_lock); }inode_unlock (inode);
fs/notify/fsnotify.c +1 -1
@@ -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 ; }
fs/pipe.c +1 -1
@@ -906,7 +906,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_set_raw (inode,I_DIRTY ); inode->i_mode =S_IFIFO |S_IRUSR |S_IWUSR ; inode->i_uid =current_fsuid (); inode->i_gid =current_fsgid ();
fs/quota/dquot.c +1 -1
@@ -1030,7 +1030,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);
fs/sync.c +1 -1
@@ -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); }
include/linux/backing-dev.h +3 -2
@@ -289,10 +289,11 @@ unlocked_inode_to_wb_begin(struct inode *inode, struct wb_lock_cookie *cookie)rcu_read_lock ();/* -* Paired with store_release in inode_switch_wbs_work_fn() and +* 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 =smp_load_acquire (&inode->i_state) &I_WB_SWITCH ; + cookie->locked =inode_state_read_once (inode) &I_WB_SWITCH ; +smp_rmb ();if (unlikely (cookie->locked))xa_lock_irqsave (&inode->i_mapping->i_pages, cookie->flags);
include/linux/fs.h +2 -2
@@ -2682,8 +2682,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);
include/linux/writeback.h +2 -2
@@ -193,7 +193,7 @@ void inode_io_list_del(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 )); }#ifdef CONFIG_CGROUP_WRITEBACK
@@ -234,7 +234,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 ; }
include/trace/events/writeback.h +4 -4
@@ -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; ),
@@ -719,7 +719,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)); ),
@@ -758,7 +758,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;
@@ -810,7 +810,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; ),
mm/backing-dev.c +1 -1
@@ -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);
security/landlock/fs.c +1 -1
@@ -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 ; }
Signature · 1 line
2.43.0
PATCH v4 3/12 fs: mechanically convert most filesystems to use ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/affs/inode.c | 2 +- fs/afs/dynroot.c | 6 +++--- fs/afs/inode.c | 8 ++++---- fs/bcachefs/fs.c | 7 +++---- fs/befs/linuxvfs.c | 2 +- fs/bfs/inode.c | 2 +- fs/coda/cnode.c | 4 ++-- fs/cramfs/inode.c | 2 +- fs/ecryptfs/inode.c | 6 +++--- fs/efs/inode.c | 2 +- fs/erofs/inode.c | 2 +- fs/ext2/inode.c | 2 +- fs/freevxfs/vxfs_inode.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/gfs2/file.c | 2 +- fs/gfs2/glops.c | 2 +- fs/gfs2/inode.c | 4 ++-- fs/gfs2/ops_fstype.c | 2 +- fs/hfs/btree.c | 2 +- fs/hfs/inode.c | 2 +- fs/hfsplus/super.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/dir.c | 2 +- fs/hpfs/inode.c | 2 +- fs/isofs/inode.c | 2 +- fs/jffs2/fs.c | 4 ++-- fs/jfs/file.c | 4 ++-- fs/jfs/inode.c | 2 +- fs/jfs/jfs_txnmgr.c | 2 +- fs/kernfs/inode.c | 2 +- fs/minix/inode.c | 2 +- fs/nfs/inode.c | 2 +- fs/nfs/pnfs.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/ntfs3/inode.c | 2 +- fs/ocfs2/dlmglue.c | 2 +- fs/ocfs2/inode.c | 10 +++++----- fs/omfs/inode.c | 2 +- fs/openpromfs/inode.c | 2 +- fs/orangefs/inode.c | 2 +- fs/orangefs/orangefs-utils.c | 6 +++--- fs/qnx4/inode.c | 2 +- fs/qnx6/inode.c | 2 +- fs/romfs/super.c | 2 +- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/inode.c | 14 +++++++------- fs/squashfs/inode.c | 2 +- fs/ubifs/file.c | 2 +- fs/ubifs/super.c | 2 +- fs/udf/inode.c | 2 +- fs/ufs/inode.c | 2 +- fs/zonefs/super.c | 4 ++-- 54 files changed, 81 insertions(+), 82 deletions(-)
fs/9p/vfs_inode.c +1 -1
@@ -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
fs/9p/vfs_inode_dotl.c +1 -1
@@ -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
fs/affs/inode.c +1 -1
@@ -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);
fs/afs/dynroot.c +3 -3
@@ -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 );
fs/afs/inode.c +4 -4
@@ -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 )
@@ -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 ,
fs/bcachefs/fs.c +3 -4
@@ -347,7 +347,7 @@ static struct bch_inode_info *bch2_inode_hash_find(struct bch_fs *c, struct btrespin_unlock (&inode->v.i_lock);return NULL ; } -if ((inode->v.i_state & (I_FREEING |I_WILL_FREE ))) { +if ((inode_state_read (&inode->v) & (I_FREEING |I_WILL_FREE ))) {if (!trans) {__wait_on_freeing_inode (c, inode, inum); }else {
@@ -411,7 +411,7 @@ static struct bch_inode_info *bch2_inode_hash_insert(struct bch_fs *c,* only insert fully created inodes in the inode hash table. But * discard_new_inode() expects it to be set... */ - inode->v.i_state |=I_NEW ; +inode_state_add_raw (&inode->v,I_NEW );/* * We don't want bch2_evict_inode() to delete the inode on disk, * we just raced and had another inode in cache. Normally new
@@ -2224,8 +2224,7 @@ void bch2_evict_subvolume_inodes(struct bch_fs *c, snapshot_id_list *s)if (!snapshot_list_has_id (s, inode->ei_inum.subvol))continue ; -if (!(inode->v.i_state &I_DONTCACHE ) && - !(inode->v.i_state &I_FREEING ) && +if (!(inode_state_read_once (&inode->v) & (I_DONTCACHE |I_FREEING )) &&igrab (&inode->v)) { this_pass_clean = false;
fs/befs/linuxvfs.c +1 -1
@@ -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);
fs/bfs/inode.c +1 -1
@@ -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)) {
fs/coda/cnode.c +2 -2
@@ -70,7 +70,7 @@ struct inode * coda_iget(struct super_block * sb, struct CodaFid * fid,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; }
fs/cramfs/inode.c +1 -1
@@ -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 ) {
fs/ecryptfs/inode.c +3 -3
@@ -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;
@@ -373,7 +373,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); }
fs/efs/inode.c +1 -1
@@ -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);
fs/erofs/inode.c +1 -1
@@ -297,7 +297,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) {
fs/ext2/inode.c +1 -1
@@ -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);
fs/freevxfs/vxfs_inode.c +1 -1
@@ -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);
fs/fuse/inode.c +2 -2
@@ -161,7 +161,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);
@@ -506,7 +506,7 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,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 ;
fs/gfs2/file.c +1 -1
@@ -744,7 +744,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end, {struct address_space *mapping = file->f_mapping;struct inode *inode = mapping->host; -int sync_state = inode->i_state &I_DIRTY ; +int sync_state =inode_state_read_once (inode) &I_DIRTY ;struct gfs2_inode *ip =GFS2_I (inode);int ret =0 , ret1 =0 ;
fs/gfs2/glops.c +1 -1
@@ -394,7 +394,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)u16 height, depth;umode_t mode =be32_to_cpu (str->di_mode);struct inode *inode = &ip->i_inode; -bool is_new = inode->i_state &I_NEW ; +bool is_new =inode_state_read_once (inode) &I_NEW ;if (unlikely (ip->i_no_addr !=be64_to_cpu (str->di_num.no_addr))) {gfs2_consist_inode (ip);
fs/gfs2/inode.c +2 -2
@@ -127,7 +127,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, ip =GFS2_I (inode); -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {struct gfs2_sbd *sdp =GFS2_SB (inode);struct gfs2_glock *io_gl;int extra_flags =0 ;
@@ -924,7 +924,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,gfs2_dir_no_add (&da);gfs2_glock_dq_uninit (&d_gh);if (!IS_ERR_OR_NULL (inode)) { -if (inode->i_state &I_NEW ) +if (inode_state_read_once (inode) &I_NEW )iget_failed (inode);else iput (inode);
fs/gfs2/ops_fstype.c +1 -1
@@ -1749,7 +1749,7 @@ static void gfs2_evict_inodes(struct super_block *sb)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 )) && !need_resched ()) {spin_unlock (&inode->i_lock);continue ;
fs/hfs/btree.c +1 -1
@@ -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 ;
fs/hfs/inode.c +1 -1
@@ -401,7 +401,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; }
fs/hfsplus/super.c +1 -1
@@ -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;INIT_LIST_HEAD (&HFSPLUS_I (inode)->open_dir_list);
fs/hostfs/hostfs_kern.c +1 -1
@@ -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);
fs/hpfs/dir.c +1 -1
@@ -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);
fs/hpfs/inode.c +1 -1
@@ -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);
fs/isofs/inode.c +1 -1
@@ -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);
fs/jffs2/fs.c +2 -2
@@ -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 ;
fs/jfs/file.c +2 -2
@@ -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);
fs/jfs/inode.c +1 -1
@@ -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);
fs/jfs/jfs_txnmgr.c +1 -1
@@ -1286,7 +1286,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 ; }
fs/kernfs/inode.c +1 -1
@@ -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;
fs/minix/inode.c +1 -1
@@ -583,7 +583,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 )
fs/nfs/inode.c +1 -1
@@ -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;
fs/nfs/pnfs.c +1 -1
@@ -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);
fs/nfsd/vfs.c +1 -1
@@ -1139,7 +1139,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 ); }
fs/ntfs3/inode.c +1 -1
@@ -536,7 +536,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) {/*
fs/ocfs2/dlmglue.c +1 -1
@@ -2487,7 +2487,7 @@ int ocfs2_inode_lock_full_nested(struct inode *inode,* 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 );
fs/ocfs2/inode.c +5 -5
@@ -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); }
@@ -1307,12 +1307,12 @@ int ocfs2_drop_inode(struct inode *inode) inode->i_nlink, oi->ip_flags);assert_spin_locked (&inode->i_lock); - inode->i_state |=I_WILL_FREE ; +inode_state_add (inode,I_WILL_FREE );spin_unlock (&inode->i_lock);write_inode_now (inode,1 );spin_lock (&inode->i_lock); -WARN_ON (inode->i_state &I_NEW ); - inode->i_state &= ~I_WILL_FREE ; +WARN_ON (inode_state_read (inode) &I_NEW ); +inode_state_del (inode,I_WILL_FREE );return 1 ; }
fs/omfs/inode.c +1 -1
@@ -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);
fs/openpromfs/inode.c +1 -1
@@ -236,7 +236,7 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentrymutex_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;
fs/orangefs/inode.c +1 -1
@@ -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 );
fs/orangefs/orangefs-utils.c +3 -3
@@ -247,7 +247,7 @@ int orangefs_inode_getattr(struct inode *inode, int flags)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 @@ int orangefs_inode_getattr(struct inode *inode, int flags)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; }
fs/qnx4/inode.c +1 -1
@@ -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);
fs/qnx6/inode.c +1 -1
@@ -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);
fs/romfs/super.c +1 -1
@@ -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 */
fs/smb/client/cifsfs.c +1 -1
@@ -444,7 +444,7 @@ cifs_evict_inode(struct inode *inode) {netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data); -if (inode->i_state &I_PINNING_NETFS_WB ) +if (inode_state_read_once (inode) &I_PINNING_NETFS_WB )cifs_fscache_unuse_inode_cookie (inode, true);cifs_fscache_release_inode_cookie (inode);clear_inode (inode);
fs/smb/client/inode.c +7 -7
@@ -101,7 +101,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)cifs_dbg (FYI ,"%s: revalidating inode %llu\n" , __func__, cifs_i->uniqueid); -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {cifs_dbg (FYI ,"%s: inode %llu is new\n" , __func__, cifs_i->uniqueid);return ;
@@ -146,7 +146,7 @@ cifs_nlink_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)*/ if (fattr->cf_flags &CIFS_FATTR_UNKNOWN_NLINK ) {/* only provide fake values on a new inode */ -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {if (fattr->cf_cifsattrs &ATTR_DIRECTORY )set_nlink (inode,2 );else
@@ -167,12 +167,12 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,struct cifsInodeInfo *cifs_i =CIFS_I (inode);struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -if (!(inode->i_state &I_NEW ) && +if (!(inode_state_read_once (inode) &I_NEW ) &&unlikely (inode_wrong_type (inode, fattr->cf_mode))) {CIFS_I (inode)->time =0 ;/* force reval */ return -ESTALE ; } -if (inode->i_state &I_NEW ) +if (inode_state_read_once (inode) &I_NEW )CIFS_I (inode)->netfs.zero_point = fattr->cf_eof;cifs_revalidate_cache (inode, fattr);
@@ -194,7 +194,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr, inode->i_gid = fattr->cf_gid;/* if dynperm is set, don't clobber existing mode */ -if (inode->i_state &I_NEW || +if (inode_state_read_once (inode) &I_NEW || !(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_DYNPERM )) inode->i_mode = fattr->cf_mode;
@@ -236,7 +236,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,if (fattr->cf_flags &CIFS_FATTR_JUNCTION ) inode->i_flags |=S_AUTOMOUNT ; -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {cifs_set_netfs_context (inode);cifs_set_ops (inode); }
@@ -1638,7 +1638,7 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr)cifs_fattr_to_inode (inode, fattr, false);if (sb->s_flags &SB_NOATIME ) inode->i_flags |=S_NOATIME |S_NOCMTIME ; -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_ino = hash;cifs_fscache_get_inode_cookie (inode);unlock_new_inode (inode);
fs/squashfs/inode.c +1 -1
@@ -82,7 +82,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);
fs/ubifs/file.c +1 -1
@@ -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;
fs/ubifs/super.c +1 -1
@@ -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);
fs/udf/inode.c +1 -1
@@ -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 );
fs/ufs/inode.c +1 -1
@@ -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);
fs/zonefs/super.c +2 -2
@@ -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;
Signature · 1 line
2.43.0
PATCH v4 4/12 btrfs: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
fs/btrfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/inode.c +5 -5
@@ -3856,7 +3856,7 @@ static int btrfs_add_inode_to_root(struct btrfs_inode *inode, bool prealloc)ASSERT (ret != -ENOMEM );return ret; }else if (existing) { -WARN_ON (!(existing->vfs_inode.i_state & (I_WILL_FREE |I_FREEING ))); +WARN_ON (!(inode_state_read_once (&existing->vfs_inode) & (I_WILL_FREE |I_FREEING ))); }return 0 ;
@@ -5317,7 +5317,7 @@ static void evict_inode_truncate_pages(struct inode *inode)struct extent_io_tree *io_tree = &BTRFS_I (inode)->io_tree;struct rb_node *node; -ASSERT (inode->i_state &I_FREEING ); +ASSERT (inode_state_read_once (inode) &I_FREEING );truncate_inode_pages_final (&inode->i_data);btrfs_drop_extent_map_range (BTRFS_I (inode),0 , (u64)-1 , false);
@@ -5745,7 +5745,7 @@ struct btrfs_inode *btrfs_iget_path(u64 ino, struct btrfs_root *root,if (!inode)return ERR_PTR (-ENOMEM ); -if (!(inode->vfs_inode.i_state &I_NEW )) +if (!(inode_state_read_once (&inode->vfs_inode) &I_NEW ))return inode; ret =btrfs_read_locked_inode (inode, path);
@@ -5769,7 +5769,7 @@ struct btrfs_inode *btrfs_iget(u64 ino, struct btrfs_root *root)if (!inode)return ERR_PTR (-ENOMEM ); -if (!(inode->vfs_inode.i_state &I_NEW )) +if (!(inode_state_read_once (&inode->vfs_inode) &I_NEW ))return inode; path =btrfs_alloc_path ();
@@ -7435,7 +7435,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,u64 page_start =folio_pos (folio);u64 page_end = page_start +folio_size (folio) -1 ;u64 cur; -int inode_evicting = inode->vfs_inode.i_state &I_FREEING ; +int inode_evicting =inode_state_read_once (&inode->vfs_inode) &I_FREEING ;/* * We have folio locked so no new ordered extent can be created on this
Signature · 1 line
2.43.0
PATCH v4 5/12 netfs: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
fs/netfs/misc.c | 8 ++++---- fs/netfs/read_single.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
fs/netfs/misc.c +4 -4
@@ -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_add (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); }
fs/netfs/read_single.c +3 -3
@@ -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_add (inode,I_PINNING_NETFS_WB ); need_use = true; }spin_unlock (&inode->i_lock);
Signature · 1 line
2.43.0
PATCH v4 6/12 nilfs2: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
fs/nilfs2/cpfile.c | 2 +- fs/nilfs2/dat.c | 2 +- fs/nilfs2/ifile.c | 2 +- fs/nilfs2/inode.c | 10 +++++----- fs/nilfs2/sufile.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
fs/nilfs2/cpfile.c +1 -1
@@ -1148,7 +1148,7 @@ int nilfs_cpfile_read(struct super_block *sb, size_t cpsize, cpfile =nilfs_iget_locked (sb,NULL ,NILFS_CPFILE_INO );if (unlikely (!cpfile))return -ENOMEM ; -if (!(cpfile->i_state &I_NEW )) +if (!(inode_state_read_once (cpfile) &I_NEW )) goto out; err =nilfs_mdt_init (cpfile,NILFS_MDT_GFP ,0 );
fs/nilfs2/dat.c +1 -1
@@ -506,7 +506,7 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size, dat =nilfs_iget_locked (sb,NULL ,NILFS_DAT_INO );if (unlikely (!dat))return -ENOMEM ; -if (!(dat->i_state &I_NEW )) +if (!(inode_state_read_once (dat) &I_NEW )) goto out; err =nilfs_mdt_init (dat,NILFS_MDT_GFP ,sizeof (*di));
fs/nilfs2/ifile.c +1 -1
@@ -188,7 +188,7 @@ int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root, ifile =nilfs_iget_locked (sb, root,NILFS_IFILE_INO );if (unlikely (!ifile))return -ENOMEM ; -if (!(ifile->i_state &I_NEW )) +if (!(inode_state_read_once (ifile) &I_NEW )) goto out; err = nilfs_mdt_init(ifile, NILFS_MDT_GFP,
fs/nilfs2/inode.c +5 -5
@@ -365,7 +365,7 @@ struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) failed_after_creation:clear_nlink (inode); -if (inode->i_state &I_NEW ) +if (inode_state_read_once (inode) &I_NEW )unlock_new_inode (inode);iput (inode);/* * raw_inode will be deleted through
@@ -562,7 +562,7 @@ struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,if (unlikely (!inode))return ERR_PTR (-ENOMEM ); -if (!(inode->i_state &I_NEW )) { +if (!(inode_state_read_once (inode) &I_NEW )) {if (!inode->i_nlink) {iput (inode);return ERR_PTR (-ESTALE );
@@ -591,7 +591,7 @@ struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino, inode =iget5_locked (sb, ino, nilfs_iget_test, nilfs_iget_set, &args);if (unlikely (!inode))return ERR_PTR (-ENOMEM ); -if (!(inode->i_state &I_NEW )) +if (!(inode_state_read_once (inode) &I_NEW ))return inode; err =nilfs_init_gcinode (inode);
@@ -631,7 +631,7 @@ int nilfs_attach_btree_node_cache(struct inode *inode) nilfs_iget_set, &args);if (unlikely (!btnc_inode))return -ENOMEM ; -if (btnc_inode->i_state &I_NEW ) { +if (inode_state_read_once (btnc_inode) &I_NEW ) {nilfs_init_btnc_inode (btnc_inode);unlock_new_inode (btnc_inode); }
@@ -686,7 +686,7 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode) nilfs_iget_set, &args);if (unlikely (!s_inode))return ERR_PTR (-ENOMEM ); -if (!(s_inode->i_state &I_NEW )) +if (!(inode_state_read_once (s_inode) &I_NEW ))return inode;NILFS_I (s_inode)->i_flags =0 ;
fs/nilfs2/sufile.c +1 -1
@@ -1226,7 +1226,7 @@ int nilfs_sufile_read(struct super_block *sb, size_t susize, sufile =nilfs_iget_locked (sb,NULL ,NILFS_SUFILE_INO );if (unlikely (!sufile))return -ENOMEM ; -if (!(sufile->i_state &I_NEW )) +if (!(inode_state_read_once (sufile) &I_NEW )) goto out; err =nilfs_mdt_init (sufile,NILFS_MDT_GFP ,sizeof (*sui));
Signature · 1 line
2.43.0
PATCH v4 7/12 xfs: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
fs/xfs/scrub/common.c | 2 +- fs/xfs/scrub/inode_repair.c | 2 +- fs/xfs/scrub/parent.c | 2 +- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_health.c | 4 ++-- fs/xfs/xfs_icache.c | 6 +++--- fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_inode_item.c | 4 ++-- fs/xfs/xfs_iops.c | 2 +- fs/xfs/xfs_reflink.h | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-)
fs/xfs/scrub/common.c +1 -1
@@ -1249,7 +1249,7 @@ xchk_irele(* hits do not clear DONTCACHE, so we must do it here. */ spin_lock (&VFS_I (ip)->i_lock); -VFS_I (ip)->i_state &= ~I_DONTCACHE ; +inode_state_del (VFS_I (ip),I_DONTCACHE );spin_unlock (&VFS_I (ip)->i_lock); }
fs/xfs/scrub/inode_repair.c +1 -1
@@ -1933,7 +1933,7 @@ xrep_inode_pptr(* Unlinked inodes that cannot be added to the directory tree will not * have a parent pointer. */ -if (inode->i_nlink ==0 && !(inode->i_state &I_LINKABLE )) +if (inode->i_nlink ==0 && !(inode_state_read_once (inode) &I_LINKABLE ))return 0 ;/* Children of the superblock do not have parent pointers. */
fs/xfs/scrub/parent.c +1 -1
@@ -915,7 +915,7 @@ xchk_pptr_looks_zapped(* Temporary files that cannot be linked into the directory tree do not * have attr forks because they cannot ever have parents. */ -if (inode->i_nlink ==0 && !(inode->i_state &I_LINKABLE )) +if (inode->i_nlink ==0 && !(inode_state_read_once (inode) &I_LINKABLE ))return false;/*
fs/xfs/xfs_bmap_util.c +1 -1
@@ -514,7 +514,7 @@ xfs_can_free_eofblocks(* Caller must either hold the exclusive io lock; or be inactivating * the inode, which guarantees there are no other users of the inode. */ -if (!(VFS_I (ip)->i_state &I_FREEING )) +if (!(inode_state_read_once (VFS_I (ip)) &I_FREEING ))xfs_assert_ilocked (ip,XFS_IOLOCK_EXCL );/* prealloc/delalloc exists only on regular files */
fs/xfs/xfs_health.c +2 -2
@@ -285,7 +285,7 @@ xfs_inode_mark_sick(* is not the case here. */ spin_lock (&VFS_I (ip)->i_lock); -VFS_I (ip)->i_state &= ~I_DONTCACHE ; +inode_state_del (VFS_I (ip),I_DONTCACHE );spin_unlock (&VFS_I (ip)->i_lock); }
@@ -309,7 +309,7 @@ xfs_inode_mark_corrupt(* is not the case here. */ spin_lock (&VFS_I (ip)->i_lock); -VFS_I (ip)->i_state &= ~I_DONTCACHE ; +inode_state_del (VFS_I (ip),I_DONTCACHE );spin_unlock (&VFS_I (ip)->i_lock); }
fs/xfs/xfs_icache.c +3 -3
@@ -334,7 +334,7 @@ xfs_reinit_inode(dev_t dev = inode->i_rdev;kuid_t uid = inode->i_uid;kgid_t gid = inode->i_gid; -unsigned long state = inode->i_state; +unsigned long state =inode_state_read_once (inode); error =inode_init_always (mp->m_super, inode);
@@ -345,7 +345,7 @@ xfs_reinit_inode( inode->i_rdev = dev; inode->i_uid = uid; inode->i_gid = gid; - inode->i_state = state; +inode_state_set_raw (inode, state);mapping_set_folio_min_order (inode->i_mapping,M_IGEO (mp)->min_folio_order);return error;
@@ -411,7 +411,7 @@ xfs_iget_recycle( ip->i_flags |=XFS_INEW ;xfs_perag_clear_inode_tag (pag,XFS_INO_TO_AGINO (mp, ip->i_ino),XFS_ICI_RECLAIM_TAG ); - inode->i_state =I_NEW ; +inode_state_set_raw (inode,I_NEW );spin_unlock (&ip->i_flags_lock);spin_unlock (&pag->pag_ici_lock);
fs/xfs/xfs_inode.c +3 -3
@@ -1569,7 +1569,7 @@ xfs_iunlink_reload_next( next_ip->i_prev_unlinked = prev_agino;trace_xfs_iunlink_reload_next (next_ip); rele: -ASSERT (!(VFS_I (next_ip)->i_state &I_DONTCACHE )); +ASSERT (!(inode_state_read_once (VFS_I (next_ip)) &I_DONTCACHE ));if (xfs_is_quotacheck_running (mp) && next_ip)xfs_iflags_set (next_ip,XFS_IQUOTAUNCHECKED );xfs_irele (next_ip);
@@ -2093,7 +2093,7 @@ xfs_rename_alloc_whiteout(*/ xfs_setup_iops (tmpfile);xfs_finish_inode_setup (tmpfile); -VFS_I (tmpfile)->i_state |=I_LINKABLE ; +inode_state_add_raw (VFS_I (tmpfile),I_LINKABLE ); *wip = tmpfile;return 0 ;
@@ -2319,7 +2319,7 @@ xfs_rename(* flag from the inode so it doesn't accidentally get misused in * future. */ -VFS_I (du_wip.ip)->i_state &= ~I_LINKABLE ; +inode_state_del_raw (VFS_I (du_wip.ip),I_LINKABLE ); } out_commit:
fs/xfs/xfs_inode_item.c +2 -2
@@ -113,9 +113,9 @@ xfs_inode_item_precommit(* to log the timestamps, or will clear already cleared fields in the * worst case. */ -if (inode->i_state &I_DIRTY_TIME ) { +if (inode_state_read_once (inode) &I_DIRTY_TIME ) {spin_lock (&inode->i_lock); - inode->i_state &= ~I_DIRTY_TIME ; +inode_state_del (inode,I_DIRTY_TIME );spin_unlock (&inode->i_lock); }
fs/xfs/xfs_iops.c +1 -1
@@ -1419,7 +1419,7 @@ xfs_setup_inode(bool is_meta =xfs_is_internal_inode (ip); inode->i_ino = ip->i_ino; - inode->i_state |=I_NEW ; +inode_state_add_raw (inode,I_NEW );inode_sb_list_add (inode);/* make the inode look hashed for the writeback code */
fs/xfs/xfs_reflink.h +1 -1
@@ -17,7 +17,7 @@ xfs_can_free_cowblocks(struct xfs_inode *ip) {struct inode *inode =VFS_I (ip); -if ((inode->i_state &I_DIRTY_PAGES ) || +if ((inode_state_read_once (inode) &I_DIRTY_PAGES ) ||mapping_tagged (inode->i_mapping,PAGECACHE_TAG_DIRTY ) ||mapping_tagged (inode->i_mapping,PAGECACHE_TAG_WRITEBACK ) ||atomic_read (&inode->i_dio_count))
Signature · 1 line
2.43.0
PATCH v4 8/12 ext4: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
---
cheat sheet:
Suppose flags I_A and I_B are to be handled, then if ->i_lock is held:
state = inode->i_state => state = inode_state_read(inode) inode->i_state |= (I_A | I_B) => inode_state_add(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set(inode, I_A | I_B)
If ->i_lock is not held or only held conditionally, add "_once" suffix for the read routine or "_raw" for the rest:
state = inode->i_state => state = inode_state_read_once(inode) inode->i_state |= (I_A | I_B) => inode_state_add_raw(inode, I_A | I_B) inode->i_state &= ~(I_A | I_B) => inode_state_del_raw(inode, I_A | I_B) inode->i_state = I_A | I_B => inode_state_set_raw(inode, I_A | I_B)
fs/ext4/inode.c | 10 +++++----- fs/ext4/orphan.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
fs/ext4/inode.c +5 -5
@@ -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,
@@ -4581,7 +4581,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);
@@ -5239,7 +5239,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);
@@ -5570,7 +5570,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_del (inode,I_DIRTY_TIME );spin_unlock (&inode->i_lock);spin_lock (&ei->i_raw_lock);
fs/ext4/orphan.c +2 -2
@@ -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));/* * Inode orphaned in orphan file or in orphan list?
@@ -236,7 +236,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);
Signature · 1 line
2.43.0
PATCH v4 9/12 f2fs: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
--- fs/f2fs/data.c | 2 +- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 4 ++-- fs/f2fs/super.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/data.c +1 -1
@@ -4241,7 +4241,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,if (map.m_flags &F2FS_MAP_NEW ) iomap->flags |=IOMAP_F_NEW ; -if ((inode->i_state &I_DIRTY_DATASYNC ) || +if ((inode_state_read_once (inode) &I_DIRTY_DATASYNC ) || offset + length >i_size_read (inode)) iomap->flags |=IOMAP_F_DIRTY ;
fs/f2fs/inode.c +1 -1
@@ -569,7 +569,7 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)if (!inode)return ERR_PTR (-ENOMEM ); -if (!(inode->i_state &I_NEW )) { +if (!(inode_state_read_once (inode) &I_NEW )) {if (is_meta_ino (sbi, ino)) {f2fs_err (sbi,"inaccessible inode: %lu, run fsck to repair" , ino);set_sbi_flag (sbi,SBI_NEED_FSCK );
fs/f2fs/namei.c +2 -2
@@ -844,7 +844,7 @@ static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,f2fs_i_links_write (inode, false);spin_lock (&inode->i_lock); - inode->i_state |=I_LINKABLE ; +inode_state_add (inode,I_LINKABLE );spin_unlock (&inode->i_lock); }else {if (file)
@@ -1057,7 +1057,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, goto put_out_dir;spin_lock (&whiteout->i_lock); - whiteout->i_state &= ~I_LINKABLE ; +inode_state_del (whiteout,I_LINKABLE );spin_unlock (&whiteout->i_lock);iput (whiteout);
fs/f2fs/super.c +1 -1
@@ -1747,7 +1747,7 @@ static int f2fs_drop_inode(struct inode *inode)* - f2fs_gc -> iput -> evict * - inode_wait_for_writeback(inode) */ -if ((!inode_unhashed (inode) && inode->i_state &I_SYNC )) { +if ((!inode_unhashed (inode) &&inode_state_read (inode) &I_SYNC )) {if (!inode->i_nlink && !is_bad_inode (inode)) {/* to avoid evict_inode call simultaneously */ __iget (inode);
Signature · 1 line
2.43.0
PATCH v4 10/12 ceph: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
--- fs/ceph/cache.c | 2 +- fs/ceph/crypto.c | 4 ++-- fs/ceph/file.c | 4 ++-- fs/ceph/inode.c | 28 ++++++++++++++-------------- 4 files changed, 19 insertions(+), 19 deletions(-)
fs/ceph/cache.c +1 -1
@@ -26,7 +26,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)return ;/* Only new inodes! */ -if (!(inode->i_state &I_NEW )) +if (!(inode_state_read_once (inode) &I_NEW ))return ;WARN_ON_ONCE (ci->netfs.cache);
fs/ceph/crypto.c +2 -2
@@ -329,7 +329,7 @@ int ceph_encode_encrypted_dname(struct inode *parent, char *buf, int elen) out:kfree (cryptbuf);if (dir != parent) { -if ((dir->i_state &I_NEW )) +if ((inode_state_read_once (dir) &I_NEW ))discard_new_inode (dir);else iput (dir);
@@ -438,7 +438,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,fscrypt_fname_free_buffer (&_tname); out_inode:if (dir != fname->dir) { -if ((dir->i_state &I_NEW )) +if ((inode_state_read_once (dir) &I_NEW ))discard_new_inode (dir);else iput (dir);
fs/ceph/file.c +2 -2
@@ -744,7 +744,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, vino.ino, ceph_ino(dir), dentry->d_name.name);ceph_dir_clear_ordered (dir);ceph_init_inode_acls (inode, as_ctx); -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {/* * If it's not I_NEW, then someone created this before * we got here. Assume the server is aware of it at
@@ -907,7 +907,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, new_inode =NULL ; goto out_req; } -WARN_ON_ONCE (!(new_inode->i_state &I_NEW )); +WARN_ON_ONCE (!(inode_state_read_once (new_inode) &I_NEW ));spin_lock (&dentry->d_lock); di->flags |=CEPH_DENTRY_ASYNC_CREATE ;
fs/ceph/inode.c +14 -14
@@ -86,7 +86,7 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry, goto out_err; } - inode->i_state =0 ; +inode_state_set_raw (inode,0 ); inode->i_mode = *mode; err =ceph_security_init_secctx (dentry, *mode, as_ctx);
@@ -155,7 +155,7 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino,doutc (cl,"on %llx=%llx.%llx got %p new %d\n" ,ceph_present_inode (inode),ceph_vinop (inode), inode, - !!(inode->i_state &I_NEW )); + !!(inode_state_read_once (inode) &I_NEW ));return inode; }
@@ -182,7 +182,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) goto err; } -if (!(inode->i_state &I_NEW ) && !S_ISDIR (inode->i_mode)) { +if (!(inode_state_read_once (inode) &I_NEW ) && !S_ISDIR (inode->i_mode)) {pr_warn_once_client (cl,"bad snapdir inode type (mode=0%o)\n" , inode->i_mode); goto err;
@@ -215,7 +215,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) } }#endif -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_op = &ceph_snapdir_iops; inode->i_fop = &ceph_snapdir_fops; ci->i_snap_caps =CEPH_CAP_PIN ;/* so we can open */
@@ -224,7 +224,7 @@ struct inode *ceph_get_snapdir(struct inode *parent)return inode; err: -if ((inode->i_state &I_NEW )) +if ((inode_state_read_once (inode) &I_NEW ))discard_new_inode (inode);else iput (inode);
@@ -698,7 +698,7 @@ void ceph_evict_inode(struct inode *inode)netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data); -if (inode->i_state &I_PINNING_NETFS_WB ) +if (inode_state_read_once (inode) &I_PINNING_NETFS_WB )ceph_fscache_unuse_cookie (inode, true);clear_inode (inode);
@@ -967,7 +967,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, le64_to_cpu(info->version), ci->i_version);/* Once I_NEW is cleared, we can't change type or dev numbers */ -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_mode = mode; }else {if (inode_wrong_type (inode, mode)) {
@@ -1044,7 +1044,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,#ifdef CONFIG_FS_ENCRYPTION if (iinfo->fscrypt_auth_len && - ((inode->i_state &I_NEW ) || (ci->fscrypt_auth_len ==0 ))) { + ((inode_state_read_once (inode) &I_NEW ) || (ci->fscrypt_auth_len ==0 ))) {kfree (ci->fscrypt_auth); ci->fscrypt_auth_len = iinfo->fscrypt_auth_len; ci->fscrypt_auth = iinfo->fscrypt_auth;
@@ -1638,13 +1638,13 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)pr_err_client (cl,"badness %p %llx.%llx\n" , in,ceph_vinop (in)); req->r_target_inode =NULL ; -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )discard_new_inode (in);else iput (in); goto done; } -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )unlock_new_inode (in); }
@@ -1830,11 +1830,11 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,pr_err_client (cl,"inode badness on %p got %d\n" , in, rc); err = rc; -if (in->i_state &I_NEW ) { +if (inode_state_read_once (in) &I_NEW ) {ihold (in);discard_new_inode (in); } - }else if (in->i_state &I_NEW ) { + }else if (inode_state_read_once (in) &I_NEW ) {unlock_new_inode (in); }
@@ -2046,7 +2046,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,pr_err_client (cl,"badness on %p %llx.%llx\n" , in,ceph_vinop (in));if (d_really_is_negative (dn)) { -if (in->i_state &I_NEW ) { +if (inode_state_read_once (in) &I_NEW ) {ihold (in);discard_new_inode (in); }
@@ -2056,7 +2056,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, err = ret; goto next_item; } -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )unlock_new_inode (in);if (d_really_is_negative (dn)) {
Signature · 1 line
2.43.0
PATCH v4 11/12 overlayfs: use the new ->i_state accessors
In reply to Mateusz GuzikChange generated with coccinelle and fixed up by hand as appropriate.
--- fs/overlayfs/dir.c | 2 +- fs/overlayfs/inode.c | 6 +++--- fs/overlayfs/util.c | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-)
fs/overlayfs/dir.c +1 -1
@@ -659,7 +659,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev, goto out_drop_write;spin_lock (&inode->i_lock); - inode->i_state |=I_CREATING ; +inode_state_add (inode,I_CREATING );spin_unlock (&inode->i_lock);inode_init_owner (&nop_mnt_idmap, inode, dentry->d_parent->d_inode, mode);
fs/overlayfs/inode.c +3 -3
@@ -1149,7 +1149,7 @@ struct inode *ovl_get_trap_inode(struct super_block *sb, struct dentry *dir)if (!trap)return ERR_PTR (-ENOMEM ); -if (!(trap->i_state &I_NEW )) { +if (!(inode_state_read_once (trap) &I_NEW )) {/* Conflicting layer roots? */ iput (trap);return ERR_PTR (-ELOOP );
@@ -1240,7 +1240,7 @@ struct inode *ovl_get_inode(struct super_block *sb, inode =ovl_iget5 (sb, oip->newinode, key);if (!inode) goto out_err; -if (!(inode->i_state &I_NEW )) { +if (!(inode_state_read_once (inode) &I_NEW )) {/* * Verify that the underlying files stored in the inode * match those in the dentry.
@@ -1299,7 +1299,7 @@ struct inode *ovl_get_inode(struct super_block *sb,if (upperdentry)ovl_check_protattr (inode, upperdentry); -if (inode->i_state &I_NEW ) +if (inode_state_read_once (inode) &I_NEW )unlock_new_inode (inode); out:return inode;
fs/overlayfs/util.c +5 -5
@@ -1019,8 +1019,8 @@ bool ovl_inuse_trylock(struct dentry *dentry)bool locked = false;spin_lock (&inode->i_lock); -if (!(inode->i_state &I_OVL_INUSE )) { - inode->i_state |=I_OVL_INUSE ; +if (!(inode_state_read (inode) &I_OVL_INUSE )) { +inode_state_add (inode,I_OVL_INUSE ); locked = true; }spin_unlock (&inode->i_lock);
@@ -1034,8 +1034,8 @@ void ovl_inuse_unlock(struct dentry *dentry)struct inode *inode =d_inode (dentry);spin_lock (&inode->i_lock); -WARN_ON (!(inode->i_state &I_OVL_INUSE )); - inode->i_state &= ~I_OVL_INUSE ; +WARN_ON (!(inode_state_read (inode) &I_OVL_INUSE )); +inode_state_del (inode,I_OVL_INUSE );spin_unlock (&inode->i_lock); } }
@@ -1046,7 +1046,7 @@ bool ovl_is_inuse(struct dentry *dentry)bool inuse;spin_lock (&inode->i_lock); - inuse = (inode->i_state &I_OVL_INUSE ); + inuse = (inode_state_read (inode) &I_OVL_INUSE );spin_unlock (&inode->i_lock);return inuse;
Signature · 1 line
2.43.0
PATCH v4 12/12 fs: make plain ->i_state access fail to compile
In reply to Mateusz Guzik... to make sure all accesses are properly validated.
Merely renaming the var to __i_state still lets the compiler make the following suggestion:
error: 'struct inode' has no member named 'i_state'; did you mean '__i_state'?
Unfortunately some people will add the __'s and call it a day.
In order to make it harder to mess up in this way, hide it behind a struct. The resulting error message should be convincing in terms of checking what to do:
error: invalid operands to binary & (have 'struct inode_state_flags' and 'int')
Of course people determined to do a plain access can still do it, but nothing can be done for that case.
--- include/linux/fs.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
include/linux/fs.h +13 -6
@@ -782,6 +782,13 @@ enum inode_state_flags_enum {#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)#define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME) +/* +* Use inode_state_read() & friends to access. +*/ +struct inode_state_flags { +enum inode_state_flags_enum __state; +}; +/* * Keep mostly read-only and often accessed (especially for * the RCU path lookup and 'stat' data) fields at the beginning
@@ -840,7 +847,7 @@ struct inode {#endif /* Misc */ -enum inode_state_flags_enum i_state; +struct inode_state_flags i_state;/* 32-bit hole */ struct rw_semaphore i_rwsem;
@@ -906,19 +913,19 @@ struct inode {*/ static inline enum inode_state_flags_enum inode_state_read_once (struct inode *inode) { -return READ_ONCE (inode->i_state); +return READ_ONCE (inode->i_state.__state); }static inline enum inode_state_flags_enum inode_state_read (struct inode *inode) {lockdep_assert_held (&inode->i_lock); -return inode->i_state; +return inode->i_state.__state; }static inline void inode_state_add_raw (struct inode *inode,enum inode_state_flags_enum addflags) { -WRITE_ONCE (inode->i_state, inode->i_state | addflags); +WRITE_ONCE (inode->i_state.__state, inode->i_state.__state | addflags); } static inline void inode_state_add(struct inode *inode,
@@ -931,7 +938,7 @@ static inline void inode_state_add(struct inode *inode,static inline void inode_state_del_raw (struct inode *inode,enum inode_state_flags_enum delflags) { -WRITE_ONCE (inode->i_state, inode->i_state & ~delflags); +WRITE_ONCE (inode->i_state.__state, inode->i_state.__state & ~delflags); } static inline void inode_state_del(struct inode *inode,
@@ -944,7 +951,7 @@ static inline void inode_state_del(struct inode *inode,static inline void inode_state_set_raw (struct inode *inode,enum inode_state_flags_enum setflags) { -WRITE_ONCE (inode->i_state, setflags); +WRITE_ONCE (inode->i_state.__state, setflags); } static inline void inode_state_set(struct inode *inode,
Signature · 1 line
2.43.0
Re: [PATCH v4 10/12] ceph: use the new ->i_state accessors
In reply to Mateusz GuzikQuoted 10 lines · Mateusz Guzik
Change generated with coccinelle and fixed up by hand as appropriate.
Signed-off-by Mateusz Guzik <[email protected]>--- fs/ceph/cache.c | 2 +- fs/ceph/crypto.c | 4 ++-- fs/ceph/file.c | 4 ++-- fs/ceph/inode.c | 28 ++++++++++++++-------------- 4 files changed, 19 insertions(+), 19 deletions(-)
Looks good. I simply started to guess. Do we need a method something like this?
bool inode_is_new(struct inode *inode)
{
return inode_state_read_once(inode) & I_NEW;
}Thanks,
Slava.
Quoted 181 lines
fs/ceph/cache.c +1
-1@@ -26,7 +26,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)return ;/* Only new inodes! */ -if (!(inode->i_state &I_NEW )) +if (!(inode_state_read_once (inode) &I_NEW ))return ;WARN_ON_ONCE (ci->netfs.cache);fs/ceph/crypto.c +2
-2@@ -329,7 +329,7 @@ int ceph_encode_encrypted_dname(struct inode *parent, char *buf, int elen) out:kfree (cryptbuf);if (dir != parent) { -if ((dir->i_state &I_NEW )) +if ((inode_state_read_once (dir) &I_NEW ))discard_new_inode (dir);else iput (dir);@@ -438,7 +438,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,fscrypt_fname_free_buffer (&_tname); out_inode:if (dir != fname->dir) { -if ((dir->i_state &I_NEW )) +if ((inode_state_read_once (dir) &I_NEW ))discard_new_inode (dir);else iput (dir);fs/ceph/file.c +2
-2@@ -744,7 +744,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, vino.ino, ceph_ino(dir), dentry->d_name.name);ceph_dir_clear_ordered (dir);ceph_init_inode_acls (inode, as_ctx); -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {/* * If it's not I_NEW, then someone created this before * we got here. Assume the server is aware of it at @@ -907,7 +907,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, new_inode =NULL ; goto out_req; } -WARN_ON_ONCE (!(new_inode->i_state &I_NEW )); +WARN_ON_ONCE (!(inode_state_read_once (new_inode) &I_NEW ));spin_lock (&dentry->d_lock); di->flags |=CEPH_DENTRY_ASYNC_CREATE ;fs/ceph/inode.c +14
-14@@ -86,7 +86,7 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry, goto out_err; } - inode->i_state =0 ; +inode_state_set_raw (inode,0 ); inode->i_mode = *mode; err =ceph_security_init_secctx (dentry, *mode, as_ctx);@@ -155,7 +155,7 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino,doutc (cl,"on %llx=%llx.%llx got %p new %d\n" ,ceph_present_inode (inode),ceph_vinop (inode), inode, - !!(inode->i_state &I_NEW )); + !!(inode_state_read_once (inode) &I_NEW ));return inode; }@@ -182,7 +182,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) goto err; } -if (!(inode->i_state &I_NEW ) && !S_ISDIR (inode->i_mode)) { +if (!(inode_state_read_once (inode) &I_NEW ) && !S_ISDIR (inode->i_mode)) {pr_warn_once_client (cl,"bad snapdir inode type (mode=0%o)\n" , inode->i_mode); goto err;@@ -215,7 +215,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) } }#endif -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_op = &ceph_snapdir_iops; inode->i_fop = &ceph_snapdir_fops; ci->i_snap_caps =CEPH_CAP_PIN ;/* so we can open */ @@ -224,7 +224,7 @@ struct inode *ceph_get_snapdir(struct inode *parent)return inode; err: -if ((inode->i_state &I_NEW )) +if ((inode_state_read_once (inode) &I_NEW ))discard_new_inode (inode);else iput (inode);@@ -698,7 +698,7 @@ void ceph_evict_inode(struct inode *inode)netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data); -if (inode->i_state &I_PINNING_NETFS_WB ) +if (inode_state_read_once (inode) &I_PINNING_NETFS_WB )ceph_fscache_unuse_cookie (inode, true);clear_inode (inode);@@ -967,7 +967,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, le64_to_cpu(info->version), ci->i_version);/* Once I_NEW is cleared, we can't change type or dev numbers */ -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_mode = mode; }else {if (inode_wrong_type (inode, mode)) {@@ -1044,7 +1044,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,#ifdef CONFIG_FS_ENCRYPTION if (iinfo->fscrypt_auth_len && - ((inode->i_state &I_NEW ) || (ci->fscrypt_auth_len ==0 ))) { + ((inode_state_read_once (inode) &I_NEW ) || (ci->fscrypt_auth_len ==0 ))) {kfree (ci->fscrypt_auth); ci->fscrypt_auth_len = iinfo->fscrypt_auth_len; ci->fscrypt_auth = iinfo->fscrypt_auth;@@ -1638,13 +1638,13 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)pr_err_client (cl,"badness %p %llx.%llx\n" , in,ceph_vinop (in)); req->r_target_inode =NULL ; -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )discard_new_inode (in);else iput (in); goto done; } -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )unlock_new_inode (in); }@@ -1830,11 +1830,11 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,pr_err_client (cl,"inode badness on %p got %d\n" , in, rc); err = rc; -if (in->i_state &I_NEW ) { +if (inode_state_read_once (in) &I_NEW ) {ihold (in);discard_new_inode (in); } - }else if (in->i_state &I_NEW ) { + }else if (inode_state_read_once (in) &I_NEW ) {unlock_new_inode (in); }@@ -2046,7 +2046,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,pr_err_client (cl,"badness on %p %llx.%llx\n" , in,ceph_vinop (in));if (d_really_is_negative (dn)) { -if (in->i_state &I_NEW ) { +if (inode_state_read_once (in) &I_NEW ) {ihold (in);discard_new_inode (in); }@@ -2056,7 +2056,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, err = ret; goto next_item; } -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )unlock_new_inode (in);if (d_really_is_negative (dn)) {
Re: [PATCH v4 10/12] ceph: use the new ->i_state accessors
Quoted 13 lines · Viacheslav Dubeyko
Quoted 10 lines · Mateusz Guzik
Change generated with coccinelle and fixed up by hand as appropriate.
Signed-off-by Mateusz Guzik <[email protected]>--- fs/ceph/cache.c | 2 +- fs/ceph/crypto.c | 4 ++-- fs/ceph/file.c | 4 ++-- fs/ceph/inode.c | 28 ++++++++++++++-------------- 4 files changed, 19 insertions(+), 19 deletions(-)
Quoted 7 lines
Looks good. I simply started to guess. Do we need a method something like this?
bool
inode_is_new(struct inode *inode){ return inode_state_read_once(inode) & I_NEW; }
Helpers of the sort might show up later after the flag situation gets sorted out, for now it's baby steps.
Quoted 186 lines
Reviewed-by Viacheslav Dubeyko <[email protected]>Thanks,
Slava.Quoted 181 lines
fs/ceph/cache.c +1
-1@@ -26,7 +26,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)return ;/* Only new inodes! */ -if (!(inode->i_state &I_NEW )) +if (!(inode_state_read_once (inode) &I_NEW ))return ;WARN_ON_ONCE (ci->netfs.cache);fs/ceph/crypto.c +2
-2@@ -329,7 +329,7 @@ int ceph_encode_encrypted_dname(struct inode *parent, char *buf, int elen) out:kfree (cryptbuf);if (dir != parent) { -if ((dir->i_state &I_NEW )) +if ((inode_state_read_once (dir) &I_NEW ))discard_new_inode (dir);else iput (dir);@@ -438,7 +438,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,fscrypt_fname_free_buffer (&_tname); out_inode:if (dir != fname->dir) { -if ((dir->i_state &I_NEW )) +if ((inode_state_read_once (dir) &I_NEW ))discard_new_inode (dir);else iput (dir);fs/ceph/file.c +2
-2@@ -744,7 +744,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, vino.ino, ceph_ino(dir), dentry->d_name.name);ceph_dir_clear_ordered (dir);ceph_init_inode_acls (inode, as_ctx); -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) {/* * If it's not I_NEW, then someone created this before * we got here. Assume the server is aware of it at @@ -907,7 +907,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, new_inode =NULL ; goto out_req; } -WARN_ON_ONCE (!(new_inode->i_state &I_NEW )); +WARN_ON_ONCE (!(inode_state_read_once (new_inode) &I_NEW ));spin_lock (&dentry->d_lock); di->flags |=CEPH_DENTRY_ASYNC_CREATE ;fs/ceph/inode.c +14
-14@@ -86,7 +86,7 @@ struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry, goto out_err; } - inode->i_state =0 ; +inode_state_set_raw (inode,0 ); inode->i_mode = *mode; err =ceph_security_init_secctx (dentry, *mode, as_ctx);@@ -155,7 +155,7 @@ struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino,doutc (cl,"on %llx=%llx.%llx got %p new %d\n" ,ceph_present_inode (inode),ceph_vinop (inode), inode, - !!(inode->i_state &I_NEW )); + !!(inode_state_read_once (inode) &I_NEW ));return inode; }@@ -182,7 +182,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) goto err; } -if (!(inode->i_state &I_NEW ) && !S_ISDIR (inode->i_mode)) { +if (!(inode_state_read_once (inode) &I_NEW ) && !S_ISDIR (inode->i_mode)) {pr_warn_once_client (cl,"bad snapdir inode type (mode=0%o)\n" , inode->i_mode); goto err;@@ -215,7 +215,7 @@ struct inode *ceph_get_snapdir(struct inode *parent) } }#endif -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_op = &ceph_snapdir_iops; inode->i_fop = &ceph_snapdir_fops; ci->i_snap_caps =CEPH_CAP_PIN ;/* so we can open */ @@ -224,7 +224,7 @@ struct inode *ceph_get_snapdir(struct inode *parent)return inode; err: -if ((inode->i_state &I_NEW )) +if ((inode_state_read_once (inode) &I_NEW ))discard_new_inode (inode);else iput (inode);@@ -698,7 +698,7 @@ void ceph_evict_inode(struct inode *inode)netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data); -if (inode->i_state &I_PINNING_NETFS_WB ) +if (inode_state_read_once (inode) &I_PINNING_NETFS_WB )ceph_fscache_unuse_cookie (inode, true);clear_inode (inode);@@ -967,7 +967,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, le64_to_cpu(info->version), ci->i_version);/* Once I_NEW is cleared, we can't change type or dev numbers */ -if (inode->i_state &I_NEW ) { +if (inode_state_read_once (inode) &I_NEW ) { inode->i_mode = mode; }else {if (inode_wrong_type (inode, mode)) {@@ -1044,7 +1044,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,#ifdef CONFIG_FS_ENCRYPTION if (iinfo->fscrypt_auth_len && - ((inode->i_state &I_NEW ) || (ci->fscrypt_auth_len ==0 ))) { + ((inode_state_read_once (inode) &I_NEW ) || (ci->fscrypt_auth_len ==0 ))) {kfree (ci->fscrypt_auth); ci->fscrypt_auth_len = iinfo->fscrypt_auth_len; ci->fscrypt_auth = iinfo->fscrypt_auth;@@ -1638,13 +1638,13 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)pr_err_client (cl,"badness %p %llx.%llx\n" , in,ceph_vinop (in)); req->r_target_inode =NULL ; -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )discard_new_inode (in);else iput (in); goto done; } -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )unlock_new_inode (in); }@@ -1830,11 +1830,11 @@ static int readdir_prepopulate_inodes_only(struct ceph_mds_request *req,pr_err_client (cl,"inode badness on %p got %d\n" , in, rc); err = rc; -if (in->i_state &I_NEW ) { +if (inode_state_read_once (in) &I_NEW ) {ihold (in);discard_new_inode (in); } - }else if (in->i_state &I_NEW ) { + }else if (inode_state_read_once (in) &I_NEW ) {unlock_new_inode (in); }@@ -2046,7 +2046,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,pr_err_client (cl,"badness on %p %llx.%llx\n" , in,ceph_vinop (in));if (d_really_is_negative (dn)) { -if (in->i_state &I_NEW ) { +if (inode_state_read_once (in) &I_NEW ) {ihold (in);discard_new_inode (in); }@@ -2056,7 +2056,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, err = ret; goto next_item; } -if (in->i_state &I_NEW ) +if (inode_state_read_once (in) &I_NEW )unlock_new_inode (in);if (d_really_is_negative (dn)) {
Christian Brauner
maintainerQuoted 2 lines · Mateusz Guzik
This is generated against:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?h=vfs-6.18.inode.refcount.preliminaries
Given how late in the cycle it is I'm going to push this into the v6.19 merge window. You don't need to resend. We might get by with applying and rebasing given that it's fairly mechanincal overall. Objections Mateusz?
Quoted 9 lines · Christian Brauner
Quoted 2 lines · Mateusz Guzik
This is generated against:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?h=vfs-6.18.inode.refcount.preliminariesGiven how late in the cycle it is I'm going to push this into the v6.19 merge window. You don't need to resend. We might get by with applying and rebasing given that it's fairly mechanincal overall. Objections Mateusz?
First a nit: if the prelim branch is going in, you may want to adjust the dump_inode commit to use icount_read instead of atomic_read(&inode->i_count));
Getting this in *now* is indeed not worth it, so I support the idea.
Quoted 12 lines · Mateusz Guzik
Quoted 9 lines · Christian Brauner
Quoted 2 lines · Mateusz Guzik
This is generated against:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?h=vfs-6.18.inode.refcount.preliminariesGiven how late in the cycle it is I'm going to push this into the v6.19 merge window. You don't need to resend. We might get by with applying and rebasing given that it's fairly mechanincal overall. Objections Mateusz?
Quoted 5 lines
First a nit: if the prelim branch is going in, you may want to adjust the
dump_inodecommit to useicount_readinstead ofatomic_read(&inode->i_count));Getting this in *now* is indeed not worth it, so I support the idea.
Now that I wrote this I gave it a little bit of thought.
Note almost all of the churn was generated by coccinelle. Few spots got adjusted by hand.
Regressions are possible in 3 ways:
- wrong routine usage (_raw/_once vs plain) leading to lockdep splats
- incorrect manual adjustment between _raw/_once and plain variants, again leading to lockdep splats
- incorrect manually added usage (e.g., some of the _set stuff and the xfs changes were done that way)
The first two become instant non-problems if lockdep gets elided for the merge right now.
The last one may be a real concern, to which I have a
counter-proposal: extended coccinelle to also cover that, leading to *no* manual intervention.
Something like that should be perfectly safe to merge, hopefully avoiding some churn headache in the next cycle. Worst case the _raw/_once usage would be "wrong" and only come out after lockdep is restored.
Another option is to make the patchset into a nop by only providing the helpers without _raw/_once variants, again fully generated with coccinelle. Again should make it easier to shuffle changes in the next cycle.
I can prep this today if it sounds like a plan, but I'm not going to strongly argue one way or the other.
Quoted 44 lines · Mateusz Guzik
Quoted 12 lines · Mateusz Guzik
Quoted 9 lines · Christian Brauner
Quoted 2 lines · Mateusz Guzik
This is generated against:
https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?h=vfs-6.18.inode.refcount.preliminariesGiven how late in the cycle it is I'm going to push this into the v6.19 merge window. You don't need to resend. We might get by with applying and rebasing given that it's fairly mechanincal overall. Objections Mateusz?
Quoted 5 lines
First a nit: if the prelim branch is going in, you may want to adjust the
dump_inodecommit to useicount_readinstead ofatomic_read(&inode->i_count));Getting this in *now* is indeed not worth it, so I support the idea.
Now that I wrote this I gave it a little bit of thought.
Note almost all of the churn was generated by coccinelle. Few spots got adjusted by hand.
Regressions are possible in 3 ways:
- wrong routine usage (_raw/_once vs plain) leading to lockdep splats
- incorrect manual adjustment between _raw/_once and plain variants, again leading to lockdep splats
- incorrect manually added usage (e.g., some of the_setstuff and the xfs changes were done that way)The first two become instant non-problems if lockdep gets elided for the merge right now.
The last one may be a real concern, to which I have a
counter-proposal: extended coccinelle to also cover that, leading to *no* manual intervention.Something like that should be perfectly safe to merge, hopefully avoiding some churn headache in the next cycle. Worst case the _raw/_once usage would be "wrong" and only come out after lockdep is restored.
Quoted 7 lines
Another option is to make the patchset into a nop by only providing the helpers without _raw/_once variants, again fully generated with coccinelle. Again should make it easier to shuffle changes in the next cycle.
I can prep this today if it sounds like a plan, but I'm not going to strongly argue one way or the other.
So I posted v5 with the no _raw/_once variants approach.
It is more manual conversion than I thought, but it is all pretty straightforward and contained to a dedicated diff.
If you still want to postpone this work that's fine with me.