Commit c41f3cc3 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: inject page allocation failures

This patch adds page allocation failures.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 2c63fead
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#ifdef CONFIG_F2FS_FAULT_INJECTION #ifdef CONFIG_F2FS_FAULT_INJECTION
enum { enum {
FAULT_KMALLOC, FAULT_KMALLOC,
FAULT_PAGE_ALLOC,
FAULT_MAX, FAULT_MAX,
}; };
...@@ -1296,6 +1297,14 @@ static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi) ...@@ -1296,6 +1297,14 @@ static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
static inline struct page *f2fs_grab_cache_page(struct address_space *mapping, static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
pgoff_t index, bool for_write) pgoff_t index, bool for_write)
{ {
#ifdef CONFIG_F2FS_FAULT_INJECTION
struct page *page = find_lock_page(mapping, index);
if (page)
return page;
if (time_to_inject(FAULT_PAGE_ALLOC))
return NULL;
#endif
if (!for_write) if (!for_write)
return grab_cache_page(mapping, index); return grab_cache_page(mapping, index);
return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS); return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
......
...@@ -45,6 +45,7 @@ atomic_t f2fs_ops; ...@@ -45,6 +45,7 @@ atomic_t f2fs_ops;
char *fault_name[FAULT_MAX] = { char *fault_name[FAULT_MAX] = {
[FAULT_KMALLOC] = "kmalloc", [FAULT_KMALLOC] = "kmalloc",
[FAULT_PAGE_ALLOC] = "page alloc",
}; };
#endif #endif
......
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