diff options
author | Bob Peterson <rpeterso@redhat.com> | 2012-04-11 12:59:32 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2012-04-24 11:44:29 -0400 |
commit | 36f5580be1dde43eb94ce4d58bc20e493be09f09 (patch) | |
tree | 5d8c2ce2b52d4ac806d04611b829e394b4365969 | |
parent | b120193e360f6c22b0c9424c928f2df40ba0ffdb (diff) |
GFS2: Use slab for block reservation memory
This patch changes block reservations so it uses slab storage.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r-- | fs/gfs2/main.c | 10 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 19 | ||||
-rw-r--r-- | fs/gfs2/util.c | 1 | ||||
-rw-r--r-- | fs/gfs2/util.h | 1 |
4 files changed, 23 insertions, 8 deletions
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 754426b1e52c..ce1794428ee4 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
@@ -143,6 +143,12 @@ static int __init init_gfs2_fs(void) | |||
143 | if (!gfs2_quotad_cachep) | 143 | if (!gfs2_quotad_cachep) |
144 | goto fail; | 144 | goto fail; |
145 | 145 | ||
146 | gfs2_rsrv_cachep = kmem_cache_create("gfs2_mblk", | ||
147 | sizeof(struct gfs2_blkreserv), | ||
148 | 0, 0, NULL); | ||
149 | if (!gfs2_rsrv_cachep) | ||
150 | goto fail; | ||
151 | |||
146 | register_shrinker(&qd_shrinker); | 152 | register_shrinker(&qd_shrinker); |
147 | 153 | ||
148 | error = register_filesystem(&gfs2_fs_type); | 154 | error = register_filesystem(&gfs2_fs_type); |
@@ -186,6 +192,9 @@ fail: | |||
186 | unregister_shrinker(&qd_shrinker); | 192 | unregister_shrinker(&qd_shrinker); |
187 | gfs2_glock_exit(); | 193 | gfs2_glock_exit(); |
188 | 194 | ||
195 | if (gfs2_rsrv_cachep) | ||
196 | kmem_cache_destroy(gfs2_rsrv_cachep); | ||
197 | |||
189 | if (gfs2_quotad_cachep) | 198 | if (gfs2_quotad_cachep) |
190 | kmem_cache_destroy(gfs2_quotad_cachep); | 199 | kmem_cache_destroy(gfs2_quotad_cachep); |
191 | 200 | ||
@@ -226,6 +235,7 @@ static void __exit exit_gfs2_fs(void) | |||
226 | rcu_barrier(); | 235 | rcu_barrier(); |
227 | 236 | ||
228 | mempool_destroy(gfs2_bh_pool); | 237 | mempool_destroy(gfs2_bh_pool); |
238 | kmem_cache_destroy(gfs2_rsrv_cachep); | ||
229 | kmem_cache_destroy(gfs2_quotad_cachep); | 239 | kmem_cache_destroy(gfs2_quotad_cachep); |
230 | kmem_cache_destroy(gfs2_rgrpd_cachep); | 240 | kmem_cache_destroy(gfs2_rgrpd_cachep); |
231 | kmem_cache_destroy(gfs2_bufdata_cachep); | 241 | kmem_cache_destroy(gfs2_bufdata_cachep); |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 3df65c9ab73b..69fa32fbf3fb 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -1002,11 +1002,13 @@ struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip) | |||
1002 | * Returns: the struct gfs2_qadata | 1002 | * Returns: the struct gfs2_qadata |
1003 | */ | 1003 | */ |
1004 | 1004 | ||
1005 | static struct gfs2_blkreserv *gfs2_blkrsv_get(struct gfs2_inode *ip) | 1005 | static int gfs2_blkrsv_get(struct gfs2_inode *ip) |
1006 | { | 1006 | { |
1007 | BUG_ON(ip->i_res != NULL); | 1007 | BUG_ON(ip->i_res != NULL); |
1008 | ip->i_res = kzalloc(sizeof(struct gfs2_blkreserv), GFP_NOFS); | 1008 | ip->i_res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS); |
1009 | return ip->i_res; | 1009 | if (!ip->i_res) |
1010 | return -ENOMEM; | ||
1011 | return 0; | ||
1010 | } | 1012 | } |
1011 | 1013 | ||
1012 | /** | 1014 | /** |
@@ -1164,7 +1166,7 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) | |||
1164 | static void gfs2_blkrsv_put(struct gfs2_inode *ip) | 1166 | static void gfs2_blkrsv_put(struct gfs2_inode *ip) |
1165 | { | 1167 | { |
1166 | BUG_ON(ip->i_res == NULL); | 1168 | BUG_ON(ip->i_res == NULL); |
1167 | kfree(ip->i_res); | 1169 | kmem_cache_free(gfs2_rsrv_cachep, ip->i_res); |
1168 | ip->i_res = NULL; | 1170 | ip->i_res = NULL; |
1169 | } | 1171 | } |
1170 | 1172 | ||
@@ -1179,14 +1181,15 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested) | |||
1179 | { | 1181 | { |
1180 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1182 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
1181 | struct gfs2_blkreserv *rs; | 1183 | struct gfs2_blkreserv *rs; |
1182 | int error = 0; | 1184 | int error; |
1183 | u64 last_unlinked = NO_BLOCK; | 1185 | u64 last_unlinked = NO_BLOCK; |
1184 | int tries = 0; | 1186 | int tries = 0; |
1185 | 1187 | ||
1186 | rs = gfs2_blkrsv_get(ip); | 1188 | error = gfs2_blkrsv_get(ip); |
1187 | if (!rs) | 1189 | if (error) |
1188 | return -ENOMEM; | 1190 | return error; |
1189 | 1191 | ||
1192 | rs = ip->i_res; | ||
1190 | rs->rs_requested = requested; | 1193 | rs->rs_requested = requested; |
1191 | if (gfs2_assert_warn(sdp, requested)) { | 1194 | if (gfs2_assert_warn(sdp, requested)) { |
1192 | error = -EINVAL; | 1195 | error = -EINVAL; |
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 9e7765e8e7b0..3afc6ac6fe0d 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c | |||
@@ -25,6 +25,7 @@ struct kmem_cache *gfs2_inode_cachep __read_mostly; | |||
25 | struct kmem_cache *gfs2_bufdata_cachep __read_mostly; | 25 | struct kmem_cache *gfs2_bufdata_cachep __read_mostly; |
26 | struct kmem_cache *gfs2_rgrpd_cachep __read_mostly; | 26 | struct kmem_cache *gfs2_rgrpd_cachep __read_mostly; |
27 | struct kmem_cache *gfs2_quotad_cachep __read_mostly; | 27 | struct kmem_cache *gfs2_quotad_cachep __read_mostly; |
28 | struct kmem_cache *gfs2_rsrv_cachep __read_mostly; | ||
28 | mempool_t *gfs2_bh_pool __read_mostly; | 29 | mempool_t *gfs2_bh_pool __read_mostly; |
29 | 30 | ||
30 | void gfs2_assert_i(struct gfs2_sbd *sdp) | 31 | void gfs2_assert_i(struct gfs2_sbd *sdp) |
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h index a4ce76c67dbb..8fbe6cffc118 100644 --- a/fs/gfs2/util.h +++ b/fs/gfs2/util.h | |||
@@ -152,6 +152,7 @@ extern struct kmem_cache *gfs2_inode_cachep; | |||
152 | extern struct kmem_cache *gfs2_bufdata_cachep; | 152 | extern struct kmem_cache *gfs2_bufdata_cachep; |
153 | extern struct kmem_cache *gfs2_rgrpd_cachep; | 153 | extern struct kmem_cache *gfs2_rgrpd_cachep; |
154 | extern struct kmem_cache *gfs2_quotad_cachep; | 154 | extern struct kmem_cache *gfs2_quotad_cachep; |
155 | extern struct kmem_cache *gfs2_rsrv_cachep; | ||
155 | extern mempool_t *gfs2_bh_pool; | 156 | extern mempool_t *gfs2_bh_pool; |
156 | 157 | ||
157 | static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, | 158 | static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, |