diff options
author | David Sterba <dsterba@suse.com> | 2015-12-08 08:39:32 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-01-07 08:26:58 -0500 |
commit | 100d57025cce6bf568a10660c0d884bcc64c580e (patch) | |
tree | 1cee4de6fcbad6bae29d486e1b92861946a41eb8 /fs/btrfs/inode.c | |
parent | 0de270fa83d5a45664e3f2428d432145037ac432 (diff) |
btrfs: don't use slab cache for struct btrfs_delalloc_work
Although we prefer to use separate caches for various structs, it seems
better not to do that for struct btrfs_delalloc_work. Objects of this
type are allocated rarely, when transaction commit calls
btrfs_start_delalloc_roots, requesting delayed iputs.
The objects are temporary (with some IO involved) but still allocated
and freed within __start_delalloc_inodes. Memory allocation failure is
handled.
The slab cache is empty most of the time (observed on several systems),
so if we need to allocate a new slab object, the first one has to
allocate a full page. In a potential case of low memory conditions this
might fail with higher probability compared to using the generic slab
caches.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 255d0f966b9f..0214a812fc0e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -77,7 +77,6 @@ static const struct file_operations btrfs_dir_file_operations; | |||
77 | static struct extent_io_ops btrfs_extent_io_ops; | 77 | static struct extent_io_ops btrfs_extent_io_ops; |
78 | 78 | ||
79 | static struct kmem_cache *btrfs_inode_cachep; | 79 | static struct kmem_cache *btrfs_inode_cachep; |
80 | static struct kmem_cache *btrfs_delalloc_work_cachep; | ||
81 | struct kmem_cache *btrfs_trans_handle_cachep; | 80 | struct kmem_cache *btrfs_trans_handle_cachep; |
82 | struct kmem_cache *btrfs_transaction_cachep; | 81 | struct kmem_cache *btrfs_transaction_cachep; |
83 | struct kmem_cache *btrfs_path_cachep; | 82 | struct kmem_cache *btrfs_path_cachep; |
@@ -9159,8 +9158,6 @@ void btrfs_destroy_cachep(void) | |||
9159 | kmem_cache_destroy(btrfs_path_cachep); | 9158 | kmem_cache_destroy(btrfs_path_cachep); |
9160 | if (btrfs_free_space_cachep) | 9159 | if (btrfs_free_space_cachep) |
9161 | kmem_cache_destroy(btrfs_free_space_cachep); | 9160 | kmem_cache_destroy(btrfs_free_space_cachep); |
9162 | if (btrfs_delalloc_work_cachep) | ||
9163 | kmem_cache_destroy(btrfs_delalloc_work_cachep); | ||
9164 | } | 9161 | } |
9165 | 9162 | ||
9166 | int btrfs_init_cachep(void) | 9163 | int btrfs_init_cachep(void) |
@@ -9195,13 +9192,6 @@ int btrfs_init_cachep(void) | |||
9195 | if (!btrfs_free_space_cachep) | 9192 | if (!btrfs_free_space_cachep) |
9196 | goto fail; | 9193 | goto fail; |
9197 | 9194 | ||
9198 | btrfs_delalloc_work_cachep = kmem_cache_create("btrfs_delalloc_work", | ||
9199 | sizeof(struct btrfs_delalloc_work), 0, | ||
9200 | SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, | ||
9201 | NULL); | ||
9202 | if (!btrfs_delalloc_work_cachep) | ||
9203 | goto fail; | ||
9204 | |||
9205 | return 0; | 9195 | return 0; |
9206 | fail: | 9196 | fail: |
9207 | btrfs_destroy_cachep(); | 9197 | btrfs_destroy_cachep(); |
@@ -9446,7 +9436,7 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode, | |||
9446 | { | 9436 | { |
9447 | struct btrfs_delalloc_work *work; | 9437 | struct btrfs_delalloc_work *work; |
9448 | 9438 | ||
9449 | work = kmem_cache_zalloc(btrfs_delalloc_work_cachep, GFP_NOFS); | 9439 | work = kmalloc(sizeof(*work), GFP_NOFS); |
9450 | if (!work) | 9440 | if (!work) |
9451 | return NULL; | 9441 | return NULL; |
9452 | 9442 | ||
@@ -9465,7 +9455,7 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode, | |||
9465 | void btrfs_wait_and_free_delalloc_work(struct btrfs_delalloc_work *work) | 9455 | void btrfs_wait_and_free_delalloc_work(struct btrfs_delalloc_work *work) |
9466 | { | 9456 | { |
9467 | wait_for_completion(&work->completion); | 9457 | wait_for_completion(&work->completion); |
9468 | kmem_cache_free(btrfs_delalloc_work_cachep, work); | 9458 | kfree(work); |
9469 | } | 9459 | } |
9470 | 9460 | ||
9471 | /* | 9461 | /* |