aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-07-03 10:45:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-22 15:58:19 -0400
commitceed17236a7491b44ee2be21f56a41ab997cbe7d (patch)
treed3204566d1a2efb4b927de039044881e16d30c2d /fs/quota
parent6eedc70150d55b5885800eb6664ea226dc2cb66f (diff)
quota: Split dquot_quota_sync() to writeback and cache flushing part
Split off part of dquot_quota_sync() which writes dquots into a quota file to a separate function. In the next patch we will use the function from filesystems and we do not want to abuse ->quota_sync quotactl callback more than necessary. Acked-by: Steven Whitehouse <swhiteho@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/dquot.c24
-rw-r--r--fs/quota/quota.c4
2 files changed, 23 insertions, 5 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 10cbe841cb7..d679fc48ef2 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -595,12 +595,14 @@ out:
595} 595}
596EXPORT_SYMBOL(dquot_scan_active); 596EXPORT_SYMBOL(dquot_scan_active);
597 597
598int dquot_quota_sync(struct super_block *sb, int type, int wait) 598/* Write all dquot structures to quota files */
599int dquot_writeback_dquots(struct super_block *sb, int type)
599{ 600{
600 struct list_head *dirty; 601 struct list_head *dirty;
601 struct dquot *dquot; 602 struct dquot *dquot;
602 struct quota_info *dqopt = sb_dqopt(sb); 603 struct quota_info *dqopt = sb_dqopt(sb);
603 int cnt; 604 int cnt;
605 int err, ret = 0;
604 606
605 mutex_lock(&dqopt->dqonoff_mutex); 607 mutex_lock(&dqopt->dqonoff_mutex);
606 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 608 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
@@ -624,7 +626,9 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
624 atomic_inc(&dquot->dq_count); 626 atomic_inc(&dquot->dq_count);
625 spin_unlock(&dq_list_lock); 627 spin_unlock(&dq_list_lock);
626 dqstats_inc(DQST_LOOKUPS); 628 dqstats_inc(DQST_LOOKUPS);
627 sb->dq_op->write_dquot(dquot); 629 err = sb->dq_op->write_dquot(dquot);
630 if (!ret && err)
631 err = ret;
628 dqput(dquot); 632 dqput(dquot);
629 spin_lock(&dq_list_lock); 633 spin_lock(&dq_list_lock);
630 } 634 }
@@ -638,7 +642,21 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
638 dqstats_inc(DQST_SYNCS); 642 dqstats_inc(DQST_SYNCS);
639 mutex_unlock(&dqopt->dqonoff_mutex); 643 mutex_unlock(&dqopt->dqonoff_mutex);
640 644
641 if (!wait || (dqopt->flags & DQUOT_QUOTA_SYS_FILE)) 645 return ret;
646}
647EXPORT_SYMBOL(dquot_writeback_dquots);
648
649/* Write all dquot structures to disk and make them visible from userspace */
650int dquot_quota_sync(struct super_block *sb, int type)
651{
652 struct quota_info *dqopt = sb_dqopt(sb);
653 int cnt;
654 int ret;
655
656 ret = dquot_writeback_dquots(sb, type);
657 if (ret)
658 return ret;
659 if (dqopt->flags & DQUOT_QUOTA_SYS_FILE)
642 return 0; 660 return 0;
643 661
644 /* This is not very clever (and fast) but currently I don't know about 662 /* This is not very clever (and fast) but currently I don't know about
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 9a391204ca2..c659f92298d 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -47,7 +47,7 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd,
47static void quota_sync_one(struct super_block *sb, void *arg) 47static void quota_sync_one(struct super_block *sb, void *arg)
48{ 48{
49 if (sb->s_qcop && sb->s_qcop->quota_sync) 49 if (sb->s_qcop && sb->s_qcop->quota_sync)
50 sb->s_qcop->quota_sync(sb, *(int *)arg, 1); 50 sb->s_qcop->quota_sync(sb, *(int *)arg);
51} 51}
52 52
53static int quota_sync_all(int type) 53static int quota_sync_all(int type)
@@ -270,7 +270,7 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
270 case Q_SYNC: 270 case Q_SYNC:
271 if (!sb->s_qcop->quota_sync) 271 if (!sb->s_qcop->quota_sync)
272 return -ENOSYS; 272 return -ENOSYS;
273 return sb->s_qcop->quota_sync(sb, type, 1); 273 return sb->s_qcop->quota_sync(sb, type);
274 case Q_XQUOTAON: 274 case Q_XQUOTAON:
275 case Q_XQUOTAOFF: 275 case Q_XQUOTAOFF:
276 case Q_XQUOTARM: 276 case Q_XQUOTARM: