aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-06-09 02:45:43 -0400
committerJan Kara <jack@suse.cz>2017-08-17 13:11:23 -0400
commit9a8ae30e73cb8827dd0a8ae5fd505db457cfb7ed (patch)
treeebc569647ebbffa64b3cbfe81873a97aacb0c3f7
parentf14618c6823ee0f9f92a87aad7d5ad26916ccff1 (diff)
quota: Push dqio_sem down to ->write_file_info()
Push down acquisition of dqio_sem into ->write_file_info() callback. Mostly for consistency with other operations. Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/ocfs2/quota_global.c8
-rw-r--r--fs/quota/dquot.c10
-rw-r--r--fs/quota/quota_v1.c2
-rw-r--r--fs/quota/quota_v2.c5
4 files changed, 13 insertions, 12 deletions
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index 4134d557a8e5..78f3a869748c 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -443,13 +443,17 @@ static int __ocfs2_global_write_info(struct super_block *sb, int type)
443int ocfs2_global_write_info(struct super_block *sb, int type) 443int ocfs2_global_write_info(struct super_block *sb, int type)
444{ 444{
445 int err; 445 int err;
446 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv; 446 struct quota_info *dqopt = sb_dqopt(sb);
447 struct ocfs2_mem_dqinfo *info = dqopt->info[type].dqi_priv;
447 448
449 down_write(&dqopt->dqio_sem);
448 err = ocfs2_qinfo_lock(info, 1); 450 err = ocfs2_qinfo_lock(info, 1);
449 if (err < 0) 451 if (err < 0)
450 return err; 452 goto out_sem;
451 err = __ocfs2_global_write_info(sb, type); 453 err = __ocfs2_global_write_info(sb, type);
452 ocfs2_qinfo_unlock(info, 1); 454 ocfs2_qinfo_unlock(info, 1);
455out_sem:
456 up_write(&dqopt->dqio_sem);
453 return err; 457 return err;
454} 458}
455 459
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 332f7026edad..1e1ff97098ec 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -415,10 +415,8 @@ int dquot_acquire(struct dquot *dquot)
415 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); 415 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
416 /* Write the info if needed */ 416 /* Write the info if needed */
417 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( 418 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
420 dquot->dq_sb, dquot->dq_id.type); 419 dquot->dq_sb, dquot->dq_id.type);
421 up_write(&dqopt->dqio_sem);
422 } 420 }
423 if (ret < 0) 421 if (ret < 0)
424 goto out_iolock; 422 goto out_iolock;
@@ -482,10 +480,8 @@ int dquot_release(struct dquot *dquot)
482 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot); 480 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
483 /* Write the info */ 481 /* Write the info */
484 if (info_dirty(&dqopt->info[dquot->dq_id.type])) { 482 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
485 down_write(&dqopt->dqio_sem);
486 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info( 483 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
487 dquot->dq_sb, dquot->dq_id.type); 484 dquot->dq_sb, dquot->dq_id.type);
488 up_write(&dqopt->dqio_sem);
489 } 485 }
490 if (ret >= 0) 486 if (ret >= 0)
491 ret = ret2; 487 ret = ret2;
@@ -2054,13 +2050,9 @@ EXPORT_SYMBOL(dquot_transfer);
2054 */ 2050 */
2055int dquot_commit_info(struct super_block *sb, int type) 2051int dquot_commit_info(struct super_block *sb, int type)
2056{ 2052{
2057 int ret;
2058 struct quota_info *dqopt = sb_dqopt(sb); 2053 struct quota_info *dqopt = sb_dqopt(sb);
2059 2054
2060 down_write(&dqopt->dqio_sem); 2055 return dqopt->ops[type]->write_file_info(sb, type);
2061 ret = dqopt->ops[type]->write_file_info(sb, type);
2062 up_write(&dqopt->dqio_sem);
2063 return ret;
2064} 2056}
2065EXPORT_SYMBOL(dquot_commit_info); 2057EXPORT_SYMBOL(dquot_commit_info);
2066 2058
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
index 12d69cda57cc..fe68bf544b29 100644
--- a/fs/quota/quota_v1.c
+++ b/fs/quota/quota_v1.c
@@ -186,6 +186,7 @@ static int v1_write_file_info(struct super_block *sb, int type)
186 struct v1_disk_dqblk dqblk; 186 struct v1_disk_dqblk dqblk;
187 int ret; 187 int ret;
188 188
189 down_write(&dqopt->dqio_sem);
189 dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY; 190 dqopt->info[type].dqi_flags &= ~DQF_INFO_DIRTY;
190 ret = sb->s_op->quota_read(sb, type, (char *)&dqblk, 191 ret = sb->s_op->quota_read(sb, type, (char *)&dqblk,
191 sizeof(struct v1_disk_dqblk), v1_dqoff(0)); 192 sizeof(struct v1_disk_dqblk), v1_dqoff(0));
@@ -203,6 +204,7 @@ static int v1_write_file_info(struct super_block *sb, int type)
203 else if (ret > 0) 204 else if (ret > 0)
204 ret = -EIO; 205 ret = -EIO;
205out: 206out:
207 up_write(&dqopt->dqio_sem);
206 return ret; 208 return ret;
207} 209}
208 210
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index f82638e43c07..5e47012d2f57 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -154,10 +154,12 @@ static int v2_read_file_info(struct super_block *sb, int type)
154static int v2_write_file_info(struct super_block *sb, int type) 154static int v2_write_file_info(struct super_block *sb, int type)
155{ 155{
156 struct v2_disk_dqinfo dinfo; 156 struct v2_disk_dqinfo dinfo;
157 struct mem_dqinfo *info = sb_dqinfo(sb, type); 157 struct quota_info *dqopt = sb_dqopt(sb);
158 struct mem_dqinfo *info = &dqopt->info[type];
158 struct qtree_mem_dqinfo *qinfo = info->dqi_priv; 159 struct qtree_mem_dqinfo *qinfo = info->dqi_priv;
159 ssize_t size; 160 ssize_t size;
160 161
162 down_write(&dqopt->dqio_sem);
161 spin_lock(&dq_data_lock); 163 spin_lock(&dq_data_lock);
162 info->dqi_flags &= ~DQF_INFO_DIRTY; 164 info->dqi_flags &= ~DQF_INFO_DIRTY;
163 dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace); 165 dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace);
@@ -170,6 +172,7 @@ static int v2_write_file_info(struct super_block *sb, int type)
170 dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry); 172 dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry);
171 size = sb->s_op->quota_write(sb, type, (char *)&dinfo, 173 size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
172 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); 174 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
175 up_write(&dqopt->dqio_sem);
173 if (size != sizeof(struct v2_disk_dqinfo)) { 176 if (size != sizeof(struct v2_disk_dqinfo)) {
174 quota_error(sb, "Can't write info structure"); 177 quota_error(sb, "Can't write info structure");
175 return -1; 178 return -1;