Skip to content

Commit

Permalink
quota: Properly disable quotas when add_dquot_ref() fails
Browse files Browse the repository at this point in the history
When add_dquot_ref() fails (usually due to IO error or ENOMEM), we want
to disable quotas we are trying to enable. However dquot_disable() call
was passed just the flags we are enabling so in case flags ==
DQUOT_USAGE_ENABLED dquot_disable() call will just fail with EINVAL
instead of properly disabling quotas. Fix the problem by always passing
DQUOT_LIMITS_ENABLED | DQUOT_USAGE_ENABLED to dquot_disable() in this
case.

Reported-and-tested-by: Ye Bin <[email protected]>
Reported-by: [email protected]
Signed-off-by: Jan Kara <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
jankara committed Jun 5, 2023
1 parent aac2fa2 commit 6a4e336
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/quota/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,8 @@ int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,

error = add_dquot_ref(sb, type);
if (error)
dquot_disable(sb, type, flags);
dquot_disable(sb, type,
DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);

return error;
out_fmt:
Expand Down

0 comments on commit 6a4e336

Please sign in to comment.