Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx> --- fs/ext3/ialloc.c | 6 +++++- fs/ext3/inode.c | 19 ++++++++++++++----- fs/ext3/namei.c | 54 ++++++++++++++++++++++++++++++++++++++++-------------- fs/ext3/super.c | 9 ++++++++- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 0d0e97e..6757cde 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -590,7 +590,11 @@ got: sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; 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/ext3/inode.c b/fs/ext3/inode.c index 735f019..8497b03 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -196,9 +196,15 @@ void ext3_delete_inode (struct inode * inode) { handle_t *handle; - if (!is_bad_inode(inode)) - dquot_initialize(inode); - + if (!is_bad_inode(inode)) { + int ret = dquot_initialize(inode); + if (ret) + ext3_error(inode->i_sb, __func__, "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); + } truncate_inode_pages(&inode->i_data, 0); if (is_bad_inode(inode)) @@ -3151,8 +3157,11 @@ int ext3_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/ext3/namei.c b/fs/ext3/namei.c index ee18408..4813ebf 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1696,8 +1696,9 @@ static int ext3_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 = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + @@ -1732,7 +1733,9 @@ static int ext3_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 = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + @@ -1770,7 +1773,9 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode) if (dir->i_nlink >= EXT3_LINK_MAX) return -EMLINK; - dquot_initialize(dir); + err = dquot_initialize(dir); + if (err) + return err; retry: handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + @@ -2066,8 +2071,13 @@ static int ext3_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 = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); if (IS_ERR(handle)) @@ -2127,8 +2137,13 @@ static int ext3_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 = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); if (IS_ERR(handle)) @@ -2184,7 +2199,9 @@ static int ext3_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 = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + @@ -2241,7 +2258,9 @@ static int ext3_link (struct dentry * old_dentry, if (inode->i_nlink >= EXT3_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 @@ -2293,15 +2312,22 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, struct ext3_dir_entry_2 * old_de, * new_de; int retval, flush_file = 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 = ext3_journal_start(old_dir, 2 * EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 5ca068f..dd17196 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1498,7 +1498,14 @@ static int ext3_orphan_cleanup (struct super_block * sb, } list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); - dquot_initialize(inode); + ret = dquot_initialize(inode); + if (ret) { + ext3_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) { printk(KERN_DEBUG "%s: truncating inode %lu to %Ld bytes\n", -- 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