aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_qm.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-03-13 04:52:37 -0400
committerBen Myers <bpm@sgi.com>2012-03-14 13:06:32 -0400
commita05931ceb0160deadbd7798d60d01b17f2d81b09 (patch)
treeca56811415e970149cc99b8b7f6ec9a4677d6025 /fs/xfs/xfs_qm.c
parentb84a3a96751f93071c1863f2962273973c8b8f5e (diff)
xfs: remove the global xfs_Gqm structure
If we initialize the slab caches for the quota code when XFS is loaded there is no need for a global and reference counted quota manager structure. Drop all this overhead and also fix the error handling during quota initialization. Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_qm.c')
-rw-r--r--fs/xfs/xfs_qm.c132
1 files changed, 0 insertions, 132 deletions
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 2f92d3b0d8a8..55c6afedc879 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -48,127 +48,11 @@
48 * quota functionality, including maintaining the freelist and hash 48 * quota functionality, including maintaining the freelist and hash
49 * tables of dquots. 49 * tables of dquots.
50 */ 50 */
51struct mutex xfs_Gqm_lock;
52struct xfs_qm *xfs_Gqm;
53
54kmem_zone_t *qm_dqzone;
55kmem_zone_t *qm_dqtrxzone;
56
57STATIC int xfs_qm_init_quotainos(xfs_mount_t *); 51STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
58STATIC int xfs_qm_init_quotainfo(xfs_mount_t *); 52STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
59STATIC int xfs_qm_shake(struct shrinker *, struct shrink_control *); 53STATIC int xfs_qm_shake(struct shrinker *, struct shrink_control *);
60 54
61/* 55/*
62 * Initialize the XQM structure.
63 * Note that there is not one quota manager per file system.
64 */
65STATIC struct xfs_qm *
66xfs_Gqm_init(void)
67{
68 xfs_qm_t *xqm;
69
70 xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
71
72 /*
73 * dquot zone. we register our own low-memory callback.
74 */
75 if (!qm_dqzone) {
76 xqm->qm_dqzone = kmem_zone_init(sizeof(xfs_dquot_t),
77 "xfs_dquots");
78 qm_dqzone = xqm->qm_dqzone;
79 } else
80 xqm->qm_dqzone = qm_dqzone;
81
82 /*
83 * The t_dqinfo portion of transactions.
84 */
85 if (!qm_dqtrxzone) {
86 xqm->qm_dqtrxzone = kmem_zone_init(sizeof(xfs_dquot_acct_t),
87 "xfs_dqtrx");
88 qm_dqtrxzone = xqm->qm_dqtrxzone;
89 } else
90 xqm->qm_dqtrxzone = qm_dqtrxzone;
91
92 xqm->qm_nrefs = 0;
93 return xqm;
94}
95
96/*
97 * Destroy the global quota manager when its reference count goes to zero.
98 */
99STATIC void
100xfs_qm_destroy(
101 struct xfs_qm *xqm)
102{
103 ASSERT(xqm != NULL);
104 ASSERT(xqm->qm_nrefs == 0);
105
106 kmem_free(xqm);
107}
108
109/*
110 * Called at mount time to let XQM know that another file system is
111 * starting quotas. This isn't crucial information as the individual mount
112 * structures are pretty independent, but it helps the XQM keep a
113 * global view of what's going on.
114 */
115/* ARGSUSED */
116STATIC int
117xfs_qm_hold_quotafs_ref(
118 struct xfs_mount *mp)
119{
120 /*
121 * Need to lock the xfs_Gqm structure for things like this. For example,
122 * the structure could disappear between the entry to this routine and
123 * a HOLD operation if not locked.
124 */
125 mutex_lock(&xfs_Gqm_lock);
126
127 if (!xfs_Gqm) {
128 xfs_Gqm = xfs_Gqm_init();
129 if (!xfs_Gqm) {
130 mutex_unlock(&xfs_Gqm_lock);
131 return ENOMEM;
132 }
133 }
134
135 /*
136 * We can keep a list of all filesystems with quotas mounted for
137 * debugging and statistical purposes, but ...
138 * Just take a reference and get out.
139 */
140 xfs_Gqm->qm_nrefs++;
141 mutex_unlock(&xfs_Gqm_lock);
142
143 return 0;
144}
145
146
147/*
148 * Release the reference that a filesystem took at mount time,
149 * so that we know when we need to destroy the entire quota manager.
150 */
151/* ARGSUSED */
152STATIC void
153xfs_qm_rele_quotafs_ref(
154 struct xfs_mount *mp)
155{
156 ASSERT(xfs_Gqm);
157 ASSERT(xfs_Gqm->qm_nrefs > 0);
158
159 /*
160 * Destroy the entire XQM. If somebody mounts with quotaon, this'll
161 * be restarted.
162 */
163 mutex_lock(&xfs_Gqm_lock);
164 if (--xfs_Gqm->qm_nrefs == 0) {
165 xfs_qm_destroy(xfs_Gqm);
166 xfs_Gqm = NULL;
167 }
168 mutex_unlock(&xfs_Gqm_lock);
169}
170
171/*
172 * We use the batch lookup interface to iterate over the dquots as it 56 * We use the batch lookup interface to iterate over the dquots as it
173 * currently is the only interface into the radix tree code that allows 57 * currently is the only interface into the radix tree code that allows
174 * fuzzy lookups instead of exact matches. Holding the lock over multiple 58 * fuzzy lookups instead of exact matches. Holding the lock over multiple
@@ -738,13 +622,6 @@ xfs_qm_init_quotainfo(
738 622
739 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 623 ASSERT(XFS_IS_QUOTA_RUNNING(mp));
740 624
741 /*
742 * Tell XQM that we exist as soon as possible.
743 */
744 if ((error = xfs_qm_hold_quotafs_ref(mp))) {
745 return error;
746 }
747
748 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); 625 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
749 626
750 /* 627 /*
@@ -850,17 +727,9 @@ xfs_qm_destroy_quotainfo(
850 727
851 qi = mp->m_quotainfo; 728 qi = mp->m_quotainfo;
852 ASSERT(qi != NULL); 729 ASSERT(qi != NULL);
853 ASSERT(xfs_Gqm != NULL);
854 730
855 unregister_shrinker(&qi->qi_shrinker); 731 unregister_shrinker(&qi->qi_shrinker);
856 732
857 /*
858 * Release the reference that XQM kept, so that we know
859 * when the XQM structure should be freed. We cannot assume
860 * that xfs_Gqm is non-null after this point.
861 */
862 xfs_qm_rele_quotafs_ref(mp);
863
864 if (qi->qi_uquotaip) { 733 if (qi->qi_uquotaip) {
865 IRELE(qi->qi_uquotaip); 734 IRELE(qi->qi_uquotaip);
866 qi->qi_uquotaip = NULL; /* paranoia */ 735 qi->qi_uquotaip = NULL; /* paranoia */
@@ -1447,7 +1316,6 @@ xfs_qm_quotacheck(
1447 * We must turn off quotas. 1316 * We must turn off quotas.
1448 */ 1317 */
1449 ASSERT(mp->m_quotainfo != NULL); 1318 ASSERT(mp->m_quotainfo != NULL);
1450 ASSERT(xfs_Gqm != NULL);
1451 xfs_qm_destroy_quotainfo(mp); 1319 xfs_qm_destroy_quotainfo(mp);
1452 if (xfs_mount_reset_sbqflags(mp)) { 1320 if (xfs_mount_reset_sbqflags(mp)) {
1453 xfs_warn(mp, 1321 xfs_warn(mp,