diff options
| author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-04-29 16:17:09 -0700 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-13 12:33:25 +0200 |
| commit | 3e07797cae983bf0bbddb57509ffd0ec5f0c7615 (patch) | |
| tree | 1d0439667d47015be2da8ccebb30befb810de3b0 | |
| parent | cf5e3f58637310620c59bdbde876eda7449baa00 (diff) | |
f2fs: inject page allocation failures
This patch adds page allocation failures.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
| -rw-r--r-- | fs/f2fs/f2fs.h | 9 | ||||
| -rw-r--r-- | fs/f2fs/super.c | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 1e9a83ee1..888d07b77 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -41,6 +41,7 @@ #ifdef CONFIG_F2FS_FAULT_INJECTION enum { FAULT_KMALLOC, + FAULT_PAGE_ALLOC, FAULT_MAX, }; @@ -1332,6 +1333,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, 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) return grab_cache_page(mapping, index); return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 311e9d2a3..b21c0350f 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -45,6 +45,7 @@ atomic_t f2fs_ops; char *fault_name[FAULT_MAX] = { [FAULT_KMALLOC] = "kmalloc", + [FAULT_PAGE_ALLOC] = "page alloc", }; #endif |
