]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
f2fs: add fault injection on f2fs_truncate
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 9 Mar 2017 23:24:24 +0000 (15:24 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 22 Mar 2017 02:34:26 +0000 (22:34 -0400)
Inject a fault during f2fs_truncate().

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/super.c

index b549b531e586f767d92c9fe755d7ca0129f98f3e..7c9685c4c904f042f3c5cd4a7de18ae20cc4881d 100644 (file)
@@ -50,6 +50,7 @@ enum {
        FAULT_BLOCK,
        FAULT_DIR_DEPTH,
        FAULT_EVICT_INODE,
+       FAULT_TRUNCATE,
        FAULT_IO,
        FAULT_CHECKPOINT,
        FAULT_MAX,
index 300d62015c2457899ef547c367ff9c148137e763..af507585c75b45fb0263f213d2ca0b8f9e90bd03 100644 (file)
@@ -620,6 +620,12 @@ int f2fs_truncate(struct inode *inode)
 
        trace_f2fs_truncate(inode);
 
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+       if (time_to_inject(F2FS_I_SB(inode), FAULT_TRUNCATE)) {
+               f2fs_show_injection_info(FAULT_TRUNCATE);
+               return -EIO;
+       }
+#endif
        /* we should check inline_data size */
        if (!f2fs_may_inline_data(inode)) {
                err = f2fs_convert_inline_inode(inode);
index cfb40d3fd875f8f2e5a882a0931d6f243a1b78b7..17126a2897ad836d65ca8c11636afa351c0c4938 100644 (file)
@@ -49,6 +49,7 @@ char *fault_name[FAULT_MAX] = {
        [FAULT_BLOCK]           = "no more block",
        [FAULT_DIR_DEPTH]       = "too big dir depth",
        [FAULT_EVICT_INODE]     = "evict_inode fail",
+       [FAULT_TRUNCATE]        = "truncate fail",
        [FAULT_IO]              = "IO error",
        [FAULT_CHECKPOINT]      = "checkpoint error",
 };