Skip to content

Commit 9368f0f

Browse files
committed
Merge tag 'vfs-6.19-rc1.inode' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs inode updates from Christian Brauner: "Features: - Hide inode->i_state behind accessors. Open-coded accesses prevent asserting they are done correctly. One obvious aspect is locking, but significantly more can be 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) - Provide accessors for ->i_state, converts all filesystems using coccinelle and manual conversions (btrfs, ceph, smb, f2fs, gfs2, overlayfs, nilfs2, xfs), and makes plain ->i_state access fail to compile - Rework I_NEW handling to operate without fences, simplifying the code after the accessor infrastructure is in place Cleanups: - Move wait_on_inode() from writeback.h to fs.h - Spell out fenced ->i_state accesses with explicit smp_wmb/smp_rmb for clarity - Cosmetic fixes to LRU handling - Push list presence check into inode_io_list_del() - Touch up predicts in __d_lookup_rcu() - ocfs2: retire ocfs2_drop_inode() and I_WILL_FREE usage - Assert on ->i_count in iput_final() - Assert ->i_lock held in __iget() Fixes: - Add missing fences to I_NEW handling" * tag 'vfs-6.19-rc1.inode' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (22 commits) dcache: touch up predicts in __d_lookup_rcu() fs: push list presence check into inode_io_list_del() fs: cosmetic fixes to lru handling fs: rework I_NEW handling to operate without fences fs: make plain ->i_state access fail to compile xfs: use the new ->i_state accessors nilfs2: use the new ->i_state accessors overlayfs: use the new ->i_state accessors gfs2: use the new ->i_state accessors f2fs: use the new ->i_state accessors smb: use the new ->i_state accessors ceph: use the new ->i_state accessors btrfs: use the new ->i_state accessors Manual conversion to use ->i_state accessors of all places not covered by coccinelle Coccinelle-based conversion to use ->i_state accessors fs: provide accessors for ->i_state fs: spell out fenced ->i_state accesses with explicit smp_wmb/smp_rmb fs: move wait_on_inode() from writeback.h to fs.h fs: add missing fences to I_NEW handling ocfs2: retire ocfs2_drop_inode() and I_WILL_FREE usage ...
2 parents b04b2e7 + ca0d620 commit 9368f0f

115 files changed

Lines changed: 514 additions & 414 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/filesystems/porting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ test and set for you.
211211
e.g.::
212212

