summaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-06-08 09:48:16 -0400
committerJan Kara <jack@suse.cz>2017-08-17 13:03:09 -0400
commit8fc32c2b0db2c9ee0dffebea65bcdea03a29ba5a (patch)
tree1ad92b623f562ac9f160fb4ea8e4c9073d2cb4f5 /fs/quota
parent47cdc11deed639ae1d4050efbc284d328c3c2fa5 (diff)
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 <adilger@dilger.ca> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/dquot.c11
-rw-r--r--fs/quota/quota_v1.c3
-rw-r--r--fs/quota/quota_v2.c10
3 files changed, 16 insertions, 8 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 46046523abf0..562f5978488f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -412,14 +412,14 @@ int dquot_acquire(struct dquot *dquot)
412 set_bit(DQ_READ_B, &dquot->dq_flags); 412 set_bit(DQ_READ_B, &dquot->dq_flags);
413 /* Instantiate dquot if needed */ 413 /* Instantiate dquot if needed */
414 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { 414 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
415 down_write(&dqopt->dqio_sem);
416 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); 415 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
417 /* Write the info if needed */ 416 /* Write the info if needed */
418 if (info_dirty(&dqopt->info[dquot->dq_id.type])) { 417 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
418 down_write(&dqopt->dqio_sem);
419 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info( 419 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
420 dquot->dq_sb, dquot->dq_id.type); 420 dquot->dq_sb, dquot->dq_id.type);
421 up_write(&dqopt->dqio_sem);
421 } 422 }
422 up_write(&dqopt->dqio_sem);
423 if (ret < 0) 423 if (ret < 0)
424 goto out_iolock; 424 goto out_iolock;
425 if (ret2 < 0) { 425 if (ret2 < 0) {
@@ -456,13 +456,10 @@ int dquot_commit(struct dquot *dquot)
456 spin_unlock(&dq_list_lock); 456 spin_unlock(&dq_list_lock);
457 /* Inactive dquot can be only if there was error during read/init 457 /* Inactive dquot can be only if there was error during read/init
458 * => we have better not writing it */ 458 * => we have better not writing it */
459 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { 459 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
460 down_write(&dqopt->dqio_sem);
461 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); 460 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
462 up_write(&dqopt->dqio_sem); 461 else
463 } else {
464 ret = -EIO; 462 ret = -EIO;
465 }
466out_lock: 463out_lock:
467 mutex_unlock(&dquot->dq_lock); 464 mutex_unlock(&dquot->dq_lock);
468 return ret; 465 return ret;
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
index 12d69cda57cc..94cceb76b9a3 100644
--- a/fs/quota/quota_v1.c
+++ b/fs/quota/quota_v1.c
@@ -83,7 +83,9 @@ static int v1_commit_dqblk(struct dquot *dquot)
83 short type = dquot->dq_id.type; 83 short type = dquot->dq_id.type;
84 ssize_t ret; 84 ssize_t ret;
85 struct v1_disk_dqblk dqblk; 85 struct v1_disk_dqblk dqblk;
86 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
86 87
88 down_write(&dqopt->dqio_sem);
87 v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb); 89 v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb);
88 if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) || 90 if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) ||
89 ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) { 91 ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) {
@@ -97,6 +99,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
97 ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type, 99 ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
98 (char *)&dqblk, sizeof(struct v1_disk_dqblk), 100 (char *)&dqblk, sizeof(struct v1_disk_dqblk),
99 v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id))); 101 v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
102 up_write(&dqopt->dqio_sem);
100 if (ret != sizeof(struct v1_disk_dqblk)) { 103 if (ret != sizeof(struct v1_disk_dqblk)) {
101 quota_error(dquot->dq_sb, "dquota write failed"); 104 quota_error(dquot->dq_sb, "dquota write failed");
102 if (ret >= 0) 105 if (ret >= 0)
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index b2cd34f6b3da..482733abe4ac 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -298,7 +298,15 @@ static int v2_read_dquot(struct dquot *dquot)
298 298
299static int v2_write_dquot(struct dquot *dquot) 299static int v2_write_dquot(struct dquot *dquot)
300{ 300{
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;
302} 310}
303 311
304static int v2_release_dquot(struct dquot *dquot) 312static int v2_release_dquot(struct dquot *dquot)