Skip to content

Commit d2faa41

Browse files
committed
quota: Do not acquire dqio_sem for dquot overwrites in v2 format
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]>
1 parent 8fc32c2 commit d2faa41

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

fs/quota/quota_v2.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,23 @@ static int v2_write_dquot(struct dquot *dquot)
300300
{
301301
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
302302
int ret;
303-
304-
down_write(&dqopt->dqio_sem);
303+
bool alloc = false;
304+
305+
/*
306+
* If space for dquot is already allocated, we don't need any
307+
* protection as we'll only overwrite the place of dquot. We are
308+
* still protected by concurrent writes of the same dquot by
309+
* dquot->dq_lock.
310+
*/
311+
if (!dquot->dq_off) {
312+
alloc = true;
313+
down_write(&dqopt->dqio_sem);
314+
}
305315
ret = qtree_write_dquot(
306316
sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
307317
dquot);
308-
up_write(&dqopt->dqio_sem);
318+
if (alloc)
319+
up_write(&dqopt->dqio_sem);
309320
return ret;
310321
}
311322

0 commit comments

Comments
 (0)