Commit 9a747377 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] quota locking fix

Quota locking fix from Jan Kara.
parent 5a3446d8
...@@ -1157,6 +1157,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path) ...@@ -1157,6 +1157,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
struct quota_info *dqopt = sb_dqopt(sb); struct quota_info *dqopt = sb_dqopt(sb);
struct quota_format_type *fmt = find_quota_format(format_id); struct quota_format_type *fmt = find_quota_format(format_id);
int error; int error;
unsigned int oldflags;
if (!fmt) if (!fmt)
return -ESRCH; return -ESRCH;
...@@ -1181,10 +1182,11 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path) ...@@ -1181,10 +1182,11 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
error = -EBUSY; error = -EBUSY;
goto out_lock; goto out_lock;
} }
oldflags = inode->i_flags;
dqopt->files[type] = f; dqopt->files[type] = f;
error = -EINVAL; error = -EINVAL;
if (!fmt->qf_ops->check_quota_file(sb, type)) if (!fmt->qf_ops->check_quota_file(sb, type))
goto out_lock; goto out_file_init;
/* We don't want quota on quota files */ /* We don't want quota on quota files */
dquot_drop_nolock(inode); dquot_drop_nolock(inode);
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
...@@ -1194,7 +1196,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path) ...@@ -1194,7 +1196,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
down(&dqopt->dqio_sem); down(&dqopt->dqio_sem);
if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) { if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) {
up(&dqopt->dqio_sem); up(&dqopt->dqio_sem);
goto out_lock; goto out_file_init;
} }
up(&dqopt->dqio_sem); up(&dqopt->dqio_sem);
set_enable_flags(dqopt, type); set_enable_flags(dqopt, type);
...@@ -1204,9 +1206,10 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path) ...@@ -1204,9 +1206,10 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
up_write(&dqopt->dqoff_sem); up_write(&dqopt->dqoff_sem);
return 0; return 0;
out_lock: out_file_init:
inode->i_flags &= ~S_NOQUOTA; inode->i_flags = oldflags;
dqopt->files[type] = NULL; dqopt->files[type] = NULL;
out_lock:
up_write(&dqopt->dqoff_sem); up_write(&dqopt->dqoff_sem);
out_f: out_f:
filp_close(f, NULL); filp_close(f, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment