[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMZfGtV3cOY0JwMp_wr+PcHyYZsL4-2v-9YjXnPgpvJXgMvrTw@mail.gmail.com>
Date: Wed, 12 May 2021 11:20:10 +0800
From: Muchun Song <songmuchun@...edance.com>
To: Dave Chinner <david@...morbit.com>
Cc: Matthew Wilcox <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Vladimir Davydov <vdavydov.dev@...il.com>,
Shakeel Butt <shakeelb@...gle.com>,
Roman Gushchin <guro@...com>, Yang Shi <shy828301@...il.com>,
alexs@...nel.org, Wei Yang <richard.weiyang@...il.com>,
trond.myklebust@...merspace.com, anna.schumaker@...app.com,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux Memory Management List <linux-mm@...ck.org>,
linux-nfs@...r.kernel.org, zhengqi.arch@...edance.com,
Xiongchun duan <duanxiongchun@...edance.com>,
fam.zheng@...edance.com
Subject: Re: [External] Re: [PATCH 10/17] fs: introduce alloc_inode_sb() to
allocate filesystems specific inode
On Wed, May 12, 2021 at 7:40 AM Dave Chinner <david@...morbit.com> wrote:
>
> On Tue, May 11, 2021 at 06:46:40PM +0800, Muchun Song wrote:
> > The allocated inode cache will be added into its memcg lru list later,
> > but we do not allocate list_lru in the later patch. So the caller should
> > call kmem_cache_alloc_lru() to allocate inode and related list_lru.
> > Introduce alloc_inode_sb() to do that and convert all inodes allocation
> > to it.
>
> FWIW, this probably needs a documentation update to mention that
> inodes should always be allocated through alloc_inode_sb() rather
> than kmem_cache_alloc(). It's a "** mandatory **" requirement as per
> Documentation/filesytems/porting.rst.
Make sense to me. I'll fix it in the next version.
>
> Also,
>
> > diff --git a/include/linux/fs.h b/include/linux/fs.h
> > index c3c88fdb9b2a..d8d5d4eb68d6 100644
> > --- a/include/linux/fs.h
> > +++ b/include/linux/fs.h
> > @@ -41,6 +41,7 @@
> > #include <linux/stddef.h>
> > #include <linux/mount.h>
> > #include <linux/cred.h>
> > +#include <linux/slab.h>
> >
> > #include <asm/byteorder.h>
> > #include <uapi/linux/fs.h>
> > @@ -3200,6 +3201,12 @@ extern void free_inode_nonrcu(struct inode *inode);
> > extern int should_remove_suid(struct dentry *);
> > extern int file_remove_privs(struct file *);
> >
> > +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);
> > +}
> > +
>
> This really needs a kerneldoc comment explaining that it must be
> used for allocating inodes to set up the inode reclaim context
> correctly....
Will do.
>
> /me wonders if we should add a BUG_ON() check in inode_init_always()
> to capture filesystems that don't call through
> kmem_cache_alloc_lru() for inodes?
Good point. IMHO, I think that the BUG_ON check may be useful.
Actually, it can catch such bugs.
Any suggestions from others?
Thanks.
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@...morbit.com
Powered by blists - more mailing lists