Commit 32410577 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: support fault injection for f2fs_kmem_cache_alloc()



This patch supports to inject fault into f2fs_kmem_cache_alloc().

Usage:
a) echo 32768 > /sys/fs/f2fs/<dev>/inject_type or
b) mount -o fault_type=32768 <dev> <mountpoint>

Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 4a4fc043
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ fault_type=%d Support configuring fault injection type, should be
			 FAULT_CHECKPOINT	  0x000001000
			 FAULT_DISCARD		  0x000002000
			 FAULT_WRITE_IO		  0x000004000
			 FAULT_SLAB_ALLOC	  0x000008000
			 ===================	  ===========
mode=%s			 Control block allocation mode which supports "adaptive"
			 and "lfs". In "lfs" mode, there should be no random
+2 −1
Original line number Diff line number Diff line
@@ -475,7 +475,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,

retry:
	if (!e)
		new = f2fs_kmem_cache_alloc(ino_entry_slab, GFP_NOFS);
		new = f2fs_kmem_cache_alloc(ino_entry_slab,
						GFP_NOFS, true, NULL);

	radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);

+5 −3
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ static void *page_array_alloc(struct inode *inode, int nr)
	unsigned int size = sizeof(struct page *) * nr;

	if (likely(size <= sbi->page_array_slab_size))
		return kmem_cache_zalloc(sbi->page_array_slab, GFP_NOFS);
		return f2fs_kmem_cache_alloc(sbi->page_array_slab,
					GFP_F2FS_ZERO, false, F2FS_I_SB(inode));
	return f2fs_kzalloc(sbi, size, GFP_NOFS);
}

@@ -1228,7 +1229,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,

	fio.version = ni.version;

	cic = kmem_cache_zalloc(cic_entry_slab, GFP_NOFS);
	cic = f2fs_kmem_cache_alloc(cic_entry_slab, GFP_F2FS_ZERO, false, sbi);
	if (!cic)
		goto out_put_dnode;

@@ -1506,7 +1507,8 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
	pgoff_t start_idx = start_idx_of_cluster(cc);
	int i;

	dic = kmem_cache_zalloc(dic_entry_slab, GFP_NOFS);
	dic = f2fs_kmem_cache_alloc(dic_entry_slab, GFP_F2FS_ZERO,
					false, F2FS_I_SB(cc->inode));
	if (!dic)
		return ERR_PTR(-ENOMEM);

+1 −1
Original line number Diff line number Diff line
@@ -724,7 +724,7 @@ static void add_bio_entry(struct f2fs_sb_info *sbi, struct bio *bio,
	struct f2fs_bio_info *io = sbi->write_io[DATA] + temp;
	struct bio_entry *be;

	be = f2fs_kmem_cache_alloc(bio_entry_slab, GFP_NOFS);
	be = f2fs_kmem_cache_alloc(bio_entry_slab, GFP_NOFS, true, NULL);
	be->bio = bio;
	bio_get(bio);

+2 −2
Original line number Diff line number Diff line
@@ -83,8 +83,8 @@ int f2fs_init_casefolded_name(const struct inode *dir,
	struct super_block *sb = dir->i_sb;

	if (IS_CASEFOLDED(dir)) {
		fname->cf_name.name = kmem_cache_alloc(f2fs_cf_name_slab,
								GFP_NOFS);
		fname->cf_name.name = f2fs_kmem_cache_alloc(f2fs_cf_name_slab,
					GFP_NOFS, false, F2FS_SB(sb));
		if (!fname->cf_name.name)
			return -ENOMEM;
		fname->cf_name.len = utf8_casefold(sb->s_encoding,
Loading