From 5222595d093ebe80329d38d255d14316257afb3e Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 13 Dec 2018 18:38:33 -0800 Subject: f2fs: use kvmalloc, if kmalloc is failed One report says memalloc failure during mount. (unwind_backtrace) from [] (show_stack+0x10/0x14) (show_stack) from [] (dump_stack+0x8c/0xa0) (dump_stack) from [] (warn_alloc+0xc4/0x160) (warn_alloc) from [] (__alloc_pages_nodemask+0x3f4/0x10d0) (__alloc_pages_nodemask) from [] (kmalloc_order_trace+0x2c/0x120) (kmalloc_order_trace) from [] (build_node_manager+0x35c/0x688) (build_node_manager) from [] (f2fs_fill_super+0xf0c/0x16cc) (f2fs_fill_super) from [] (mount_bdev+0x15c/0x188) (mount_bdev) from [] (f2fs_mount+0x18/0x20) (f2fs_mount) from [] (mount_fs+0x158/0x19c) (mount_fs) from [] (vfs_kern_mount+0x78/0x134) (vfs_kern_mount) from [] (do_mount+0x474/0xca4) (do_mount) from [] (SyS_mount+0x94/0xbc) (SyS_mount) from [] (ret_fast_syscall+0x0/0x48) Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/f2fs.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'fs/f2fs/f2fs.h') diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 03e7b37b1433..d30b4a095e5c 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1630,7 +1630,7 @@ static inline void disable_nat_bits(struct f2fs_sb_info *sbi, bool lock) if (lock) spin_lock_irqsave(&sbi->cp_lock, flags); __clear_ckpt_flags(F2FS_CKPT(sbi), CP_NAT_BITS_FLAG); - kfree(NM_I(sbi)->nat_bits); + kvfree(NM_I(sbi)->nat_bits); NM_I(sbi)->nat_bits = NULL; if (lock) spin_unlock_irqrestore(&sbi->cp_lock, flags); @@ -2704,12 +2704,18 @@ static inline bool f2fs_may_extent_tree(struct inode *inode) static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi, size_t size, gfp_t flags) { + void *ret; + if (time_to_inject(sbi, FAULT_KMALLOC)) { f2fs_show_injection_info(FAULT_KMALLOC); return NULL; } - return kmalloc(size, flags); + ret = kmalloc(size, flags); + if (ret) + return ret; + + return kvmalloc(size, flags); } static inline void *f2fs_kzalloc(struct f2fs_sb_info *sbi, -- cgit v1.2.3