]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: introduce FAULT_LOCK_TIMEOUT
authorChao Yu <chao@kernel.org>
Sun, 4 Jan 2026 02:07:28 +0000 (10:07 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 7 Jan 2026 03:17:08 +0000 (03:17 +0000)
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 <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
Documentation/filesystems/f2fs.rst
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/super.c

index de5a80124e04f27505a315ce6a934d5276491687..4b0bec3c074628d26893001657a729b88c6e8c7a 100644 (file)
@@ -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
index 2d71efa7db7a0438087a7a024b5ff661cbd3353d..33d2166ac6b7757e4912e542cd19fb185f3e7d2f 100644 (file)
@@ -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
index 86656231ce83bf9fd03ae8135c21fe682c65850c..f2ab5ba8fb6a53f2274e2d5f0552c73af0834a73 100644 (file)
@@ -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);
index 533440f15e20b56cf14b48af9ccb5e26729f9bf3..68fa9fd9cd5d0c85592307ca17b30ed3f79705d2 100644 (file)
@@ -65,6 +65,7 @@ enum {
        FAULT_INCONSISTENT_FOOTER,
        FAULT_ATOMIC_TIMEOUT,
        FAULT_VMALLOC,
+       FAULT_LOCK_TIMEOUT,
        FAULT_MAX,
 };
 
index 1b7fc2bd3bb78b34911e3659d0665f247058cb9e..30e6cf027ba757eebee4bfef44ab5a1ad2aac0bc 100644 (file)
@@ -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,