diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-02-16 03:44:52 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:24 -0500 |
commit | 5fb324ad24febe57a8a2e62903dcb7bad546ea71 (patch) | |
tree | f49d1b8b7fe9feffbdd1afba18047001f5d7228f | |
parent | 8c4e4acd660a09e571a71583b5bbe1eee700c9ad (diff) |
quota: move code from sync_quota_sb into vfs_quota_sync
Currenly sync_quota_sb does a lot of sync and truncate action that only
applies to "VFS" style quotas and is actively harmful for the sync
performance in XFS. Move it into vfs_quota_sync and add a wait parameter
to ->quota_sync to tell if we need it or not.
My audit of the GFS2 code says it's also not needed given the way GFS2
implements quotas, but I'd be happy if this can get a detailed review.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/gfs2/quota.c | 9 | ||||
-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 | 29 | ||||
-rw-r--r-- | fs/quota/quota.c | 46 | ||||
-rw-r--r-- | fs/sync.c | 14 | ||||
-rw-r--r-- | include/linux/quota.h | 2 | ||||
-rw-r--r-- | include/linux/quotaops.h | 17 |
9 files changed, 52 insertions, 71 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index e3bf6eab8750..6dbcbad6ab17 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -1083,7 +1083,7 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | |||
1083 | } | 1083 | } |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | int gfs2_quota_sync(struct super_block *sb, int type) | 1086 | int gfs2_quota_sync(struct super_block *sb, int type, int wait) |
1087 | { | 1087 | { |
1088 | struct gfs2_sbd *sdp = sb->s_fs_info; | 1088 | struct gfs2_sbd *sdp = sb->s_fs_info; |
1089 | struct gfs2_quota_data **qda; | 1089 | struct gfs2_quota_data **qda; |
@@ -1127,6 +1127,11 @@ int gfs2_quota_sync(struct super_block *sb, int type) | |||
1127 | return error; | 1127 | return error; |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | static int gfs2_quota_sync_timeo(struct super_block *sb, int type) | ||
1131 | { | ||
1132 | return gfs2_quota_sync(sb, type, 0); | ||
1133 | } | ||
1134 | |||
1130 | int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id) | 1135 | int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id) |
1131 | { | 1136 | { |
1132 | struct gfs2_quota_data *qd; | 1137 | struct gfs2_quota_data *qd; |
@@ -1382,7 +1387,7 @@ int gfs2_quotad(void *data) | |||
1382 | &tune->gt_statfs_quantum); | 1387 | &tune->gt_statfs_quantum); |
1383 | 1388 | ||
1384 | /* Update quota file */ | 1389 | /* Update quota file */ |
1385 | quotad_check_timeo(sdp, "sync", gfs2_quota_sync, t, | 1390 | quotad_check_timeo(sdp, "sync", gfs2_quota_sync_timeo, t, |
1386 | "ad_timeo, &tune->gt_quota_quantum); | 1391 | "ad_timeo, &tune->gt_quota_quantum); |
1387 | 1392 | ||
1388 | /* Check for & recover partially truncated inodes */ | 1393 | /* Check for & recover partially truncated inodes */ |
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index e271fa07ad02..195f60c8bd14 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h | |||
@@ -25,7 +25,7 @@ extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid); | |||
25 | extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | 25 | extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change, |
26 | u32 uid, u32 gid); | 26 | u32 uid, u32 gid); |
27 | 27 | ||
28 | extern int gfs2_quota_sync(struct super_block *sb, int type); | 28 | extern int gfs2_quota_sync(struct super_block *sb, int type, int wait); |
29 | extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id); | 29 | extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id); |
30 | 30 | ||
31 | extern int gfs2_quota_init(struct gfs2_sbd *sdp); | 31 | extern int gfs2_quota_init(struct gfs2_sbd *sdp); |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index b9dd3da22c0a..a8c2bcd0fcc8 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -764,7 +764,7 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp) | |||
764 | int error; | 764 | int error; |
765 | 765 | ||
766 | flush_workqueue(gfs2_delete_workqueue); | 766 | flush_workqueue(gfs2_delete_workqueue); |
767 | gfs2_quota_sync(sdp->sd_vfs, 0); | 767 | gfs2_quota_sync(sdp->sd_vfs, 0, 1); |
768 | gfs2_statfs_sync(sdp->sd_vfs, 0); | 768 | gfs2_statfs_sync(sdp->sd_vfs, 0); |
769 | 769 | ||
770 | error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE, | 770 | 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 0dc34621f6a6..4496cc37a0fa 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -167,7 +167,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, | |||
167 | if (simple_strtol(buf, NULL, 0) != 1) | 167 | if (simple_strtol(buf, NULL, 0) != 1) |
168 | return -EINVAL; | 168 | return -EINVAL; |
169 | 169 | ||
170 | gfs2_quota_sync(sdp->sd_vfs, 0); | 170 | gfs2_quota_sync(sdp->sd_vfs, 0, 1); |
171 | return len; | 171 | return len; |
172 | } | 172 | } |
173 | 173 | ||
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 6c849de5dc8f..4c2213f7ed36 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -570,7 +570,7 @@ out: | |||
570 | } | 570 | } |
571 | EXPORT_SYMBOL(dquot_scan_active); | 571 | EXPORT_SYMBOL(dquot_scan_active); |
572 | 572 | ||
573 | int vfs_quota_sync(struct super_block *sb, int type) | 573 | int vfs_quota_sync(struct super_block *sb, int type, int wait) |
574 | { | 574 | { |
575 | struct list_head *dirty; | 575 | struct list_head *dirty; |
576 | struct dquot *dquot; | 576 | struct dquot *dquot; |
@@ -615,6 +615,33 @@ int vfs_quota_sync(struct super_block *sb, int type) | |||
615 | spin_unlock(&dq_list_lock); | 615 | spin_unlock(&dq_list_lock); |
616 | mutex_unlock(&dqopt->dqonoff_mutex); | 616 | mutex_unlock(&dqopt->dqonoff_mutex); |
617 | 617 | ||
618 | if (!wait || (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE)) | ||
619 | return 0; | ||
620 | |||
621 | /* This is not very clever (and fast) but currently I don't know about | ||
622 | * any other simple way of getting quota data to disk and we must get | ||
623 | * them there for userspace to be visible... */ | ||
624 | if (sb->s_op->sync_fs) | ||
625 | sb->s_op->sync_fs(sb, 1); | ||
626 | sync_blockdev(sb->s_bdev); | ||
627 | |||
628 | /* | ||
629 | * Now when everything is written we can discard the pagecache so | ||
630 | * that userspace sees the changes. | ||
631 | */ | ||
632 | mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); | ||
633 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
634 | if (type != -1 && cnt != type) | ||
635 | continue; | ||
636 | if (!sb_has_quota_active(sb, cnt)) | ||
637 | continue; | ||
638 | mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, | ||
639 | I_MUTEX_QUOTA); | ||
640 | truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0); | ||
641 | mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex); | ||
642 | } | ||
643 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); | ||
644 | |||
618 | return 0; | 645 | return 0; |
619 | } | 646 | } |
620 | EXPORT_SYMBOL(vfs_quota_sync); | 647 | EXPORT_SYMBOL(vfs_quota_sync); |
diff --git a/fs/quota/quota.c b/fs/quota/quota.c index 3d31228082ea..0593b229656c 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c | |||
@@ -48,44 +48,6 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd, | |||
48 | return security_quotactl(cmd, type, id, sb); | 48 | return security_quotactl(cmd, type, id, sb); |
49 | } | 49 | } |
50 | 50 | ||
51 | #ifdef CONFIG_QUOTA | ||
52 | void sync_quota_sb(struct super_block *sb, int type) | ||
53 | { | ||
54 | int cnt; | ||
55 | |||
56 | if (!sb->s_qcop || !sb->s_qcop->quota_sync) | ||
57 | return; | ||
58 | |||
59 | sb->s_qcop->quota_sync(sb, type); | ||
60 | |||
61 | if (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE) | ||
62 | return; | ||
63 | /* This is not very clever (and fast) but currently I don't know about | ||
64 | * any other simple way of getting quota data to disk and we must get | ||
65 | * them there for userspace to be visible... */ | ||
66 | if (sb->s_op->sync_fs) | ||
67 | sb->s_op->sync_fs(sb, 1); | ||
68 | sync_blockdev(sb->s_bdev); | ||
69 | |||
70 | /* | ||
71 | * Now when everything is written we can discard the pagecache so | ||
72 | * that userspace sees the changes. | ||
73 | */ | ||
74 | mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); | ||
75 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
76 | if (type != -1 && cnt != type) | ||
77 | continue; | ||
78 | if (!sb_has_quota_active(sb, cnt)) | ||
79 | continue; | ||
80 | mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, | ||
81 | I_MUTEX_QUOTA); | ||
82 | truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0); | ||
83 | mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex); | ||
84 | } | ||
85 | mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); | ||
86 | } | ||
87 | #endif | ||
88 | |||
89 | static int quota_sync_all(int type) | 51 | static int quota_sync_all(int type) |
90 | { | 52 | { |
91 | struct super_block *sb; | 53 | struct super_block *sb; |
@@ -101,6 +63,9 @@ static int quota_sync_all(int type) | |||
101 | spin_lock(&sb_lock); | 63 | spin_lock(&sb_lock); |
102 | restart: | 64 | restart: |
103 | list_for_each_entry(sb, &super_blocks, s_list) { | 65 | list_for_each_entry(sb, &super_blocks, s_list) { |
66 | if (!sb->s_qcop || !sb->s_qcop->quota_sync) | ||
67 | continue; | ||
68 | |||
104 | /* This test just improves performance so it needn't be | 69 | /* This test just improves performance so it needn't be |
105 | * reliable... */ | 70 | * reliable... */ |
106 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 71 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
@@ -119,7 +84,7 @@ restart: | |||
119 | spin_unlock(&sb_lock); | 84 | spin_unlock(&sb_lock); |
120 | down_read(&sb->s_umount); | 85 | down_read(&sb->s_umount); |
121 | if (sb->s_root) | 86 | if (sb->s_root) |
122 | sync_quota_sb(sb, type); | 87 | sb->s_qcop->quota_sync(sb, type, 1); |
123 | up_read(&sb->s_umount); | 88 | up_read(&sb->s_umount); |
124 | spin_lock(&sb_lock); | 89 | spin_lock(&sb_lock); |
125 | if (__put_super_and_need_restart(sb)) | 90 | if (__put_super_and_need_restart(sb)) |
@@ -306,8 +271,7 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, | |||
306 | case Q_SYNC: | 271 | case Q_SYNC: |
307 | if (!sb->s_qcop->quota_sync) | 272 | if (!sb->s_qcop->quota_sync) |
308 | return -ENOSYS; | 273 | return -ENOSYS; |
309 | sync_quota_sb(sb, type); | 274 | return sb->s_qcop->quota_sync(sb, type, 1); |
310 | return 0; | ||
311 | case Q_XQUOTAON: | 275 | case Q_XQUOTAON: |
312 | case Q_XQUOTAOFF: | 276 | case Q_XQUOTAOFF: |
313 | case Q_XQUOTARM: | 277 | case Q_XQUOTARM: |
@@ -34,14 +34,14 @@ static int __sync_filesystem(struct super_block *sb, int wait) | |||
34 | if (!sb->s_bdi) | 34 | if (!sb->s_bdi) |
35 | return 0; | 35 | return 0; |
36 | 36 | ||
37 | /* Avoid doing twice syncing and cache pruning for quota sync */ | 37 | if (sb->s_qcop && sb->s_qcop->quota_sync) |
38 | if (!wait) { | 38 | sb->s_qcop->quota_sync(sb, -1, wait); |
39 | writeout_quota_sb(sb, -1); | 39 | |
40 | writeback_inodes_sb(sb); | 40 | if (wait) |
41 | } else { | ||
42 | sync_quota_sb(sb, -1); | ||
43 | sync_inodes_sb(sb); | 41 | sync_inodes_sb(sb); |
44 | } | 42 | else |
43 | writeback_inodes_sb(sb); | ||
44 | |||
45 | if (sb->s_op->sync_fs) | 45 | if (sb->s_op->sync_fs) |
46 | sb->s_op->sync_fs(sb, wait); | 46 | sb->s_op->sync_fs(sb, wait); |
47 | return __sync_blockdev(sb->s_bdev, wait); | 47 | return __sync_blockdev(sb->s_bdev, wait); |
diff --git a/include/linux/quota.h b/include/linux/quota.h index a6861f117480..570348cbccb1 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
@@ -324,7 +324,7 @@ struct dquot_operations { | |||
324 | struct quotactl_ops { | 324 | struct quotactl_ops { |
325 | int (*quota_on)(struct super_block *, int, int, char *, int); | 325 | int (*quota_on)(struct super_block *, int, int, char *, int); |
326 | int (*quota_off)(struct super_block *, int, int); | 326 | int (*quota_off)(struct super_block *, int, int); |
327 | int (*quota_sync)(struct super_block *, int); | 327 | int (*quota_sync)(struct super_block *, int, int); |
328 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); | 328 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); |
329 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); | 329 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); |
330 | int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); | 330 | int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); |
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 69d26bc0f884..8cfd0d44c994 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -19,13 +19,6 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb) | |||
19 | /* | 19 | /* |
20 | * declaration of quota_function calls in kernel. | 20 | * declaration of quota_function calls in kernel. |
21 | */ | 21 | */ |
22 | void sync_quota_sb(struct super_block *sb, int type); | ||
23 | static inline void writeout_quota_sb(struct super_block *sb, int type) | ||
24 | { | ||
25 | if (sb->s_qcop && sb->s_qcop->quota_sync) | ||
26 | sb->s_qcop->quota_sync(sb, type); | ||
27 | } | ||
28 | |||
29 | void inode_add_rsv_space(struct inode *inode, qsize_t number); | 22 | void inode_add_rsv_space(struct inode *inode, qsize_t number); |
30 | void inode_claim_rsv_space(struct inode *inode, qsize_t number); | 23 | void inode_claim_rsv_space(struct inode *inode, qsize_t number); |
31 | void inode_sub_rsv_space(struct inode *inode, qsize_t number); | 24 | void inode_sub_rsv_space(struct inode *inode, qsize_t number); |
@@ -67,7 +60,7 @@ int vfs_quota_on_mount(struct super_block *sb, char *qf_name, | |||
67 | int format_id, int type); | 60 | int format_id, int type); |
68 | int vfs_quota_off(struct super_block *sb, int type, int remount); | 61 | int vfs_quota_off(struct super_block *sb, int type, int remount); |
69 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); | 62 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); |
70 | int vfs_quota_sync(struct super_block *sb, int type); | 63 | int vfs_quota_sync(struct super_block *sb, int type, int wait); |
71 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 64 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
72 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 65 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
73 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 66 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); |
@@ -340,14 +333,6 @@ static inline void vfs_dq_free_inode(struct inode *inode) | |||
340 | { | 333 | { |
341 | } | 334 | } |
342 | 335 | ||
343 | static inline void sync_quota_sb(struct super_block *sb, int type) | ||
344 | { | ||
345 | } | ||
346 | |||
347 | static inline void writeout_quota_sb(struct super_block *sb, int type) | ||
348 | { | ||
349 | } | ||
350 | |||
351 | static inline int vfs_dq_off(struct super_block *sb, int remount) | 336 | static inline int vfs_dq_off(struct super_block *sb, int remount) |
352 | { | 337 | { |
353 | return 0; | 338 | return 0; |