mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 23:54:04 +08:00
f2fs: support fault injection for dquot_initialize()
This patch adds a new function f2fs_dquot_initialize() to wrap dquot_initialize(), and it supports to inject fault into f2fs_dquot_initialize() to simulate inner failure occurs in dquot_initialize(). 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>
This commit is contained in:
parent
ca98d72141
commit
10a2687856
@ -197,6 +197,7 @@ fault_type=%d Support configuring fault injection type, should be
|
|||||||
FAULT_DISCARD 0x000002000
|
FAULT_DISCARD 0x000002000
|
||||||
FAULT_WRITE_IO 0x000004000
|
FAULT_WRITE_IO 0x000004000
|
||||||
FAULT_SLAB_ALLOC 0x000008000
|
FAULT_SLAB_ALLOC 0x000008000
|
||||||
|
FAULT_DQUOT_INIT 0x000010000
|
||||||
=================== ===========
|
=================== ===========
|
||||||
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
|
||||||
|
@ -653,7 +653,7 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
|
|||||||
return PTR_ERR(inode);
|
return PTR_ERR(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err) {
|
if (err) {
|
||||||
iput(inode);
|
iput(inode);
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
@ -55,6 +55,7 @@ enum {
|
|||||||
FAULT_DISCARD,
|
FAULT_DISCARD,
|
||||||
FAULT_WRITE_IO,
|
FAULT_WRITE_IO,
|
||||||
FAULT_SLAB_ALLOC,
|
FAULT_SLAB_ALLOC,
|
||||||
|
FAULT_DQUOT_INIT,
|
||||||
FAULT_MAX,
|
FAULT_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3376,6 +3377,7 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
|
|||||||
*/
|
*/
|
||||||
int f2fs_inode_dirtied(struct inode *inode, bool sync);
|
int f2fs_inode_dirtied(struct inode *inode, bool sync);
|
||||||
void f2fs_inode_synced(struct inode *inode);
|
void f2fs_inode_synced(struct inode *inode);
|
||||||
|
int f2fs_dquot_initialize(struct inode *inode);
|
||||||
int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly);
|
int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly);
|
||||||
int f2fs_quota_sync(struct super_block *sb, int type);
|
int f2fs_quota_sync(struct super_block *sb, int type);
|
||||||
loff_t max_file_blocks(struct inode *inode);
|
loff_t max_file_blocks(struct inode *inode);
|
||||||
|
@ -786,7 +786,7 @@ int f2fs_truncate(struct inode *inode)
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -916,7 +916,7 @@ int f2fs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (is_quota_modification(inode, attr)) {
|
if (is_quota_modification(inode, attr)) {
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -3020,7 +3020,7 @@ static int f2fs_ioc_setproject(struct inode *inode, __u32 projid)
|
|||||||
}
|
}
|
||||||
f2fs_put_page(ipage, 1);
|
f2fs_put_page(ipage, 1);
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ int f2fs_convert_inline_inode(struct inode *inode)
|
|||||||
f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb))
|
f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@ void f2fs_evict_inode(struct inode *inode)
|
|||||||
if (inode->i_nlink || is_bad_inode(inode))
|
if (inode->i_nlink || is_bad_inode(inode))
|
||||||
goto no_delete;
|
goto no_delete;
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err) {
|
if (err) {
|
||||||
err = 0;
|
err = 0;
|
||||||
set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
|
set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
|
||||||
|
@ -74,7 +74,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
|
|||||||
if (err)
|
if (err)
|
||||||
goto fail_drop;
|
goto fail_drop;
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail_drop;
|
goto fail_drop;
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ static int f2fs_create(struct user_namespace *mnt_userns, struct inode *dir,
|
|||||||
if (!f2fs_is_checkpoint_ready(sbi))
|
if (!f2fs_is_checkpoint_ready(sbi))
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
|
|||||||
F2FS_I(old_dentry->d_inode)->i_projid)))
|
F2FS_I(old_dentry->d_inode)->i_projid)))
|
||||||
return -EXDEV;
|
return -EXDEV;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -598,10 +598,10 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -675,7 +675,7 @@ static int f2fs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -746,7 +746,7 @@ static int f2fs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
|
|||||||
if (unlikely(f2fs_cp_error(sbi)))
|
if (unlikely(f2fs_cp_error(sbi)))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -803,7 +803,7 @@ static int f2fs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
|
|||||||
if (!f2fs_is_checkpoint_ready(sbi))
|
if (!f2fs_is_checkpoint_ready(sbi))
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -841,7 +841,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
|
|||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = dquot_initialize(dir);
|
err = f2fs_dquot_initialize(dir);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -965,16 +965,16 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dquot_initialize(old_dir);
|
err = f2fs_dquot_initialize(old_dir);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = dquot_initialize(new_dir);
|
err = f2fs_dquot_initialize(new_dir);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (new_inode) {
|
if (new_inode) {
|
||||||
err = dquot_initialize(new_inode);
|
err = f2fs_dquot_initialize(new_inode);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1138,11 +1138,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
F2FS_I(new_dentry->d_inode)->i_projid)))
|
F2FS_I(new_dentry->d_inode)->i_projid)))
|
||||||
return -EXDEV;
|
return -EXDEV;
|
||||||
|
|
||||||
err = dquot_initialize(old_dir);
|
err = f2fs_dquot_initialize(old_dir);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = dquot_initialize(new_dir);
|
err = f2fs_dquot_initialize(new_dir);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi,
|
|||||||
if (IS_ERR(inode))
|
if (IS_ERR(inode))
|
||||||
return ERR_CAST(inode);
|
return ERR_CAST(inode);
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ retry:
|
|||||||
goto out_put;
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dquot_initialize(einode);
|
err = f2fs_dquot_initialize(einode);
|
||||||
if (err) {
|
if (err) {
|
||||||
iput(einode);
|
iput(einode);
|
||||||
goto out_put;
|
goto out_put;
|
||||||
@ -508,7 +508,7 @@ got_it:
|
|||||||
if (IS_ERR(inode))
|
if (IS_ERR(inode))
|
||||||
return PTR_ERR(inode);
|
return PTR_ERR(inode);
|
||||||
|
|
||||||
ret = dquot_initialize(inode);
|
ret = f2fs_dquot_initialize(inode);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
iput(inode);
|
iput(inode);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -58,6 +58,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
|
|||||||
[FAULT_DISCARD] = "discard error",
|
[FAULT_DISCARD] = "discard error",
|
||||||
[FAULT_WRITE_IO] = "write IO error",
|
[FAULT_WRITE_IO] = "write IO error",
|
||||||
[FAULT_SLAB_ALLOC] = "slab alloc",
|
[FAULT_SLAB_ALLOC] = "slab alloc",
|
||||||
|
[FAULT_DQUOT_INIT] = "dquot initialize",
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -2499,6 +2500,16 @@ retry:
|
|||||||
return len - towrite;
|
return len - towrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int f2fs_dquot_initialize(struct inode *inode)
|
||||||
|
{
|
||||||
|
if (time_to_inject(F2FS_I_SB(inode), FAULT_DQUOT_INIT)) {
|
||||||
|
f2fs_show_injection_info(F2FS_I_SB(inode), FAULT_DQUOT_INIT);
|
||||||
|
return -ESRCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dquot_initialize(inode);
|
||||||
|
}
|
||||||
|
|
||||||
static struct dquot **f2fs_get_dquots(struct inode *inode)
|
static struct dquot **f2fs_get_dquots(struct inode *inode)
|
||||||
{
|
{
|
||||||
return F2FS_I(inode)->i_dquot;
|
return F2FS_I(inode)->i_dquot;
|
||||||
@ -2883,6 +2894,11 @@ static const struct quotactl_ops f2fs_quotactl_ops = {
|
|||||||
.get_nextdqblk = dquot_get_next_dqblk,
|
.get_nextdqblk = dquot_get_next_dqblk,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
int f2fs_dquot_initialize(struct inode *inode)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int f2fs_quota_sync(struct super_block *sb, int type)
|
int f2fs_quota_sync(struct super_block *sb, int type)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -136,7 +136,7 @@ static int f2fs_begin_enable_verity(struct file *filp)
|
|||||||
* here and not rely on ->open() doing it. This must be done before
|
* here and not rely on ->open() doing it. This must be done before
|
||||||
* evicting the inline data.
|
* evicting the inline data.
|
||||||
*/
|
*/
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -773,7 +773,7 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
|
|||||||
if (!f2fs_is_checkpoint_ready(sbi))
|
if (!f2fs_is_checkpoint_ready(sbi))
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
|
|
||||||
err = dquot_initialize(inode);
|
err = f2fs_dquot_initialize(inode);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user