Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7b2656f authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: use kvmalloc, if kmalloc is failed



One report says memalloc failure during mount.

 (unwind_backtrace) from [<c010cd4c>] (show_stack+0x10/0x14)
 (show_stack) from [<c049c6b8>] (dump_stack+0x8c/0xa0)
 (dump_stack) from [<c024fcf0>] (warn_alloc+0xc4/0x160)
 (warn_alloc) from [<c0250218>] (__alloc_pages_nodemask+0x3f4/0x10d0)
 (__alloc_pages_nodemask) from [<c0270450>] (kmalloc_order_trace+0x2c/0x120)
 (kmalloc_order_trace) from [<c03fa748>] (build_node_manager+0x35c/0x688)
 (build_node_manager) from [<c03de494>] (f2fs_fill_super+0xf0c/0x16cc)
 (f2fs_fill_super) from [<c02a5864>] (mount_bdev+0x15c/0x188)
 (mount_bdev) from [<c03da624>] (f2fs_mount+0x18/0x20)
 (f2fs_mount) from [<c02a68b8>] (mount_fs+0x158/0x19c)
 (mount_fs) from [<c02c3c9c>] (vfs_kern_mount+0x78/0x134)
 (vfs_kern_mount) from [<c02c76ac>] (do_mount+0x474/0xca4)
 (do_mount) from [<c02c8264>] (SyS_mount+0x94/0xbc)
 (SyS_mount) from [<c0108180>] (ret_fast_syscall+0x0/0x48)

Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent bb46621e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ static void *f2fs_acl_to_disk(struct f2fs_sb_info *sbi,
	return (void *)f2fs_acl;

fail:
	kfree(f2fs_acl);
	kvfree(f2fs_acl);
	return ERR_PTR(-EINVAL);
}

@@ -190,7 +190,7 @@ static struct posix_acl *__f2fs_get_acl(struct inode *inode, int type,
		acl = NULL;
	else
		acl = ERR_PTR(retval);
	kfree(value);
	kvfree(value);

	return acl;
}
@@ -240,7 +240,7 @@ static int __f2fs_set_acl(struct inode *inode, int type,

	error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0);

	kfree(value);
	kvfree(value);
	if (!error)
		set_cached_acl(inode, type, acl);

+1 −1
Original line number Diff line number Diff line
@@ -911,7 +911,7 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)
	f2fs_put_page(cp1, 1);
	f2fs_put_page(cp2, 1);
fail_no_cp:
	kfree(sbi->ckpt);
	kvfree(sbi->ckpt);
	return -EINVAL;
}

+1 −1
Original line number Diff line number Diff line
@@ -2573,7 +2573,7 @@ static void f2fs_dio_end_io(struct bio *bio)
	bio->bi_private = dio->orig_private;
	bio->bi_end_io = dio->orig_end_io;

	kfree(dio);
	kvfree(dio);

	bio_endio(bio);
}
+1 −1
Original line number Diff line number Diff line
@@ -503,7 +503,7 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
	list_del(&si->stat_list);
	mutex_unlock(&f2fs_stat_mutex);

	kfree(si);
	kvfree(si);
}

int __init f2fs_create_root_stats(void)
+8 −2
Original line number Diff line number Diff line
@@ -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,
Loading