Re: [PATCH 1/2] bcachefs: do not use PF_MEMALLOC_NORECLAIM

Matthew Wilcox
2024-08-26T13:12:00Z

On Mon, Aug 26, 2024 at 10:47:12AM +0200, Michal Hocko wrote:
> @@ -258,12 +258,10 @@ static struct bch_inode_info *__bch2_new_inode(struct bch_fs *c)
> */
> static struct bch_inode_info *bch2_new_inode(struct btree_trans *trans)
> {
> - struct bch_inode_info *inode =
> - memalloc_flags_do(PF_MEMALLOC_NORECLAIM|PF_MEMALLOC_NOWARN,
> - __bch2_new_inode(trans->c));
> + struct bch_inode_info *inode = __bch2_new_inode(trans->c, GFP_NOWARN | GFP_NOWAIT);

GFP_NOWAIT include GFP_NOWARN these days (since 16f5dfbc851b)

> +++ b/fs/inode.c
> @@ -153,7 +153,7 @@ static int no_open(struct inode *inode, struct file *file)
> * These are initializations that need to be done on every inode
> * allocation as the fields are not initialised by slab allocation.
> */
> -int inode_init_always(struct super_block *sb, struct inode *inode)
> +int inode_init_always(struct super_block *sb, struct inode *inode, gfp_t gfp)

Did you send the right version of this patch? There should be a "_gfp"
appended to this function name.

> +++ b/include/linux/fs.h
> @@ -3027,7 +3027,12 @@ extern loff_t default_llseek(struct file *file, loff_t offset, int whence);
>
> extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence);
>
> -extern int inode_init_always(struct super_block *, struct inode *);
> +extern int inode_init_always_gfp(struct super_block *, struct inode *, gfp_t);

You can drop the "extern" while you're changing this line.

> +static inline int inode_init_always(struct super_block *sb, struct inode *inode)
> +{
> + return inode_init_always_gfp(sb, inode, GFP_NOFS);
> +}