Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18792e6

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: support fault injection for f2fs_is_valid_blkaddr()
This patch supports to inject fault into f2fs_is_valid_blkaddr() to simulate accessing inconsistent data/meta block addressses from caller. Usage: a) echo 262144 > /sys/fs/f2fs/<dev>/inject_type or b) mount -o fault_type=262144 <dev> <mountpoint> Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 91586ce commit 18792e6

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

Documentation/filesystems/f2fs.rst

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

fs/f2fs/checkpoint.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
171171
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
172172
block_t blkaddr, int type)
173173
{
174+
if (time_to_inject(sbi, FAULT_BLKADDR)) {
175+
f2fs_show_injection_info(sbi, FAULT_BLKADDR);
176+
return false;
177+
}
178+
174179
switch (type) {
175180
case META_NAT:
176181
break;

fs/f2fs/f2fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum {
6060
FAULT_SLAB_ALLOC,
6161
FAULT_DQUOT_INIT,
6262
FAULT_LOCK_OP,
63+
FAULT_BLKADDR,
6364
FAULT_MAX,
6465
};
6566

fs/f2fs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
6161
[FAULT_SLAB_ALLOC] = "slab alloc",
6262
[FAULT_DQUOT_INIT] = "dquot initialize",
6363
[FAULT_LOCK_OP] = "lock_op",
64+
[FAULT_BLKADDR] = "invalid blkaddr",
6465
};
6566

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

0 commit comments

Comments
 (0)