Commit 01eccef7 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: support get_page error injection

This patch adds to support get_page error injection to simulate
out-of-memory test scenario.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b32d73ab
...@@ -1965,7 +1965,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, ...@@ -1965,7 +1965,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
* Do not use grab_cache_page_write_begin() to avoid deadlock due to * Do not use grab_cache_page_write_begin() to avoid deadlock due to
* wait_for_stable_page. Will wait that below with our IO control. * wait_for_stable_page. Will wait that below with our IO control.
*/ */
page = pagecache_get_page(mapping, index, page = f2fs_pagecache_get_page(mapping, index,
FGP_LOCK | FGP_WRITE | FGP_CREAT, GFP_NOFS); FGP_LOCK | FGP_WRITE | FGP_CREAT, GFP_NOFS);
if (!page) { if (!page) {
err = -ENOMEM; err = -ENOMEM;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
enum { enum {
FAULT_KMALLOC, FAULT_KMALLOC,
FAULT_PAGE_ALLOC, FAULT_PAGE_ALLOC,
FAULT_PAGE_GET,
FAULT_ALLOC_NID, FAULT_ALLOC_NID,
FAULT_ORPHAN, FAULT_ORPHAN,
FAULT_BLOCK, FAULT_BLOCK,
...@@ -1835,6 +1836,19 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping, ...@@ -1835,6 +1836,19 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS); return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
} }
static inline struct page *f2fs_pagecache_get_page(
struct address_space *mapping, pgoff_t index,
int fgp_flags, gfp_t gfp_mask)
{
#ifdef CONFIG_F2FS_FAULT_INJECTION
if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_GET)) {
f2fs_show_injection_info(FAULT_PAGE_GET);
return NULL;
}
#endif
return pagecache_get_page(mapping, index, fgp_flags, gfp_mask);
}
static inline void f2fs_copy_page(struct page *src, struct page *dst) static inline void f2fs_copy_page(struct page *src, struct page *dst)
{ {
char *src_kaddr = kmap(src); char *src_kaddr = kmap(src);
......
...@@ -650,8 +650,8 @@ static void move_data_block(struct inode *inode, block_t bidx, ...@@ -650,8 +650,8 @@ static void move_data_block(struct inode *inode, block_t bidx,
allocate_data_block(fio.sbi, NULL, fio.old_blkaddr, &newaddr, allocate_data_block(fio.sbi, NULL, fio.old_blkaddr, &newaddr,
&sum, CURSEG_COLD_DATA, NULL, false); &sum, CURSEG_COLD_DATA, NULL, false);
fio.encrypted_page = pagecache_get_page(META_MAPPING(fio.sbi), newaddr, fio.encrypted_page = f2fs_pagecache_get_page(META_MAPPING(fio.sbi),
FGP_LOCK | FGP_CREAT, GFP_NOFS); newaddr, FGP_LOCK | FGP_CREAT, GFP_NOFS);
if (!fio.encrypted_page) { if (!fio.encrypted_page) {
err = -ENOMEM; err = -ENOMEM;
goto recover_block; goto recover_block;
......
...@@ -1218,7 +1218,8 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino) ...@@ -1218,7 +1218,8 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
if (!inode) if (!inode)
return; return;
page = pagecache_get_page(inode->i_mapping, 0, FGP_LOCK|FGP_NOWAIT, 0); page = f2fs_pagecache_get_page(inode->i_mapping, 0,
FGP_LOCK|FGP_NOWAIT, 0);
if (!page) if (!page)
goto iput_out; goto iput_out;
......
...@@ -44,6 +44,7 @@ static struct kmem_cache *f2fs_inode_cachep; ...@@ -44,6 +44,7 @@ static struct kmem_cache *f2fs_inode_cachep;
char *fault_name[FAULT_MAX] = { char *fault_name[FAULT_MAX] = {
[FAULT_KMALLOC] = "kmalloc", [FAULT_KMALLOC] = "kmalloc",
[FAULT_PAGE_ALLOC] = "page alloc", [FAULT_PAGE_ALLOC] = "page alloc",
[FAULT_PAGE_GET] = "page get",
[FAULT_ALLOC_NID] = "alloc nid", [FAULT_ALLOC_NID] = "alloc nid",
[FAULT_ORPHAN] = "orphan", [FAULT_ORPHAN] = "orphan",
[FAULT_BLOCK] = "no more block", [FAULT_BLOCK] = "no more block",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment