diff options
| author | Jan Kara <jack@suse.cz> | 2012-07-03 10:45:28 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-22 15:58:19 -0400 |
| commit | ceed17236a7491b44ee2be21f56a41ab997cbe7d (patch) | |
| tree | d3204566d1a2efb4b927de039044881e16d30c2d /fs | |
| parent | 6eedc70150d55b5885800eb6664ea226dc2cb66f (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')
| -rw-r--r-- | fs/gfs2/quota.c | 4 | ||||
| -rw-r--r-- | fs/gfs2/quota.h | 2 | ||||
| -rw-r--r-- | fs/gfs2/super.c | 2 | ||||
| -rw-r--r-- | fs/gfs2/sys.c | 2 | ||||
| -rw-r--r-- | fs/quota/dquot.c | 24 | ||||
| -rw-r--r-- | fs/quota/quota.c | 4 | ||||
| -rw-r--r-- | fs/sync.c | 2 |
7 files changed, 29 insertions, 11 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index b97178e7d397..27b5cc7d6881 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
| @@ -1108,7 +1108,7 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | |||
| 1108 | } | 1108 | } |
| 1109 | } | 1109 | } |
| 1110 | 1110 | ||
| 1111 | int gfs2_quota_sync(struct super_block *sb, int type, int wait) | 1111 | int gfs2_quota_sync(struct super_block *sb, int type) |
| 1112 | { | 1112 | { |
| 1113 | struct gfs2_sbd *sdp = sb->s_fs_info; | 1113 | struct gfs2_sbd *sdp = sb->s_fs_info; |
| 1114 | struct gfs2_quota_data **qda; | 1114 | struct gfs2_quota_data **qda; |
| @@ -1154,7 +1154,7 @@ int gfs2_quota_sync(struct super_block *sb, int type, int wait) | |||
| 1154 | 1154 | ||
| 1155 | static int gfs2_quota_sync_timeo(struct super_block *sb, int type) | 1155 | static int gfs2_quota_sync_timeo(struct super_block *sb, int type) |
| 1156 | { | 1156 | { |
| 1157 | return gfs2_quota_sync(sb, type, 0); | 1157 | return gfs2_quota_sync(sb, type); |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| 1160 | int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id) | 1160 | int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id) |
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index 90bf1c302a98..f25d98b87904 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h | |||
| @@ -26,7 +26,7 @@ extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid); | |||
| 26 | extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | 26 | extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change, |
| 27 | u32 uid, u32 gid); | 27 | u32 uid, u32 gid); |
| 28 | 28 | ||
| 29 | extern int gfs2_quota_sync(struct super_block *sb, int type, int wait); | 29 | extern int gfs2_quota_sync(struct super_block *sb, int type); |
| 30 | extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id); | 30 | extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id); |
| 31 | 31 | ||
| 32 | extern int gfs2_quota_init(struct gfs2_sbd *sdp); | 32 | extern int gfs2_quota_init(struct gfs2_sbd *sdp); |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 713e621c240b..313c329490e2 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
| @@ -838,7 +838,7 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp) | |||
| 838 | int error; | 838 | int error; |
| 839 | 839 | ||
| 840 | flush_workqueue(gfs2_delete_workqueue); | 840 | flush_workqueue(gfs2_delete_workqueue); |
| 841 | gfs2_quota_sync(sdp->sd_vfs, 0, 1); | 841 | gfs2_quota_sync(sdp->sd_vfs, 0); |
| 842 | gfs2_statfs_sync(sdp->sd_vfs, 0); | 842 | gfs2_statfs_sync(sdp->sd_vfs, 0); |
| 843 | 843 | ||
| 844 | error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE, | 844 | error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE, |
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 9c2592b1d5ff..73ecc34c4342 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
| @@ -168,7 +168,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, | |||
| 168 | if (simple_strtol(buf, NULL, 0) != 1) | 168 | if (simple_strtol(buf, NULL, 0) != 1) |
| 169 | return -EINVAL; | 169 | return -EINVAL; |
| 170 | 170 | ||
| 171 | gfs2_quota_sync(sdp->sd_vfs, 0, 1); | 171 | gfs2_quota_sync(sdp->sd_vfs, 0); |
| 172 | return len; | 172 | return len; |
| 173 | } | 173 | } |
| 174 | 174 | ||
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 10cbe841cb7e..d679fc48ef27 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
| @@ -595,12 +595,14 @@ out: | |||
| 595 | } | 595 | } |
| 596 | EXPORT_SYMBOL(dquot_scan_active); | 596 | EXPORT_SYMBOL(dquot_scan_active); |
| 597 | 597 | ||
| 598 | int dquot_quota_sync(struct super_block *sb, int type, int wait) | 598 | /* Write all dquot structures to quota files */ |
| 599 | int 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 | } | ||
| 647 | EXPORT_SYMBOL(dquot_writeback_dquots); | ||
| 648 | |||
| 649 | /* Write all dquot structures to disk and make them visible from userspace */ | ||
| 650 | int 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 9a391204ca27..c659f92298d3 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, | |||
| 47 | static void quota_sync_one(struct super_block *sb, void *arg) | 47 | static 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 | ||
| 53 | static int quota_sync_all(int type) | 53 | static 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: |
| @@ -30,7 +30,7 @@ | |||
| 30 | static int __sync_filesystem(struct super_block *sb, int wait) | 30 | static int __sync_filesystem(struct super_block *sb, int wait) |
| 31 | { | 31 | { |
| 32 | if (sb->s_qcop && sb->s_qcop->quota_sync) | 32 | if (sb->s_qcop && sb->s_qcop->quota_sync) |
| 33 | sb->s_qcop->quota_sync(sb, -1, wait); | 33 | sb->s_qcop->quota_sync(sb, -1); |
| 34 | 34 | ||
| 35 | if (wait) | 35 | if (wait) |
| 36 | sync_inodes_sb(sb); | 36 | sync_inodes_sb(sb); |
