]> git.hungrycats.org Git - linux/commitdiff
btrfs: don't use slab cache for struct btrfs_delalloc_work
authorDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2015 13:39:32 +0000 (14:39 +0100)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 16 Jan 2016 03:28:32 +0000 (22:28 -0500)
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>
(cherry picked from commit 100d57025cce6bf568a10660c0d884bcc64c580e)

fs/btrfs/inode.c

index b6da2bf55142fd91d2a78cde53c444831cc9a633..08182c4ab2448d1e6e234418801372994f4678ce 100644 (file)
@@ -77,7 +77,6 @@ static const struct file_operations btrfs_dir_file_operations;
 static struct extent_io_ops btrfs_extent_io_ops;
 
 static struct kmem_cache *btrfs_inode_cachep;
-static struct kmem_cache *btrfs_delalloc_work_cachep;
 struct kmem_cache *btrfs_trans_handle_cachep;
 struct kmem_cache *btrfs_transaction_cachep;
 struct kmem_cache *btrfs_path_cachep;
@@ -9011,8 +9010,6 @@ void btrfs_destroy_cachep(void)
                kmem_cache_destroy(btrfs_path_cachep);
        if (btrfs_free_space_cachep)
                kmem_cache_destroy(btrfs_free_space_cachep);
-       if (btrfs_delalloc_work_cachep)
-               kmem_cache_destroy(btrfs_delalloc_work_cachep);
 }
 
 int btrfs_init_cachep(void)
@@ -9047,13 +9044,6 @@ int btrfs_init_cachep(void)
        if (!btrfs_free_space_cachep)
                goto fail;
 
-       btrfs_delalloc_work_cachep = kmem_cache_create("btrfs_delalloc_work",
-                       sizeof(struct btrfs_delalloc_work), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
-                       NULL);
-       if (!btrfs_delalloc_work_cachep)
-               goto fail;
-
        return 0;
 fail:
        btrfs_destroy_cachep();
@@ -9298,7 +9288,7 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode,
 {
        struct btrfs_delalloc_work *work;
 
-       work = kmem_cache_zalloc(btrfs_delalloc_work_cachep, GFP_NOFS);
+       work = kmalloc(sizeof(*work), GFP_NOFS);
        if (!work)
                return NULL;
 
@@ -9317,7 +9307,7 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode,
 void btrfs_wait_and_free_delalloc_work(struct btrfs_delalloc_work *work)
 {
        wait_for_completion(&work->completion);
-       kmem_cache_free(btrfs_delalloc_work_cachep, work);
+       kfree(work);
 }
 
 /*