Skip to content

Commit dd90864

Browse files
author
Kent Overstreet
committed
bcachefs: Fix I_NEW warning in race path in bch2_inode_insert()
discard_new_inode() is the correct interface for tearing down an indoe that was fully created but not made visible to other threads, but it expects I_NEW to be set, which we don't use. Reported-by: koverstreet/bcachefs#690 Fixes: bcachefs: Fix race path in bch2_inode_insert() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 5047940 commit dd90864

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/bcachefs/fs.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,23 @@ static struct bch_inode_info *bch2_inode_insert(struct bch_fs *c, struct bch_ino
188188
BUG_ON(!old);
189189

190190
if (unlikely(old != inode)) {
191+
/*
192+
* bcachefs doesn't use I_NEW; we have no use for it since we
193+
* only insert fully created inodes in the inode hash table. But
194+
* discard_new_inode() expects it to be set...
195+
*/
196+
inode->v.i_flags |= I_NEW;
191197
discard_new_inode(&inode->v);
192198
inode = old;
193199
} else {
194200
mutex_lock(&c->vfs_inodes_lock);
195201
list_add(&inode->ei_vfs_inode_list, &c->vfs_inodes_list);
196202
mutex_unlock(&c->vfs_inodes_lock);
197203
/*
198-
* we really don't want insert_inode_locked2() to be setting
199-
* I_NEW...
204+
* Again, I_NEW makes no sense for bcachefs. This is only needed
205+
* for clearing I_NEW, but since the inode was already fully
206+
* created and initialized we didn't actually want
207+
* inode_insert5() to set it for us.
200208
*/
201209
unlock_new_inode(&inode->v);
202210
}

0 commit comments

Comments
 (0)