@@ -196,6 +196,9 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
&file->f_ra, file,
index, 1);
file->f_ra.prev_pos = (loff_t)index << PAGE_SHIFT;
+ err = ext4_fault_dirblock_io(inode, map.m_lblk);
+ if (err)
+ goto errout;
bh = ext4_bread(NULL, inode, map.m_lblk, 0);
if (IS_ERR(bh)) {
err = PTR_ERR(bh);
@@ -1523,6 +1523,7 @@ enum ext4_fault_bits {
EXT4_FAULT_BBITMAP_EIO, /* block bitmap block */
EXT4_FAULT_INODE_EIO, /* inode */
EXT4_FAULT_EXTENT_EIO, /* extent block */
+ EXT4_FAULT_DIRBLOCK_EIO, /* directory block */
EXT4_FAULT_MAX
};
@@ -1626,6 +1627,7 @@ 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)
EXT4_FAULT_INODE_PBLOCK_FN(EXTENT_EIO, extent_io, -EIO)
+EXT4_FAULT_INODE_LBLOCK_FN(DIRBLOCK_EIO, dirblock_io, -EIO)
/*
* fourth extended-fs super-block data in memory
@@ -140,6 +140,8 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
if (ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_EIO))
bh = ERR_PTR(-EIO);
+ else if (ext4_fault_dirblock_io(inode, block))
+ bh = ERR_PTR(-EIO);
else
bh = ext4_bread(NULL, inode, block, 0);
if (IS_ERR(bh)) {
@@ -1663,6 +1665,8 @@ static struct buffer_head *__ext4_find_entry(struct inode *dir,
if ((bh = bh_use[ra_ptr++]) == NULL)
goto next;
wait_on_buffer(bh);
+ if (ext4_fault_dirblock_io(dir, bh->b_blocknr))
+ clear_buffer_uptodate(bh);
if (!buffer_uptodate(bh)) {
EXT4_ERROR_INODE_ERR(dir, EIO,
"reading directory lblock %lu",
@@ -582,6 +582,7 @@ char *ext4_fault_names[EXT4_FAULT_MAX] = {
"block_bitmap_eio", /* EXT4_FAULT_BBITMAP_EIO */
"inode_eio", /* EXT4_FAULT_INODE_EIO */
"extent_block_eio", /* EXT4_FAULT_EXTENT_EIO */
+ "dir_block_eio", /* EXT4_FAULT_DIRBLOCK_EIO */
};
static int ext4_fault_available_show(struct seq_file *m, void *v)
Add directory block reading I/O fault injection, we can specify the inode and logical block to inject. It will return -EIO immediately instead of submitting I/O in readdir cases, but in the __ext4_find_entry() procedure, it's hard to inject error precisely due to the batch count reading, so it simulate error by clearing the buffer's uptodate flag after I/O complete. Signed-off-by: Zhang Yi <yi.zhang@huawei.com> --- fs/ext4/dir.c | 3 +++ fs/ext4/ext4.h | 2 ++ fs/ext4/namei.c | 4 ++++ fs/ext4/sysfs.c | 1 + 4 files changed, 10 insertions(+)