@@ -344,7 +344,13 @@ static struct kmem_cache *ext4_free_ext_cachep;
* each unique s_blocksize_bits */
#define NR_GRPINFO_CACHES \
(EXT4_MAX_BLOCK_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE + 1)
-static struct kmem_cache *ext4_groupinfo_caches[NR_GRPINFO_CACHES];
+
+static struct {
+ /* memory cache */
+ struct kmem_cache *cache;
+ /* name of the cache */
+ char* cache_name;
+} ext4_groupinfo_caches[NR_GRPINFO_CACHES];
static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
ext4_group_t group);
@@ -2245,7 +2251,7 @@ static const struct file_operations ext4_mb_seq_groups_fops = {
static struct kmem_cache *get_groupinfo_cache(int blocksize_bits)
{
int cache_index = blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE;
- struct kmem_cache *cachep = ext4_groupinfo_caches[cache_index];
+ struct kmem_cache *cachep = ext4_groupinfo_caches[cache_index].cache;
BUG_ON(!cachep);
return cachep;
@@ -2441,7 +2447,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
}
cache_index = sb->s_blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE;
- cachep = ext4_groupinfo_caches[cache_index];
+ cachep = ext4_groupinfo_caches[cache_index].cache;
if (!cachep) {
char name[32];
int len = offsetof(struct ext4_group_info,
@@ -2462,7 +2468,8 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
ret = -ENOMEM;
goto out;
}
- ext4_groupinfo_caches[cache_index] = cachep;
+ ext4_groupinfo_caches[cache_index].cache = cachep;
+ ext4_groupinfo_caches[cache_index].cache_name = namep;
}
/* order 0 is regular bitmap */
@@ -2745,12 +2752,13 @@ void ext4_exit_mballoc(void)
kmem_cache_destroy(ext4_free_ext_cachep);
for (i = 0; i < NR_GRPINFO_CACHES; i++) {
- struct kmem_cache *cachep = ext4_groupinfo_caches[i];
- if (cachep) {
- char *name = (char *)kmem_cache_name(cachep);
+ struct kmem_cache *cachep = ext4_groupinfo_caches[i].cache;
+ char *name = ext4_groupinfo_caches[i].cache_name;
+
+ if (cachep)
kmem_cache_destroy(cachep);
+ if (name)
kfree(name);
- }
}
ext4_remove_debugfs_entry();
}