summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2018-08-06 14:30:18 +0200
committerJaegeuk Kim <jaegeuk@kernel.org>2018-08-13 19:48:17 +0200
commitb83dcfe67142ea9f4bfaa1e9e21504be9e3c1bf7 (patch)
tree1d82393efe973ad6ffa36302bc855c169e78f712 /fs/f2fs
parentf2fs: split discard command in prior to block layer (diff)
downloadlinux-b83dcfe67142ea9f4bfaa1e9e21504be9e3c1bf7.tar.xz
linux-b83dcfe67142ea9f4bfaa1e9e21504be9e3c1bf7.zip
f2fs: support discard submission error injection
This patch adds to support discard submission error injection for testing error handling of __submit_discard_cmd(). Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/segment.c8
-rw-r--r--fs/f2fs/super.c1
3 files changed, 10 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9fb780317b4e..95244e75dfc4 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -56,6 +56,7 @@ enum {
FAULT_TRUNCATE,
FAULT_IO,
FAULT_CHECKPOINT,
+ FAULT_DISCARD,
FAULT_MAX,
};
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 540d7d6161ba..f24e659463e9 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1041,10 +1041,18 @@ static void __submit_discard_cmd(struct f2fs_sb_info *sbi,
dc->len += len;
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+ if (time_to_inject(sbi, FAULT_DISCARD)) {
+ f2fs_show_injection_info(FAULT_DISCARD);
+ err = -EIO;
+ goto submit;
+ }
+#endif
err = __blkdev_issue_discard(bdev,
SECTOR_FROM_BLOCK(start),
SECTOR_FROM_BLOCK(len),
GFP_NOFS, 0, &bio);
+submit:
if (!err && bio) {
/*
* should keep before submission to avoid D_DONE
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index bd57be470e23..30bd9138f39d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -55,6 +55,7 @@ char *f2fs_fault_name[FAULT_MAX] = {
[FAULT_TRUNCATE] = "truncate fail",
[FAULT_IO] = "IO error",
[FAULT_CHECKPOINT] = "checkpoint error",
+ [FAULT_DISCARD] = "discard error",
};
void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate)