Skip to content

Commit 8fc32c2

Browse files
committed
quota: Push dqio_sem down to ->write_dqblk()
Push down acquisition of dqio_sem into ->write_dqblk() callback. It will allow quota formats to decide whether they need it or not. Reviewed-by: Andreas Dilger <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 47cdc11 commit 8fc32c2

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

fs/quota/dquot.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,14 @@ int dquot_acquire(struct dquot *dquot)
412412
set_bit(DQ_READ_B, &dquot->dq_flags);
413413
/* Instantiate dquot if needed */
414414
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
415-
down_write(&dqopt->dqio_sem);
416415
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
417416
/* Write the info if needed */
418417
if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
418+
down_write(&dqopt->dqio_sem);
419419
ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
420420
dquot->dq_sb, dquot->dq_id.type);
421+
up_write(&dqopt->dqio_sem);
421422
}
422-
up_write(&dqopt->dqio_sem);
423423
if (ret < 0)
424424
goto out_iolock;
425425
if (ret2 < 0) {
@@ -456,13 +456,10 @@ int dquot_commit(struct dquot *dquot)
456456
spin_unlock(&dq_list_lock);
457457
/* Inactive dquot can be only if there was error during read/init
458458
* => we have better not writing it */
459-
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
460-
down_write(&dqopt->dqio_sem);
459+
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
461460
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
462-
up_write(&dqopt->dqio_sem);
463-
} else {
461+
else
464462
ret = -EIO;
465-
}
466463
out_lock:
467464
mutex_unlock(&dquot->dq_lock);
468465
return ret;

fs/quota/quota_v1.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ static int v1_commit_dqblk(struct dquot *dquot)
8383
short type = dquot->dq_id.type;
8484
ssize_t ret;
8585
struct v1_disk_dqblk dqblk;
86+
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
8687

88+
down_write(&dqopt->dqio_sem);
8789
v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb);
8890
if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) ||
8991
((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) {
@@ -97,6 +99,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
9799
ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
98100
(char *)&dqblk, sizeof(struct v1_disk_dqblk),
99101
v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
102+
up_write(&dqopt->dqio_sem);
100103
if (ret != sizeof(struct v1_disk_dqblk)) {
101104
quota_error(dquot->dq_sb, "dquota write failed");
102105
if (ret >= 0)

fs/quota/quota_v2.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,15 @@ static int v2_read_dquot(struct dquot *dquot)
298298

299299
static int v2_write_dquot(struct dquot *dquot)
300300
{
301-
return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
301+
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
302+
int ret;
303+
304+
down_write(&dqopt->dqio_sem);
305+
ret = qtree_write_dquot(
306+
sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
307+
dquot);
308+
up_write(&dqopt->dqio_sem);
309+
return ret;
302310
}
303311

304312
static int v2_release_dquot(struct dquot *dquot)

0 commit comments

Comments
 (0)