Skip to content

Commit

Permalink
reiserfs: Protect reiserfs_quota_on() with write lock
Browse files Browse the repository at this point in the history
In reiserfs_quota_on() we do quite some work - for example unpacking
tail of a quota file. Thus we have to hold write lock until a moment
we call back into the quota code.

CC: stable@vger.kernel.org # >= 3.0
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Jan Kara committed Nov 19, 2012
1 parent 3bb3e1f commit b9e06ef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs/reiserfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2216,8 +2216,11 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
struct reiserfs_transaction_handle th;
int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA;

if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt)))
return -EINVAL;
reiserfs_write_lock(sb);
if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt))) {
err = -EINVAL;
goto out;
}

/* Quotafile not on the same filesystem? */
if (path->dentry->d_sb != sb) {
Expand Down Expand Up @@ -2259,8 +2262,10 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
if (err)
goto out;
}
err = dquot_quota_on(sb, type, format_id, path);
reiserfs_write_unlock(sb);
return dquot_quota_on(sb, type, format_id, path);
out:
reiserfs_write_unlock(sb);
return err;
}

Expand Down

0 comments on commit b9e06ef

Please sign in to comment.