213213
inode = iget_locked(sb, ino);
214-
if (inode->i_state & I_NEW) {
214+
if (inode_state_read_once(inode) & I_NEW) {
215215
err = read_inode_from_disk(inode);
216216
if (err < 0) {
217217
iget_failed(inode);

block/bdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void bdev_write_inode(struct block_device *bdev)
6767
int ret;
6868

6969
spin_lock(&inode->i_lock);
70-
while (inode->i_state & I_DIRTY) {
70+
while (inode_state_read(inode) & I_DIRTY) {
7171
spin_unlock(&inode->i_lock);
7272
ret = write_inode_now(inode, true);
7373
if (ret)
@@ -1282,7 +1282,7 @@ void sync_bdevs(bool wait)
12821282
struct block_device *bdev;
12831283

12841284
spin_lock(&inode->i_lock);
1285-
if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW) ||
1285+
if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE | I_NEW) ||
12861286
mapping->nrpages == 0) {
12871287
spin_unlock(&inode->i_lock);
12881288
continue;

drivers/dax/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static struct dax_device *dax_dev_get(dev_t devt)
433433
return NULL;
434434

435435
dax_dev = to_dax_dev(inode);
436-
if (inode->i_state & I_NEW) {
436+
if (inode_state_read_once(inode) & I_NEW) {
437437
set_bit(DAXDEV_ALIVE, &dax_dev->flags);
438438
inode->i_cdev = &dax_dev->cdev;
439439
inode->i_mode = S_IFCHR;

fs/9p/vfs_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
422422
inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st);
423423
if (!inode)
424424
return ERR_PTR(-ENOMEM);
425-
if (!(inode->i_state & I_NEW))
425+
if (!(inode_state_read_once(inode) & I_NEW))
426426
return inode;
427427
/*
428428
* initialize the inode with the stat info

fs/9p/vfs_inode_dotl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
112112
inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode_dotl, st);
113113
if (!inode)
114114
return ERR_PTR(-ENOMEM);
115-
if (!(inode->i_state & I_NEW))
115+
if (!(inode_state_read_once(inode) & I_NEW))
116116
return inode;
117117
/*
118118
* initialize the inode with the stat info

fs/affs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
2929
inode = iget_locked(sb, ino);
3030
if (!inode)
3131
return ERR_PTR(-ENOMEM);
32-
if (!(inode->i_state & I_NEW))
32+
if (!(inode_state_read_once(inode) & I_NEW))
3333
return inode;
3434

3535
pr_debug("affs_iget(%lu)\n", inode->i_ino);

fs/afs/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry)
779779
struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode;
780780
struct inode *inode = NULL, *ti;
781781
afs_dataversion_t data_version = READ_ONCE(dvnode->status.data_version);
782-
bool supports_ibulk;
782+
bool supports_ibulk, isnew;
783783
long ret;
784784
int i;
785785

@@ -850,7 +850,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry)
850850
* callback counters.
851851
*/
852852
ti = ilookup5_nowait(dir->i_sb, vp->fid.vnode,
853-
afs_ilookup5_test_by_fid, &vp->fid);
853+
afs_ilookup5_test_by_fid, &vp->fid, &isnew);
854854
if (!IS_ERR_OR_NULL(ti)) {
855855
vnode = AFS_FS_I(ti);
856856
vp->dv_before = vnode->status.data_version;

fs/afs/dynroot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static struct inode *afs_iget_pseudo_dir(struct super_block *sb, ino_t ino)
6464

6565
vnode = AFS_FS_I(inode);
6666

67-
if (inode->i_state & I_NEW) {
67+
if (inode_state_read_once(inode) & I_NEW) {
6868
netfs_inode_init(&vnode->netfs, NULL, false);
6969
simple_inode_init_ts(inode);
7070
set_nlink(inode, 2);
@@ -259,7 +259,7 @@ static struct dentry *afs_lookup_atcell(struct inode *dir, struct dentry *dentry
259259

260260
vnode = AFS_FS_I(inode);
261261

262-
if (inode->i_state & I_NEW) {
262+
if (inode_state_read_once(inode) & I_NEW) {
263263
netfs_inode_init(&vnode->netfs, NULL, false);
264264
simple_inode_init_ts(inode);
265265
set_nlink(inode, 1);
@@ -384,7 +384,7 @@ struct inode *afs_dynroot_iget_root(struct super_block *sb)
384384
vnode = AFS_FS_I(inode);
385385

386386
/* there shouldn't be an existing inode */
387-
if (inode->i_state & I_NEW) {
387+
if (inode_state_read_once(inode) & I_NEW) {
388388
netfs_inode_init(&vnode->netfs, NULL, false);
389389
simple_inode_init_ts(inode);
390390
set_nlink(inode, 2);

fs/afs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static void afs_fetch_status_success(struct afs_operation *op)
427427
struct afs_vnode *vnode = vp->vnode;
428428
int ret;
429429

430-
if (vnode->netfs.inode.i_state & I_NEW) {
430+
if (inode_state_read_once(&vnode->netfs.inode) & I_NEW) {
431431
ret = afs_inode_init_from_status(op, vp, vnode);
432432
afs_op_set_error(op, ret);
433433
if (ret == 0)
@@ -579,7 +579,7 @@ struct inode *afs_iget(struct afs_operation *op, struct afs_vnode_param *vp)
579579
inode, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
580580

581581
/* deal with an existing inode */
582-
if (!(inode->i_state & I_NEW)) {
582+
if (!(inode_state_read_once(inode) & I_NEW)) {
583583
_leave(" = %p", inode);
584584
return inode;
585585
}
@@ -639,7 +639,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)
639639

640640
_debug("GOT ROOT INODE %p { vl=%llx }", inode, as->volume->vid);
641641

642-
BUG_ON(!(inode->i_state & I_NEW));
642+
BUG_ON(!(inode_state_read_once(inode) & I_NEW));
643643

644644
vnode = AFS_FS_I(inode);
645645
vnode->cb_v_check = atomic_read(&as->volume->cb_v_break);
@@ -748,7 +748,7 @@ void afs_evict_inode(struct inode *inode)
748748

749749
if ((S_ISDIR(inode->i_mode) ||
750750
S_ISLNK(inode->i_mode)) &&
751-
(inode->i_state & I_DIRTY) &&
751+
(inode_state_read_once(inode) & I_DIRTY) &&
752752
!sbi->dyn_root) {
753753
struct writeback_control wbc = {
754754
.sync_mode = WB_SYNC_ALL,

fs/befs/linuxvfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
307307
inode = iget_locked(sb, ino);
308308
if (!inode)
309309
return ERR_PTR(-ENOMEM);
310-
if (!(inode->i_state & I_NEW))
310+
if (!(inode_state_read_once(inode) & I_NEW))
311311
return inode;
312312

313313
befs_ino = BEFS_I(inode);

0 commit comments

Comments
 (0)