From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 5/6] f2fs: support IO error injection
Date: Sun, 18 Sep 2016 23:30:07 +0800 [thread overview]
Message-ID: <1474212608-6930-5-git-send-email-chao@kernel.org> (raw)
In-Reply-To: <1474212608-6930-1-git-send-email-chao@kernel.org>
From: Chao Yu <yuchao0@huawei.com>
This patch adds to support IO error injection for testing IO error
tolerance of f2fs.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/data.c | 5 +++++
fs/f2fs/f2fs.h | 3 +++
fs/f2fs/super.c | 1 +
3 files changed, 9 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 120a995..251cc33 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -34,6 +34,11 @@ static void f2fs_read_end_io(struct bio *bio)
struct bio_vec *bvec;
int i;
+#ifdef CONFIG_F2FS_FAULT_INJECTION
+ if (time_to_inject(FAULT_IO))
+ bio->bi_error = -EIO;
+#endif
+
if (f2fs_bio_encrypted(bio)) {
if (bio->bi_error) {
fscrypt_release_ctx(bio->bi_private);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index b615f3f..a1a68bf 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -46,6 +46,7 @@ enum {
FAULT_BLOCK,
FAULT_DIR_DEPTH,
FAULT_EVICT_INODE,
+ FAULT_IO,
FAULT_MAX,
};
@@ -77,6 +78,8 @@ static inline bool time_to_inject(int type)
return false;
else if (type == FAULT_EVICT_INODE && !IS_FAULT_SET(type))
return false;
+ else if (type == FAULT_IO && !IS_FAULT_SET(type))
+ return false;
atomic_inc(&f2fs_fault.inject_ops);
if (atomic_read(&f2fs_fault.inject_ops) >= f2fs_fault.inject_rate) {
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f809729..fafa34e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -50,6 +50,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_IO] = "IO error",
};
static void f2fs_build_fault_attr(unsigned int rate)
--
2.7.2
------------------------------------------------------------------------------
next prev parent reply other threads:[~2016-09-18 15:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-18 15:30 [PATCH 1/6] f2fs: make f2fs_filetype_table static Chao Yu
2016-09-18 15:30 ` [PATCH 2/6] f2fs: fix to return error number of read_all_xattrs correctly Chao Yu
2016-09-18 15:30 ` [PATCH 3/6] f2fs: fix to avoid race condition when updating sbi flag Chao Yu
2016-09-19 21:40 ` Jaegeuk Kim
2016-09-20 1:41 ` Chao Yu
2016-09-18 15:30 ` [PATCH 4/6] f2fs: introduce cp_lock to protect updating of ckpt_flags Chao Yu
2016-09-19 21:49 ` Jaegeuk Kim
2016-09-20 1:47 ` Chao Yu
2016-09-20 2:41 ` Jaegeuk Kim
2016-09-20 2:50 ` Chao Yu
2016-09-18 15:30 ` Chao Yu [this message]
2016-09-18 15:30 ` [PATCH 6/6] f2fs: show dirty inode number Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474212608-6930-5-git-send-email-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).