f2fs: inject ENOSPC failures
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 29 Apr 2016 23:29:22 +0000 (16:29 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 7 May 2016 17:32:24 +0000 (10:32 -0700)
This patch injects ENOSPC failures.

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

index 9596d61ca6a8bda0a93b72ed17087437f27d05fd..79da86d6cf5cb9ec7035e187b30b24961f37da09 100644 (file)
@@ -474,6 +474,13 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
        int err = 0;
 
        spin_lock(&im->ino_lock);
+
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(FAULT_ORPHAN)) {
+               spin_unlock(&im->ino_lock);
+               return -ENOSPC;
+       }
+#endif
        if (unlikely(im->ino_num >= sbi->max_orphans))
                err = -ENOSPC;
        else
index 6bd0595914051bcc91297ee45ede12555b540e77..50f42be4ff1a7b65ba3fc9a1a49d2d460da6175b 100644 (file)
@@ -537,6 +537,10 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
        }
 
 start:
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(FAULT_DIR_DEPTH))
+               return -ENOSPC;
+#endif
        if (unlikely(current_depth == MAX_DIR_HASH_DEPTH))
                return -ENOSPC;
 
index d550a95d30f1a85f2303cc5475de0be918421860..8ba2f923d95a4b3e9d851fc8e30fcc9101b48cfb 100644 (file)
 enum {
        FAULT_KMALLOC,
        FAULT_PAGE_ALLOC,
+       FAULT_ALLOC_NID,
+       FAULT_ORPHAN,
+       FAULT_BLOCK,
+       FAULT_DIR_DEPTH,
        FAULT_MAX,
 };
 
@@ -1087,6 +1091,12 @@ static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
        block_t valid_block_count;
 
        spin_lock(&sbi->stat_lock);
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(FAULT_BLOCK)) {
+               spin_unlock(&sbi->stat_lock);
+               return false;
+       }
+#endif
        valid_block_count =
                sbi->total_valid_block_count + (block_t)count;
        if (unlikely(valid_block_count > sbi->user_block_count)) {
index af010f5c4ee14621f956b494550097a767a2f40e..78b98db48805fa3d58a0edcfad515a77e2f344f4 100644 (file)
@@ -1838,6 +1838,10 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i = NULL;
 retry:
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(FAULT_ALLOC_NID))
+               return false;
+#endif
        if (unlikely(sbi->total_valid_node_count + 1 > nm_i->available_nids))
                return false;
 
index 986d0da84e016b29087ad7250035b80f1221159e..87654f48c55d6eaa64bf155db0b417ee6e9d4cd1 100644 (file)
@@ -46,6 +46,10 @@ atomic_t f2fs_ops;
 char *fault_name[FAULT_MAX] = {
        [FAULT_KMALLOC]         = "kmalloc",
        [FAULT_PAGE_ALLOC]      = "page alloc",
+       [FAULT_ALLOC_NID]       = "alloc nid",
+       [FAULT_ORPHAN]          = "orphan",
+       [FAULT_BLOCK]           = "no more block",
+       [FAULT_DIR_DEPTH]       = "too big dir depth",
 };
 #endif