Commit 8b038c70 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: support IO error injection

This patch adds to support IO error injection for testing IO error
tolerance of f2fs.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 86696966
...@@ -34,6 +34,11 @@ static void f2fs_read_end_io(struct bio *bio) ...@@ -34,6 +34,11 @@ static void f2fs_read_end_io(struct bio *bio)
struct bio_vec *bvec; struct bio_vec *bvec;
int i; int i;
#ifdef CONFIG_F2FS_FAULT_INJECTION
if (time_to_inject(FAULT_IO))
bio->bi_error = -EIO;
#endif
if (f2fs_bio_encrypted(bio)) { if (f2fs_bio_encrypted(bio)) {
if (bio->bi_error) { if (bio->bi_error) {
fscrypt_release_ctx(bio->bi_private); fscrypt_release_ctx(bio->bi_private);
......
...@@ -46,6 +46,7 @@ enum { ...@@ -46,6 +46,7 @@ enum {
FAULT_BLOCK, FAULT_BLOCK,
FAULT_DIR_DEPTH, FAULT_DIR_DEPTH,
FAULT_EVICT_INODE, FAULT_EVICT_INODE,
FAULT_IO,
FAULT_MAX, FAULT_MAX,
}; };
...@@ -77,6 +78,8 @@ static inline bool time_to_inject(int type) ...@@ -77,6 +78,8 @@ static inline bool time_to_inject(int type)
return false; return false;
else if (type == FAULT_EVICT_INODE && !IS_FAULT_SET(type)) else if (type == FAULT_EVICT_INODE && !IS_FAULT_SET(type))
return false; return false;
else if (type == FAULT_IO && !IS_FAULT_SET(type))
return false;
atomic_inc(&f2fs_fault.inject_ops); atomic_inc(&f2fs_fault.inject_ops);
if (atomic_read(&f2fs_fault.inject_ops) >= f2fs_fault.inject_rate) { if (atomic_read(&f2fs_fault.inject_ops) >= f2fs_fault.inject_rate) {
......
...@@ -50,6 +50,7 @@ char *fault_name[FAULT_MAX] = { ...@@ -50,6 +50,7 @@ char *fault_name[FAULT_MAX] = {
[FAULT_BLOCK] = "no more block", [FAULT_BLOCK] = "no more block",
[FAULT_DIR_DEPTH] = "too big dir depth", [FAULT_DIR_DEPTH] = "too big dir depth",
[FAULT_EVICT_INODE] = "evict_inode fail", [FAULT_EVICT_INODE] = "evict_inode fail",
[FAULT_IO] = "IO error",
}; };
static void f2fs_build_fault_attr(unsigned int rate) static void f2fs_build_fault_attr(unsigned int rate)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment