Skip to content

Commit 3e02038

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: support fault injection to f2fs_trylock_op()
f2fs: support fault injection for f2fs_trylock_op() This patch supports to inject fault into f2fs_trylock_op(). Usage: a) echo 65536 > /sys/fs/f2fs/<dev>/inject_type or b) mount -o fault_type=65536 <dev> <mountpoint> Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent dd9d4a3 commit 3e02038

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

Documentation/filesystems/f2fs.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ fault_type=%d Support configuring fault injection type, should be
198198
FAULT_WRITE_IO 0x000004000
199199
FAULT_SLAB_ALLOC 0x000008000
200200
FAULT_DQUOT_INIT 0x000010000
201+
FAULT_LOCK_OP 0x000020000
201202
=================== ===========
202203
mode=%s Control block allocation mode which supports "adaptive"
203204
and "lfs". In "lfs" mode, there should be no random

fs/f2fs/f2fs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum {
5656
FAULT_WRITE_IO,
5757
FAULT_SLAB_ALLOC,
5858
FAULT_DQUOT_INIT,
59+
FAULT_LOCK_OP,
5960
FAULT_MAX,
6061
};
6162

@@ -2095,6 +2096,10 @@ static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
20952096

20962097
static inline int f2fs_trylock_op(struct f2fs_sb_info *sbi)
20972098
{
2099+
if (time_to_inject(sbi, FAULT_LOCK_OP)) {
2100+
f2fs_show_injection_info(sbi, FAULT_LOCK_OP);
2101+
return 0;
2102+
}
20982103
return down_read_trylock(&sbi->cp_rwsem);
20992104
}
21002105

fs/f2fs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
5959
[FAULT_WRITE_IO] = "write IO error",
6060
[FAULT_SLAB_ALLOC] = "slab alloc",
6161
[FAULT_DQUOT_INIT] = "dquot initialize",
62+
[FAULT_LOCK_OP] = "lock_op",
6263
};
6364

6465
void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,

0 commit comments

Comments
 (0)