Skip to content

Commit 0e42f38

Browse files
author
Kent Overstreet
committed
bcachefs: Fix inode early destruction path
discard_new_inode() is the wrong interface to use when we need to free an inode that was never inserted into the inode hash table; we can bypass the whole iput() -> evict() path and replace it with __destroy_inode(); kmem_cache_free() - this fixes a WARN_ON() about I_NEW. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 85ab365 commit 0e42f38

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

fs/bcachefs/fs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ 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-
discard_new_inode(&inode->v);
191+
__destroy_inode(&inode->v);
192+
kmem_cache_free(bch2_inode_cache, inode);
192193
inode = old;
193194
} else {
194195
mutex_lock(&c->vfs_inodes_lock);
@@ -225,8 +226,10 @@ static struct bch_inode_info *bch2_new_inode(struct btree_trans *trans)
225226

226227
if (unlikely(!inode)) {
227228
int ret = drop_locks_do(trans, (inode = to_bch_ei(new_inode(c->vfs_sb))) ? 0 : -ENOMEM);
228-
if (ret && inode)
229-
discard_new_inode(&inode->v);
229+
if (ret && inode) {
230+
__destroy_inode(&inode->v);
231+
kmem_cache_free(bch2_inode_cache, inode);
232+
}
230233
if (ret)
231234
return ERR_PTR(ret);
232235
}

0 commit comments

Comments
 (0)