[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240716025816.52156-1-youling.tang@linux.dev>
Date: Tue, 16 Jul 2024 10:58:16 +0800
From: Youling Tang <youling.tang@...ux.dev>
To: Kent Overstreet <kent.overstreet@...ux.dev>
Cc: Youling Tang <youling.tang@...ux.dev>,
Qi Zheng <zhengqi.arch@...edance.com>,
linux-kernel@...r.kernel.org,
linux-bcachefs@...r.kernel.org,
Youling Tang <tangyouling@...inos.cn>
Subject: [PATCH] bcachefs: allocate inode by using alloc_inode_sb()
From: Youling Tang <tangyouling@...inos.cn>
The inode allocation is supposed to use alloc_inode_sb(), so convert
kmem_cache_alloc() to alloc_inode_sb().
It will also fix [1] to avoid the NULL pointer dereference BUG in
list_lru_add() when CONFIG_MEMCG is enabled.
Links:
[1]: https://lore.kernel.org/all/20589721-46c0-4344-b2ef-6ab48bbe2ea5@linux.dev/
[2]: https://lore.kernel.org/all/7db60e36-9c96-4938-a28d-a9745e287386@linux.dev/
Fixes: 86d81ec5f5f0 ("bcachefs: Mark bch_inode_info as SLAB_ACCOUNT")
Signed-off-by: Youling Tang <tangyouling@...inos.cn>
---
fs/bcachefs/fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index f9c9a95d7d4c..34649ed2e3a1 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -227,7 +227,8 @@ static struct inode *bch2_alloc_inode(struct super_block *sb)
static struct bch_inode_info *__bch2_new_inode(struct bch_fs *c)
{
- struct bch_inode_info *inode = kmem_cache_alloc(bch2_inode_cache, GFP_NOFS);
+ struct bch_inode_info *inode = alloc_inode_sb(c->vfs_sb,
+ bch2_inode_cache, GFP_NOFS);
if (!inode)
return NULL;
--
2.34.1
Powered by blists - more mailing lists