f2fs: split IO error injection according to RW
authorChao Yu <yuchao0@huawei.com>
Wed, 12 Sep 2018 01:22:29 +0000 (09:22 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 12 Sep 2018 20:07:32 +0000 (13:07 -0700)
This patch adds to support injecting error for write IO, this can simulate
IO error like fail_make_request or dm_flakey does.

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

index e5edd29687b50a74f8946ca215f639bb71b434fa..bde3e91e5372eb946557ddb330747f37fb1e8328 100644 (file)
@@ -172,9 +172,10 @@ fault_type=%d          Support configuring fault injection type, should be
                        FAULT_DIR_DEPTH         0x000000100
                        FAULT_EVICT_INODE       0x000000200
                        FAULT_TRUNCATE          0x000000400
-                       FAULT_IO                        0x000000800
+                       FAULT_READ_IO           0x000000800
                        FAULT_CHECKPOINT                0x000001000
                        FAULT_DISCARD           0x000002000
+                       FAULT_WRITE_IO          0x000004000
 mode=%s                Control block allocation mode which supports "adaptive"
                        and "lfs". In "lfs" mode, there should be no random
                        writes towards main area.
index c8c4b54e2bbf4eb7306c2ca1f3698ac1660589dd..57c0823d22e001b953078db47ac91cfa42e3678a 100644 (file)
@@ -123,8 +123,9 @@ static bool f2fs_bio_post_read_required(struct bio *bio)
 
 static void f2fs_read_end_io(struct bio *bio)
 {
-       if (time_to_inject(F2FS_P_SB(bio_first_page_all(bio)), FAULT_IO)) {
-               f2fs_show_injection_info(FAULT_IO);
+       if (time_to_inject(F2FS_P_SB(bio_first_page_all(bio)),
+                                               FAULT_READ_IO)) {
+               f2fs_show_injection_info(FAULT_READ_IO);
                bio->bi_status = BLK_STS_IOERR;
        }
 
@@ -145,6 +146,11 @@ static void f2fs_write_end_io(struct bio *bio)
        struct bio_vec *bvec;
        int i;
 
+       if (time_to_inject(sbi, FAULT_WRITE_IO)) {
+               f2fs_show_injection_info(FAULT_WRITE_IO);
+               bio->bi_status = BLK_STS_IOERR;
+       }
+
        bio_for_each_segment_all(bvec, bio, i) {
                struct page *page = bvec->bv_page;
                enum count_type type = WB_DATA_TYPE(page);
index 079f525d5764289510cef52dfb32a5d3be4e9e76..b676b82312e001fb8555d4355ed1d23a115e56d5 100644 (file)
@@ -50,9 +50,10 @@ enum {
        FAULT_DIR_DEPTH,
        FAULT_EVICT_INODE,
        FAULT_TRUNCATE,
-       FAULT_IO,
+       FAULT_READ_IO,
        FAULT_CHECKPOINT,
        FAULT_DISCARD,
+       FAULT_WRITE_IO,
        FAULT_MAX,
 };
 
index 8c536105d5efb5d27d3c4b125ac83d2a9e9a3de2..945468968d4efcad9ccde06a48ee121fb2bc1342 100644 (file)
@@ -50,9 +50,10 @@ char *f2fs_fault_name[FAULT_MAX] = {
        [FAULT_DIR_DEPTH]       = "too big dir depth",
        [FAULT_EVICT_INODE]     = "evict_inode fail",
        [FAULT_TRUNCATE]        = "truncate fail",
-       [FAULT_IO]              = "IO error",
+       [FAULT_READ_IO]         = "read IO error",
        [FAULT_CHECKPOINT]      = "checkpoint error",
        [FAULT_DISCARD]         = "discard error",
+       [FAULT_WRITE_IO]        = "write IO error",
 };
 
 void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,