f2fs: inject to produce some orphan inodes
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 25 May 2016 22:24:18 +0000 (15:24 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 3 Jun 2016 01:05:19 +0000 (18:05 -0700)
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/inode.c
fs/f2fs/super.c

index 4365108d40b38e8fee658f3096aebc0c6a38dd80..4fec9e7038b65f3bf89ea9ae8441f7faf2243766 100644 (file)
@@ -45,6 +45,7 @@ enum {
        FAULT_ORPHAN,
        FAULT_BLOCK,
        FAULT_DIR_DEPTH,
+       FAULT_EVICT_INODE,
        FAULT_MAX,
 };
 
@@ -74,6 +75,8 @@ static inline bool time_to_inject(int type)
                return false;
        else if (type == FAULT_DIR_DEPTH && !IS_FAULT_SET(type))
                return false;
+       else if (type == FAULT_EVICT_INODE && !IS_FAULT_SET(type))
+               return false;
 
        atomic_inc(&f2fs_fault.inject_ops);
        if (atomic_read(&f2fs_fault.inject_ops) >= f2fs_fault.inject_rate) {
index bdd814db883eb538e98b98c29bbf69c47f1c99cb..11cb60af815d5531f5ef76a8d857b31005aa40d4 100644 (file)
@@ -345,6 +345,11 @@ void f2fs_evict_inode(struct inode *inode)
        if (inode->i_nlink || is_bad_inode(inode))
                goto no_delete;
 
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(FAULT_EVICT_INODE))
+               goto no_delete;
+#endif
+
        sb_start_intwrite(inode->i_sb);
        set_inode_flag(inode, FI_NO_ALLOC);
        i_size_write(inode, 0);
index a5b57390079c36587366725ad5d4bfa944d03825..27f76819eef14a4819c8dae07f8449e0046720bb 100644 (file)
@@ -49,6 +49,7 @@ char *fault_name[FAULT_MAX] = {
        [FAULT_ORPHAN]          = "orphan",
        [FAULT_BLOCK]           = "no more block",
        [FAULT_DIR_DEPTH]       = "too big dir depth",
+       [FAULT_EVICT_INODE]     = "evict_inode fail",
 };
 
 static void f2fs_build_fault_attr(unsigned int rate)