]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
btrfs: use generic slab for for btrfs_transaction
authorDavid Sterba <dsterba@suse.com>
Tue, 28 Mar 2017 10:06:05 +0000 (12:06 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Jun 2017 16:26:01 +0000 (18:26 +0200)
Observing the number of slab objects of btrfs_transaction, there's just
one active on an almost quiescent filesystem, and the number of objects
goes to about ten when sync is in progress. Then the nubmer goes down to
1.  This matches the expectations of the transaction lifetime.

For such use the separate slab cache is not justified, as we do not
reuse objects frequently. For the shortlived transaction, the generic
slab (size 512) should be ok. We can optimistically expect that the 512
slabs are not all used (fragmentation) and there are free slots to take
when we do the allocation, compared to potentially allocating a whole new
page for the separate slab.

We'll lose the stats about the object use, which could be added later if
we really need them.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/inode.c
fs/btrfs/transaction.c

index 388f1128544e12aa3fdfdb413daf503077d9dbb0..f0f5f28784b664d0eda75c68140105a5a4a1d76f 100644 (file)
@@ -48,7 +48,6 @@ struct btrfs_trans_handle;
 struct btrfs_transaction;
 struct btrfs_pending_snapshot;
 extern struct kmem_cache *btrfs_trans_handle_cachep;
-extern struct kmem_cache *btrfs_transaction_cachep;
 extern struct kmem_cache *btrfs_bit_radix_cachep;
 extern struct kmem_cache *btrfs_path_cachep;
 extern struct kmem_cache *btrfs_free_space_cachep;
index cdc28ad7f1ed3a9efe7d6da3ab05edb22ffb2946..cb79bce3a972b200115f73440c545cf5c21fe0fa 100644 (file)
@@ -4624,11 +4624,6 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
 
        cur_trans->state =TRANS_STATE_COMPLETED;
        wake_up(&cur_trans->commit_wait);
-
-       /*
-       memset(cur_trans, 0, sizeof(*cur_trans));
-       kmem_cache_free(btrfs_transaction_cachep, cur_trans);
-       */
 }
 
 static int btrfs_cleanup_transaction(struct btrfs_fs_info *fs_info)
index 6b8d34136044ca193f10f1ab0f2f113c42134c84..0a1ec5cd3b8f823d12f714de06c5160b48f259b9 100644 (file)
@@ -86,7 +86,6 @@ static const struct extent_io_ops btrfs_extent_io_ops;
 
 static struct kmem_cache *btrfs_inode_cachep;
 struct kmem_cache *btrfs_trans_handle_cachep;
-struct kmem_cache *btrfs_transaction_cachep;
 struct kmem_cache *btrfs_path_cachep;
 struct kmem_cache *btrfs_free_space_cachep;
 
@@ -9513,7 +9512,6 @@ void btrfs_destroy_cachep(void)
        rcu_barrier();
        kmem_cache_destroy(btrfs_inode_cachep);
        kmem_cache_destroy(btrfs_trans_handle_cachep);
-       kmem_cache_destroy(btrfs_transaction_cachep);
        kmem_cache_destroy(btrfs_path_cachep);
        kmem_cache_destroy(btrfs_free_space_cachep);
 }
@@ -9533,12 +9531,6 @@ int btrfs_init_cachep(void)
        if (!btrfs_trans_handle_cachep)
                goto fail;
 
-       btrfs_transaction_cachep = kmem_cache_create("btrfs_transaction",
-                       sizeof(struct btrfs_transaction), 0,
-                       SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
-       if (!btrfs_transaction_cachep)
-               goto fail;
-
        btrfs_path_cachep = kmem_cache_create("btrfs_path",
                        sizeof(struct btrfs_path), 0,
                        SLAB_MEM_SPREAD, NULL);
index ca0009ff47f1deb56339a2836e49f6f8c18e3b8e..ab030fb225304f12ea010b078365758a1e105c0b 100644 (file)
@@ -93,7 +93,7 @@ void btrfs_put_transaction(struct btrfs_transaction *transaction)
                        btrfs_put_block_group_trimming(cache);
                        btrfs_put_block_group(cache);
                }
-               kmem_cache_free(btrfs_transaction_cachep, transaction);
+               kfree(transaction);
        }
 }
 
@@ -228,7 +228,7 @@ loop:
         */
        BUG_ON(type == TRANS_JOIN_NOLOCK);
 
-       cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, GFP_NOFS);
+       cur_trans = kmalloc(sizeof(*cur_trans), GFP_NOFS);
        if (!cur_trans)
                return -ENOMEM;
 
@@ -238,11 +238,11 @@ loop:
                 * someone started a transaction after we unlocked.  Make sure
                 * to redo the checks above
                 */
-               kmem_cache_free(btrfs_transaction_cachep, cur_trans);
+               kfree(cur_trans);
                goto loop;
        } else if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) {
                spin_unlock(&fs_info->trans_lock);
-               kmem_cache_free(btrfs_transaction_cachep, cur_trans);
+               kfree(cur_trans);
                return -EROFS;
        }