f2fs: introduce FAULT_LOCK_TIMEOUT

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>
This commit is contained in:
Chao Yu 2026-01-04 10:07:28 +08:00 committed by Jaegeuk Kim
parent 7a127c80b0
commit c56254e2e0
5 changed files with 7 additions and 0 deletions

View 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

View 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

View 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);

View File

@ -65,6 +65,7 @@ enum {
FAULT_INCONSISTENT_FOOTER,
FAULT_ATOMIC_TIMEOUT,
FAULT_VMALLOC,
FAULT_LOCK_TIMEOUT,
FAULT_MAX,
};

View 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,