]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
f2fs: support IO error injection
authorChao Yu <yuchao0@huawei.com>
Sun, 18 Sep 2016 15:30:07 +0000 (23:30 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 22 Sep 2016 18:43:06 +0000 (11:43 -0700)
This patch adds to support IO error injection for testing IO error
tolerance of f2fs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/super.c

index 528c3c0d55a214de795fb24b7ebc61cdffa2455b..25e3c302b72f81c709820387e60adfbd6875a65d 100644 (file)
@@ -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);
index 951b9b3bc5f3fd47ae413208817eedba5730f7ae..f28b3f8fa72b3ae50443ba0b6691427b89fe795d 100644 (file)
@@ -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) {
index 555217fe43ce0986c4716ac5c2531442a2b8066c..29e3cf4ccf1b7240337944a98d4005cc20ccfc1e 100644 (file)
@@ -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)