From patchwork Thu Aug 27 23:53:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Moise <00moses.alexander00@gmail.com> X-Patchwork-Id: 7087081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A90ADBEEC1 for ; Thu, 27 Aug 2015 20:54:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97BF0209F9 for ; Thu, 27 Aug 2015 20:54:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC2B9209F8 for ; Thu, 27 Aug 2015 20:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752140AbbH0UyE (ORCPT ); Thu, 27 Aug 2015 16:54:04 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:36681 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751367AbbH0UyD (ORCPT ); Thu, 27 Aug 2015 16:54:03 -0400 Received: by wicgk12 with SMTP id gk12so3489614wic.1; Thu, 27 Aug 2015 13:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=PGc591k/IipIVLgq0XG8/BXXyt85p/WVmuhqYzvRq9E=; b=pzZDvwspf11ZWBRyjJQEvMGQdnAL3C5539zuRMhyoAZ8WG7weS84TPTjrKodNdi2v0 geq1UfzzfJw/0mG15KSD8ZS1gQSrcv/PgGg3JpGmUVqaumuMJyEDW9bU1gFrTYyCN03g XcesGLwEtMnhdJQu1cVPqCKbH2M2g1GB5hhmfYvW597NIV4ytHlinbgOCVHebXqTQMT4 6ZQcgUzE3D22jvPSsjYWzcNxYXXbKBoomE5Qfj0eRQ3mlTqdMtWQbuK3F/UH+rj0AkZj WPT9l37hEEP6iZH/qW4uAyUvIVAX+6E4XT6sV878b15ouff4s7rzWA4R7oxmZFcmSt0E 30iQ== X-Received: by 10.194.250.40 with SMTP id yz8mr7746626wjc.37.1440708841196; Thu, 27 Aug 2015 13:54:01 -0700 (PDT) Received: from gmail.com ([188.24.197.157]) by smtp.gmail.com with ESMTPSA id fi3sm784742wib.0.2015.08.27.13.54.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 13:54:00 -0700 (PDT) Date: Thu, 27 Aug 2015 23:53:45 +0000 From: Alexandru Moise <00moses.alexander00@gmail.com> To: clm@fb.com Cc: jbacik@fb.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs: trimming some start_transaction() code away Message-ID: <20150827235345.GA1373@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> Reviewed-by: David Sterba --- fs/btrfs/transaction.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index f5021fc..d874ce25 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -468,7 +468,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; @@ -509,22 +509,9 @@ again: h->transid = cur_trans->transid; h->transaction = cur_trans; - h->blocks_used = 0; - h->bytes_reserved = 0; - h->chunk_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);