diff options
author | T Makphaibulchoke <tmac@hp.com> | 2014-03-18 19:24:49 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-03-18 19:24:49 -0400 |
commit | 9c191f701ce9f9bc604e88a5dc69cd943daa5d3b (patch) | |
tree | 2e7a0ffa25f89e6dab1719deeb6a710405517afc /fs/mbcache.c | |
parent | 1f3e55fe02d12213f87869768aa2b0bad3ba9a7d (diff) |
ext4: each filesystem creates and uses its own mb_cache
This patch adds new interfaces to create and destory cache,
ext4_xattr_create_cache() and ext4_xattr_destroy_cache(), and remove
the cache creation and destory calls from ex4_init_xattr() and
ext4_exitxattr() in fs/ext4/xattr.c.
fs/ext4/super.c has been changed so that when a filesystem is mounted
a cache is allocated and attched to its ext4_sb_info structure.
fs/mbcache.c has been changed so that only one slab allocator is
allocated and used by all mbcache structures.
Signed-off-by: T. Makphaibulchoke <tmac@hp.com>
Diffstat (limited to 'fs/mbcache.c')
-rw-r--r-- | fs/mbcache.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/mbcache.c b/fs/mbcache.c index 786ecab81c99..bf166e388f0d 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c | |||
@@ -99,6 +99,7 @@ | |||
99 | 99 | ||
100 | static DECLARE_WAIT_QUEUE_HEAD(mb_cache_queue); | 100 | static DECLARE_WAIT_QUEUE_HEAD(mb_cache_queue); |
101 | static struct blockgroup_lock *mb_cache_bg_lock; | 101 | static struct blockgroup_lock *mb_cache_bg_lock; |
102 | static struct kmem_cache *mb_cache_kmem_cache; | ||
102 | 103 | ||
103 | MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>"); | 104 | MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>"); |
104 | MODULE_DESCRIPTION("Meta block cache (for extended attributes)"); | 105 | MODULE_DESCRIPTION("Meta block cache (for extended attributes)"); |
@@ -351,11 +352,14 @@ mb_cache_create(const char *name, int bucket_bits) | |||
351 | goto fail; | 352 | goto fail; |
352 | for (n=0; n<bucket_count; n++) | 353 | for (n=0; n<bucket_count; n++) |
353 | INIT_HLIST_BL_HEAD(&cache->c_index_hash[n]); | 354 | INIT_HLIST_BL_HEAD(&cache->c_index_hash[n]); |
354 | cache->c_entry_cache = kmem_cache_create(name, | 355 | if (!mb_cache_kmem_cache) { |
355 | sizeof(struct mb_cache_entry), 0, | 356 | mb_cache_kmem_cache = kmem_cache_create(name, |
356 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL); | 357 | sizeof(struct mb_cache_entry), 0, |
357 | if (!cache->c_entry_cache) | 358 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL); |
358 | goto fail2; | 359 | if (!mb_cache_kmem_cache) |
360 | goto fail2; | ||
361 | } | ||
362 | cache->c_entry_cache = mb_cache_kmem_cache; | ||
359 | 363 | ||
360 | /* | 364 | /* |
361 | * Set an upper limit on the number of cache entries so that the hash | 365 | * Set an upper limit on the number of cache entries so that the hash |
@@ -476,6 +480,10 @@ mb_cache_destroy(struct mb_cache *cache) | |||
476 | atomic_read(&cache->c_entry_count)); | 480 | atomic_read(&cache->c_entry_count)); |
477 | } | 481 | } |
478 | 482 | ||
483 | if (list_empty(&mb_cache_list)) { | ||
484 | kmem_cache_destroy(mb_cache_kmem_cache); | ||
485 | mb_cache_kmem_cache = NULL; | ||
486 | } | ||
479 | kfree(cache->c_index_hash); | 487 | kfree(cache->c_index_hash); |
480 | kfree(cache->c_block_hash); | 488 | kfree(cache->c_block_hash); |
481 | kfree(cache); | 489 | kfree(cache); |