This patch introduce a new fault type FAULT_LOCK_TIMEOUT, it can
be used to inject timeout into lock duration.

Timeout type can be set via /sys/fs/f2fs/<disk>/inject_timeout_type

Signed-off-by: Chao Yu <[email protected]>
---
 Documentation/ABI/testing/sysfs-fs-f2fs | 1 +
 Documentation/filesystems/f2fs.rst      | 1 +
 fs/f2fs/checkpoint.c                    | 3 +++
 fs/f2fs/f2fs.h                          | 1 +
 fs/f2fs/super.c                         | 1 +
 5 files changed, 7 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs 
b/Documentation/ABI/testing/sysfs-fs-f2fs
index de5a80124e04..4b0bec3c0746 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -743,6 +743,7 @@ Description:        Support configuring fault injection 
type, should be
                FAULT_INCONSISTENT_FOOTER        0x00200000
                FAULT_ATOMIC_TIMEOUT             0x00400000 (1000ms)
                FAULT_VMALLOC                    0x00800000
+               FAULT_LOCK_TIMEOUT               0x01000000 (1000ms)
                ===========================      ==========
 
 What:          /sys/fs/f2fs/<disk>/discard_io_aware_gran
diff --git a/Documentation/filesystems/f2fs.rst 
b/Documentation/filesystems/f2fs.rst
index 2d71efa7db7a..33d2166ac6b7 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -217,6 +217,7 @@ fault_type=%d                Support configuring fault 
injection type, should be
                             FAULT_INCONSISTENT_FOOTER        0x00200000
                             FAULT_ATOMIC_TIMEOUT             0x00400000 
(1000ms)
                             FAULT_VMALLOC                    0x00800000
+                            FAULT_LOCK_TIMEOUT               0x01000000 
(1000ms)
                             ===========================      ==========
 mode=%s                         Control block allocation mode which supports 
"adaptive"
                         and "lfs". In "lfs" mode, there should be no random
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 86656231ce83..f2ab5ba8fb6a 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -63,6 +63,9 @@ static inline void trace_lock_elapsed_time_end(struct 
f2fs_rwsem *sem,
        if (!lc->lock_trace)
                return;
 
+       if (time_to_inject(sem->sbi, FAULT_LOCK_TIMEOUT))
+               f2fs_io_schedule_timeout_killable(DEFAULT_FAULT_TIMEOUT);
+
        get_lock_elapsed_time(&tts);
 
        total_time = div_u64(tts.total_time - lc->ts.total_time, npm);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8c0ce9fd954f..4f8eb1292ebf 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -65,6 +65,7 @@ enum {
        FAULT_INCONSISTENT_FOOTER,
        FAULT_ATOMIC_TIMEOUT,
        FAULT_VMALLOC,
+       FAULT_LOCK_TIMEOUT,
        FAULT_MAX,
 };
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9e41fe39dbf6..1915d194153e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -69,6 +69,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
        [FAULT_INCONSISTENT_FOOTER]     = "inconsistent footer",
        [FAULT_ATOMIC_TIMEOUT]          = "atomic timeout",
        [FAULT_VMALLOC]                 = "vmalloc",
+       [FAULT_LOCK_TIMEOUT]            = "lock timeout",
 };
 
 int f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned long rate,
-- 
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to