Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx> --- fs/ext4/ialloc.c | 5 +++- fs/ext4/inode.c | 18 +++++++++++++--- fs/ext4/namei.c | 55 ++++++++++++++++++++++++++++++++++++++++------------- fs/ext4/super.c | 9 +++++++- 4 files changed, 67 insertions(+), 20 deletions(-) diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 57f6eef..83265e4 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1029,7 +1029,10 @@ got: ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; ret = inode; - dquot_initialize(inode); + err = dquot_initialize(inode); + if(err) + goto fail_drop; + err = dquot_alloc_inode(inode); if (err) goto fail_drop; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 3e0f6af..10800e9 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -172,8 +172,15 @@ void ext4_delete_inode(struct inode *inode) handle_t *handle; int err; - if (!is_bad_inode(inode)) - dquot_initialize(inode); + if (!is_bad_inode(inode)) { + int ret = dquot_initialize(inode); + if (ret) + ext4_error(inode->i_sb, "Fail to init_quota " + "for inode %lu, uid %d, gid:%d, error%d, thus " + "quota information is probably inconsistent, " + "Please run quotacheck(8)", inode->i_ino, + inode->i_uid, inode->i_gid, ret); + } if (ext4_should_order_data(inode)) ext4_begin_ordered_truncate(inode, 0); @@ -5425,8 +5432,11 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (error) return error; - if (is_quota_modification(inode, attr)) - dquot_initialize(inode); + if (is_quota_modification(inode, attr)) { + error = dquot_initialize(inode); + if (error) + return error; + } if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { handle_t *handle; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 0c070fa..7832549 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1759,8 +1759,9 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, struct inode *inode; int err, retries = 0; - dquot_initialize(dir); - + err = dquot_initialize(dir); + if (err) + return err; retry: handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + @@ -1795,7 +1796,9 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, if (!new_valid_dev(rdev)) return -EINVAL; - dquot_initialize(dir); + err = dquot_initialize(dir); + if (err) + return err; retry: handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + @@ -1834,7 +1837,9 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) if (EXT4_DIR_LINK_MAX(dir)) return -EMLINK; - dquot_initialize(dir); + err = dquot_initialize(dir); + if (err) + return err; retry: handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + @@ -2143,8 +2148,13 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) /* Initialize quotas before so that eventual writes go in * separate transaction */ - dquot_initialize(dir); - dquot_initialize(dentry->d_inode); + retval = dquot_initialize(dir); + if (retval) + return retval; + + retval = dquot_initialize(dentry->d_inode); + if (retval) + return retval; handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); if (IS_ERR(handle)) @@ -2204,8 +2214,13 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) /* Initialize quotas before so that eventual writes go * in separate transaction */ - dquot_initialize(dir); - dquot_initialize(dentry->d_inode); + retval = dquot_initialize(dir); + if (retval) + return retval; + + retval = dquot_initialize(dentry->d_inode); + if (retval) + return retval; handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); if (IS_ERR(handle)) @@ -2261,7 +2276,9 @@ static int ext4_symlink(struct inode *dir, if (l > dir->i_sb->s_blocksize) return -ENAMETOOLONG; - dquot_initialize(dir); + err = dquot_initialize(dir); + if (err) + return err; retry: handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + @@ -2321,7 +2338,9 @@ static int ext4_link(struct dentry *old_dentry, if (inode->i_nlink >= EXT4_LINK_MAX) return -EMLINK; - dquot_initialize(dir); + err = dquot_initialize(dir); + if (err) + return err; /* * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing @@ -2373,15 +2392,23 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, struct ext4_dir_entry_2 *old_de, *new_de; int retval, force_da_alloc = 0; - dquot_initialize(old_dir); - dquot_initialize(new_dir); + retval = dquot_initialize(old_dir); + if (retval) + return retval; + + retval = dquot_initialize(new_dir); + if (retval) + return retval; old_bh = new_bh = dir_bh = NULL; /* Initialize quotas before so that eventual writes go * in separate transaction */ - if (new_dentry->d_inode) - dquot_initialize(new_dentry->d_inode); + if (new_dentry->d_inode) { + retval = dquot_initialize(new_dentry->d_inode); + if (retval) + return retval; + } handle = ext4_journal_start(old_dir, 2 * EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a794707..d3a1920 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2022,7 +2022,14 @@ static int ext4_orphan_cleanup(struct super_block *sb, } list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); - dquot_initialize(inode); + ret = dquot_initialize(inode); + if (ret) { + ext4_msg(sb, KERN_ERR, "Can not initialize quota for " + "inode:%lu error %d", + inode->i_ino, ret); + if (!test_opt (sb, ERRORS_CONT)) + goto out; + } if (inode->i_nlink) { ext4_msg(sb, KERN_DEBUG, "%s: truncating inode %lu to %lld bytes", -- 1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html