@@ -1521,6 +1521,7 @@ enum ext4_fault_bits {
/* inject metadata IO error*/
EXT4_FAULT_IBITMAP_EIO, /* inode bitmap block */
EXT4_FAULT_BBITMAP_EIO, /* block bitmap block */
+ EXT4_FAULT_INODE_EIO, /* inode */
EXT4_FAULT_MAX
};
@@ -1622,6 +1623,7 @@ EXT4_FAULT_INODE_FN(XATTR_CSUM, xattr_csum, 1)
EXT4_FAULT_GRP_FN(IBITMAP_EIO, inode_bitmap_io, -EIO)
EXT4_FAULT_GRP_FN(BBITMAP_EIO, block_bitmap_io, -EIO)
+EXT4_FAULT_INODE_FN(INODE_EIO, inode_io, -EIO)
/*
* fourth extended-fs super-block data in memory
@@ -4570,19 +4570,25 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino,
* Read the block from disk.
*/
trace_ext4_load_inode(sb, ino);
+ if (ext4_fault_inode_io(sb, ino)) {
+ unlock_buffer(bh);
+ blk_finish_plug(&plug);
+ goto err;
+ }
ext4_read_bh_nowait(bh, REQ_META | REQ_PRIO, NULL);
blk_finish_plug(&plug);
wait_on_buffer(bh);
ext4_simulate_fail_bh(sb, bh, EXT4_SIM_INODE_EIO);
- if (!buffer_uptodate(bh)) {
- if (ret_block)
- *ret_block = block;
- brelse(bh);
- return -EIO;
- }
+ if (!buffer_uptodate(bh))
+ goto err;
has_buffer:
iloc->bh = bh;
return 0;
+err:
+ if (ret_block)
+ *ret_block = block;
+ brelse(bh);
+ return -EIO;
}
static int __ext4_get_inode_loc_noinmem(struct inode *inode,
@@ -580,6 +580,7 @@ char *ext4_fault_names[EXT4_FAULT_MAX] = {
"xattr_block_checksum", /* EXT4_FAULT_XATTR_CSUM */
"inode_bitmap_eio", /* EXT4_FAULT_IBITMAP_EIO */
"block_bitmap_eio", /* EXT4_FAULT_BBITMAP_EIO */
+ "inode_eio", /* EXT4_FAULT_INODE_EIO */
};
static int ext4_fault_available_show(struct seq_file *m, void *v)
Add I/O fault injection when reading raw inode from disk, we can specify the inode to inject, __ext4_get_inode_loc() will return -EIO immediately instead of submitting I/O, note that it doesn't handle the readhead case. Signed-off-by: Zhang Yi <yi.zhang@huawei.com> --- fs/ext4/ext4.h | 2 ++ fs/ext4/inode.c | 18 ++++++++++++------ fs/ext4/sysfs.c | 1 + 3 files changed, 15 insertions(+), 6 deletions(-)