Skip to content

Commit 0244c77

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: support FAULT_TIMEOUT
Support to inject a timeout fault into function, currently it only support to inject timeout to commit_atomic_write flow to reproduce inconsistent bug, like the bug fixed by commit f098aeb ("f2fs: fix to avoid atomicity corruption of atomic file"). By default, the new type fault will inject 1000ms timeout, and the timeout process can be interrupted by SIGKILL. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent cf7cd17 commit 0244c77

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ Description: Support configuring fault injection type, should be
735735
FAULT_BLKADDR_CONSISTENCE 0x000080000
736736
FAULT_NO_SEGMENT 0x000100000
737737
FAULT_INCONSISTENT_FOOTER 0x000200000
738+
FAULT_TIMEOUT 0x000400000 (1000ms)
738739
=========================== ===========
739740

740741
What: /sys/fs/f2fs/<disk>/discard_io_aware_gran

Documentation/filesystems/f2fs.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ fault_type=%d Support configuring fault injection type, should be
207207
FAULT_BLKADDR_CONSISTENCE 0x000080000
208208
FAULT_NO_SEGMENT 0x000100000
209209
FAULT_INCONSISTENT_FOOTER 0x000200000
210+
FAULT_TIMEOUT 0x000400000 (1000ms)
210211
=========================== ===========
211212
mode=%s Control block allocation mode which supports "adaptive"
212213
and "lfs". In "lfs" mode, there should be no random

fs/f2fs/f2fs.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ enum {
6363
FAULT_BLKADDR_CONSISTENCE,
6464
FAULT_NO_SEGMENT,
6565
FAULT_INCONSISTENT_FOOTER,
66+
FAULT_TIMEOUT,
6667
FAULT_MAX,
6768
};
6869

@@ -613,6 +614,9 @@ enum {
613614
/* congestion wait timeout value, default: 20ms */
614615
#define DEFAULT_IO_TIMEOUT (msecs_to_jiffies(20))
615616

617+
/* timeout value injected, default: 1000ms */
618+
#define DEFAULT_FAULT_TIMEOUT (msecs_to_jiffies(1000))
619+
616620
/* maximum retry quota flush count */
617621
#define DEFAULT_RETRY_QUOTA_FLUSH_COUNT 8
618622

@@ -4815,6 +4819,19 @@ static inline void f2fs_io_schedule_timeout(long timeout)
48154819
io_schedule_timeout(timeout);
48164820
}
48174821

4822+
static inline void f2fs_io_schedule_timeout_killable(long timeout)
4823+
{
4824+
while (timeout) {
4825+
if (fatal_signal_pending(current))
4826+
return;
4827+
set_current_state(TASK_UNINTERRUPTIBLE);
4828+
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
4829+
if (timeout <= DEFAULT_IO_TIMEOUT)
4830+
return;
4831+
timeout -= DEFAULT_IO_TIMEOUT;
4832+
}
4833+
}
4834+
48184835
static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi,
48194836
struct folio *folio, enum page_type type)
48204837
{

fs/f2fs/segment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ static int __f2fs_commit_atomic_write(struct inode *inode)
371371
}
372372

373373
out:
374+
if (time_to_inject(sbi, FAULT_TIMEOUT))
375+
f2fs_io_schedule_timeout_killable(DEFAULT_FAULT_TIMEOUT);
376+
374377
if (ret) {
375378
sbi->revoked_atomic_block += fi->atomic_write_cnt;
376379
} else {

fs/f2fs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
6565
[FAULT_BLKADDR_CONSISTENCE] = "inconsistent blkaddr",
6666
[FAULT_NO_SEGMENT] = "no free segment",
6767
[FAULT_INCONSISTENT_FOOTER] = "inconsistent footer",
68+
[FAULT_TIMEOUT] = "timeout",
6869
};
6970

7071
int f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned long rate,

0 commit comments

Comments
 (0)