]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: trimming some start_transaction() code away
authorAlexandru Moise <00moses.alexander00@gmail.com>
Thu, 27 Aug 2015 23:53:45 +0000 (23:53 +0000)
committerChuck Anderson <chuck.anderson@oracle.com>
Tue, 28 Feb 2017 04:50:32 +0000 (20:50 -0800)
Orabug: 25615755

Just call kmem_cache_zalloc() instead of calling kmem_cache_alloc().
We're just initializing most fields to 0, false and NULL later on
_anyway_, so to make the code mode readable and potentially gain
a bit of performance (completely untested claim), we should fill our
btrfs_trans_handle with zeros on allocation then just initialize
those five remaining fields (not counting the list_heads) as normal.

Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit f2f767e7345dfe56102d6809f647ba38a238f718)
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
 Conflicts:
fs/btrfs/transaction.c

fs/btrfs/transaction.c

index 6d43b2ab183b5f6c9156ce025e93524c379fcbac..ab5c3152daaa560fbd5e75a3ec304b1eb9d73d15 100644 (file)
@@ -466,7 +466,7 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
                        goto reserve_fail;
        }
 again:
-       h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
+       h = kmem_cache_zalloc(btrfs_trans_handle_cachep, GFP_NOFS);
        if (!h) {
                ret = -ENOMEM;
                goto alloc_fail;
@@ -507,20 +507,9 @@ again:
 
        h->transid = cur_trans->transid;
        h->transaction = cur_trans;
-       h->bytes_reserved = 0;
        h->root = root;
-       h->delayed_ref_updates = 0;
        h->use_count = 1;
-       h->adding_csums = 0;
-       h->block_rsv = NULL;
-       h->orig_rsv = NULL;
-       h->aborted = 0;
-       h->qgroup_reserved = 0;
-       h->delayed_ref_elem.seq = 0;
        h->type = type;
-       h->allocating_chunk = false;
-       h->reloc_reserved = false;
-       h->sync = false;
        INIT_LIST_HEAD(&h->qgroup_ref_list);
        INIT_LIST_HEAD(&h->new_bgs);
        INIT_LIST_HEAD(&h->ordered);