Skip to content

Commit

Permalink
quota: Do not acquire dqio_sem for dquot overwrites in v2 format
Browse files Browse the repository at this point in the history
When dquot has space already allocated in a quota file, we just
overwrite that place when writing dquot. So we don't need any protection
against other modifications of quota file as these keep dquot in place.

Reviewed-by: Andreas Dilger <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
jankara committed Aug 17, 2017
1 parent 8fc32c2 commit d2faa41
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions fs/quota/quota_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,23 @@ static int v2_write_dquot(struct dquot *dquot)
{
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
int ret;

down_write(&dqopt->dqio_sem);
bool alloc = false;

/*
* If space for dquot is already allocated, we don't need any
* protection as we'll only overwrite the place of dquot. We are
* still protected by concurrent writes of the same dquot by
* dquot->dq_lock.
*/
if (!dquot->dq_off) {
alloc = true;
down_write(&dqopt->dqio_sem);
}
ret = qtree_write_dquot(
sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
dquot);
up_write(&dqopt->dqio_sem);
if (alloc)
up_write(&dqopt->dqio_sem);
return ret;
}

Expand Down

0 comments on commit d2faa41

Please sign in to comment.