lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 12 May 2021 09:40:41 +1000
From:   Dave Chinner <david@...morbit.com>
To:     Muchun Song <songmuchun@...edance.com>
Cc:     willy@...radead.org, akpm@...ux-foundation.org, hannes@...xchg.org,
        mhocko@...nel.org, vdavydov.dev@...il.com, shakeelb@...gle.com,
        guro@...com, shy828301@...il.com, alexs@...nel.org,
        richard.weiyang@...il.com, trond.myklebust@...merspace.com,
        anna.schumaker@...app.com, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        linux-nfs@...r.kernel.org, zhengqi.arch@...edance.com,
        duanxiongchun@...edance.com, fam.zheng@...edance.com
Subject: Re: [PATCH 10/17] fs: introduce alloc_inode_sb() to allocate
 filesystems specific inode

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.

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....

/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?

Cheers,

Dave.
-- 
Dave Chinner
david@...morbit.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