Commit 18792e64 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

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: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 91586ce0
...@@ -199,6 +199,7 @@ fault_type=%d Support configuring fault injection type, should be ...@@ -199,6 +199,7 @@ fault_type=%d Support configuring fault injection type, should be
FAULT_SLAB_ALLOC 0x000008000 FAULT_SLAB_ALLOC 0x000008000
FAULT_DQUOT_INIT 0x000010000 FAULT_DQUOT_INIT 0x000010000
FAULT_LOCK_OP 0x000020000 FAULT_LOCK_OP 0x000020000
FAULT_BLKADDR 0x000040000
=================== =========== =================== ===========
mode=%s Control block allocation mode which supports "adaptive" mode=%s Control block allocation mode which supports "adaptive"
and "lfs". In "lfs" mode, there should be no random and "lfs". In "lfs" mode, there should be no random
......
...@@ -171,6 +171,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr, ...@@ -171,6 +171,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
block_t blkaddr, int type) block_t blkaddr, int type)
{ {
if (time_to_inject(sbi, FAULT_BLKADDR)) {
f2fs_show_injection_info(sbi, FAULT_BLKADDR);
return false;
}
switch (type) { switch (type) {
case META_NAT: case META_NAT:
break; break;
......
...@@ -60,6 +60,7 @@ enum { ...@@ -60,6 +60,7 @@ enum {
FAULT_SLAB_ALLOC, FAULT_SLAB_ALLOC,
FAULT_DQUOT_INIT, FAULT_DQUOT_INIT,
FAULT_LOCK_OP, FAULT_LOCK_OP,
FAULT_BLKADDR,
FAULT_MAX, FAULT_MAX,
}; };
......
...@@ -61,6 +61,7 @@ const char *f2fs_fault_name[FAULT_MAX] = { ...@@ -61,6 +61,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
[FAULT_SLAB_ALLOC] = "slab alloc", [FAULT_SLAB_ALLOC] = "slab alloc",
[FAULT_DQUOT_INIT] = "dquot initialize", [FAULT_DQUOT_INIT] = "dquot initialize",
[FAULT_LOCK_OP] = "lock_op", [FAULT_LOCK_OP] = "lock_op",
[FAULT_BLKADDR] = "invalid blkaddr",
}; };
void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate, void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment