[PATCH] reiserfs: add checking of journal_begin() return value

Check return values of journal_begin() and journal_end() in the quota code
for reiserfs.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Jan Kara 2005-06-23 22:01:01 -07:00 committed by Linus Torvalds
parent 92198f7eaa
commit bd6a1f16ff
2 changed files with 52 additions and 20 deletions

View file

@ -2798,7 +2798,9 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
struct reiserfs_transaction_handle th;
/* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
journal_begin(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2);
error = journal_begin(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2);
if (error)
goto out;
error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
if (error) {
journal_end(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2);
@ -2811,7 +2813,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
if (attr->ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
mark_inode_dirty(inode);
journal_end(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2);
error = journal_end(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2);
}
}
if (!error)

View file

@ -1841,13 +1841,18 @@ static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf)
static int reiserfs_dquot_initialize(struct inode *inode, int type)
{
struct reiserfs_transaction_handle th;
int ret;
int ret, err;
/* We may create quota structure so we need to reserve enough blocks */
reiserfs_write_lock(inode->i_sb);
journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
ret = journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
if (ret)
goto out;
ret = dquot_initialize(inode, type);
journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
err = journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
if (!ret && err)
ret = err;
out:
reiserfs_write_unlock(inode->i_sb);
return ret;
}
@ -1855,13 +1860,18 @@ static int reiserfs_dquot_initialize(struct inode *inode, int type)
static int reiserfs_dquot_drop(struct inode *inode)
{
struct reiserfs_transaction_handle th;
int ret;
int ret, err;
/* We may delete quota structure so we need to reserve enough blocks */
reiserfs_write_lock(inode->i_sb);
journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
ret = journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
if (ret)
goto out;
ret = dquot_drop(inode);
journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
err = journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
if (!ret && err)
ret = err;
out:
reiserfs_write_unlock(inode->i_sb);
return ret;
}
@ -1869,12 +1879,17 @@ static int reiserfs_dquot_drop(struct inode *inode)
static int reiserfs_write_dquot(struct dquot *dquot)
{
struct reiserfs_transaction_handle th;
int ret;
int ret, err;
reiserfs_write_lock(dquot->dq_sb);
journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
if (ret)
goto out;
ret = dquot_commit(dquot);
journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
if (!ret && err)
ret = err;
out:
reiserfs_write_unlock(dquot->dq_sb);
return ret;
}
@ -1882,12 +1897,17 @@ static int reiserfs_write_dquot(struct dquot *dquot)
static int reiserfs_acquire_dquot(struct dquot *dquot)
{
struct reiserfs_transaction_handle th;
int ret;
int ret, err;
reiserfs_write_lock(dquot->dq_sb);
journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
if (ret)
goto out;
ret = dquot_acquire(dquot);
journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
if (!ret && err)
ret = err;
out:
reiserfs_write_unlock(dquot->dq_sb);
return ret;
}
@ -1895,12 +1915,17 @@ static int reiserfs_acquire_dquot(struct dquot *dquot)
static int reiserfs_release_dquot(struct dquot *dquot)
{
struct reiserfs_transaction_handle th;
int ret;
int ret, err;
reiserfs_write_lock(dquot->dq_sb);
journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
if (ret)
goto out;
ret = dquot_release(dquot);
journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
if (!ret && err)
ret = err;
out:
reiserfs_write_unlock(dquot->dq_sb);
return ret;
}
@ -1920,13 +1945,18 @@ static int reiserfs_mark_dquot_dirty(struct dquot *dquot)
static int reiserfs_write_info(struct super_block *sb, int type)
{
struct reiserfs_transaction_handle th;
int ret;
int ret, err;
/* Data block + inode block */
reiserfs_write_lock(sb);
journal_begin(&th, sb, 2);
ret = journal_begin(&th, sb, 2);
if (ret)
goto out;
ret = dquot_commit_info(sb, type);
journal_end(&th, sb, 2);
err = journal_end(&th, sb, 2);
if (!ret && err)
ret = err;
out:
reiserfs_write_unlock(sb);
return ret;
}