Skip to content

Commit

Permalink
f2fs: support discard submission error injection
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chao Yu authored and Jaegeuk Kim committed Aug 13, 2018
1 parent 35ec7d5 commit b83dcfe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum {
FAULT_TRUNCATE,
FAULT_IO,
FAULT_CHECKPOINT,
FAULT_DISCARD,
FAULT_MAX,
};

Expand Down
8 changes: 8 additions & 0 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b83dcfe

Please sign in to comment.