From: Jaegeuk Kim Date: Thu, 9 Mar 2017 23:24:24 +0000 (-0800) Subject: f2fs: add fault injection on f2fs_truncate X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=14b44d238ce7402a99db30b806e08b3e4eddcdbe;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git f2fs: add fault injection on f2fs_truncate Inject a fault during f2fs_truncate(). Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index b549b531e586..7c9685c4c904 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -50,6 +50,7 @@ enum { FAULT_BLOCK, FAULT_DIR_DEPTH, FAULT_EVICT_INODE, + FAULT_TRUNCATE, FAULT_IO, FAULT_CHECKPOINT, FAULT_MAX, diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 300d62015c24..af507585c75b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -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); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index cfb40d3fd875..17126a2897ad 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -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", };