]> git.karo-electronics.de Git - linux-beck.git/commitdiff
f2fs: inject page allocation failures
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 29 Apr 2016 23:17:09 +0000 (16:17 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 7 May 2016 17:32:23 +0000 (10:32 -0700)
This patch adds page allocation failures.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/super.c

index cf03c57d0febb34cb937b5185c1d36c5e3b7c60b..d550a95d30f1a85f2303cc5475de0be918421860 100644 (file)
@@ -40,6 +40,7 @@
 #ifdef CONFIG_F2FS_FAULT_INJECTION
 enum {
        FAULT_KMALLOC,
+       FAULT_PAGE_ALLOC,
        FAULT_MAX,
 };
 
@@ -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,
                                                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);
index 9a56f544da3eaeea08f15f891e0315e2bcead18c..986d0da84e016b29087ad7250035b80f1221159e 100644 (file)
@@ -45,6 +45,7 @@ atomic_t f2fs_ops;
 
 char *fault_name[FAULT_MAX] = {
        [FAULT_KMALLOC]         = "kmalloc",
+       [FAULT_PAGE_ALLOC]      = "page alloc",
 };
 #endif