mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
fs: introduce alloc_inode_sb() to allocate filesystems specific inode
The allocated inode cache is supposed to be added to its memcg list_lru which should be allocated as well in advance. That can be done by kmem_cache_alloc_lru() which allocates object and list_lru. The file systems is main user of it. So introduce alloc_inode_sb() to allocate file system specific inodes and set up the inode reclaim context properly. The file system is supposed to use alloc_inode_sb() to allocate inodes. In later patches, we will convert all users to the new API. Link: https://lkml.kernel.org/r/20220228122126.37293-4-songmuchun@bytedance.com Signed-off-by: Muchun Song <songmuchun@bytedance.com> Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev> Cc: Alex Shi <alexs@kernel.org> Cc: Anna Schumaker <Anna.Schumaker@Netapp.com> Cc: Chao Yu <chao@kernel.org> Cc: Dave Chinner <david@fromorbit.com> Cc: Fam Zheng <fam.zheng@bytedance.com> Cc: Jaegeuk Kim <jaegeuk@kernel.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kari Argillander <kari.argillander@gmail.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Qi Zheng <zhengqi.arch@bytedance.com> Cc: Shakeel Butt <shakeelb@google.com> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Trond Myklebust <trond.myklebust@hammerspace.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Wei Yang <richard.weiyang@gmail.com> Cc: Xiongchun Duan <duanxiongchun@bytedance.com> Cc: Yang Shi <shy828301@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
88f2ef73fd
commit
8b9f3ac5b0
@ -45,6 +45,12 @@ typically between calling iget_locked() and unlocking the inode.
|
||||
|
||||
At some point that will become mandatory.
|
||||
|
||||
**mandatory**
|
||||
|
||||
The foo_inode_info should always be allocated through alloc_inode_sb() rather
|
||||
than kmem_cache_alloc() or kmalloc() related to set up the inode reclaim context
|
||||
correctly.
|
||||
|
||||
---
|
||||
|
||||
**mandatory**
|
||||
|
@ -259,7 +259,7 @@ static struct inode *alloc_inode(struct super_block *sb)
|
||||
if (ops->alloc_inode)
|
||||
inode = ops->alloc_inode(sb);
|
||||
else
|
||||
inode = kmem_cache_alloc(inode_cachep, GFP_KERNEL);
|
||||
inode = alloc_inode_sb(sb, inode_cachep, GFP_KERNEL);
|
||||
|
||||
if (!inode)
|
||||
return NULL;
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <linux/mount.h>
|
||||
#include <linux/cred.h>
|
||||
#include <linux/mnt_idmapping.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <uapi/linux/fs.h>
|
||||
@ -3114,6 +3115,16 @@ extern void free_inode_nonrcu(struct inode *inode);
|
||||
extern int should_remove_suid(struct dentry *);
|
||||
extern int file_remove_privs(struct file *);
|
||||
|
||||
/*
|
||||
* This must be used for allocating filesystems specific inodes to set
|
||||
* up the inode reclaim context correctly.
|
||||
*/
|
||||
static inline void *
|
||||
alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, gfp_t gfp)
|
||||
{
|
||||
return kmem_cache_alloc_lru(cache, &sb->s_inode_lru, gfp);
|
||||
}
|
||||
|
||||
extern void __insert_inode_hash(struct inode *, unsigned long hashval);
|
||||
static inline void insert_inode_hash(struct inode *inode)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user