From patchwork Wed Jun 7 00:58:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9770391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 55CFB603F1 for ; Wed, 7 Jun 2017 01:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38313269A3 for ; Wed, 7 Jun 2017 01:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2919E2853E; Wed, 7 Jun 2017 01:00:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D604C269A3 for ; Wed, 7 Jun 2017 01:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751505AbdFGBAP (ORCPT ); Tue, 6 Jun 2017 21:00:15 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35994 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751484AbdFGBAI (ORCPT ); Tue, 6 Jun 2017 21:00:08 -0400 Received: by mail-wr0-f195.google.com with SMTP id e23so10418262wre.3 for ; Tue, 06 Jun 2017 18:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sLKiLq5QALSmEZUNC4Q+OgGI+BBhAOg1AnoGU8g3Ed4=; b=Dn0mmvZzId7EsOyZDEkClcvBbwtBuFY3iyFjye+jfBQ5wqUoFdP4+8LsfJ1ZFajOtn VYItKimeB7vH7nWOsGoBUxPwHeq8ewsbBQpdTpSXEiemVM/F41dLW0ibvUeletZF/dv0 yxK3ezo7EMa7u07W5ttJibLOXuO294brHn/sQWIGEmKRedi5eUMZQtHYuJI8eIuH0Y+C W+7CTA+VJm2gFEroiFiBKrgyHe4yRGD2eE66S+qtWKplew3SGt/V9zJqlO/wW06N++cO hbXuWXkelAN1Z1sY+fwyWX9VxdNcAulL4cLPBi+tE+1Geplee427PF+ix6TUnMDCryeR EdOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sLKiLq5QALSmEZUNC4Q+OgGI+BBhAOg1AnoGU8g3Ed4=; b=OTuRL/WuJo+Hs3jUVbOA/zVuv4fZZ1eIjAJPNoPdhKOkWZja+8afdJ7cclTaVt0oH9 y3D/VY3a4fd4pVPnJgJvyUO4aPjxKtktQKtTPBiS2Y2SgpYUWJBcht2GTG7wT9nz2MNp 0i64KhOj/kdy8swHKIjhh9otWcs9MExVWzhGZPdagqbPe1yxY5kCsrsFLqu9BRHUwxAx WrOais31w0/sALhiHxDb84fG9K4AueB9JWtl+b2QK0rSVAs2yuVJBMPKibJDjHb3JKbu LfuwkehTwG6srVWBX8E5mJqT/qJFkBC4LNGjR5gTQQ9Pm/ZcQ/LRqBlv2Dmnio6JRanj UW3w== X-Gm-Message-State: AODbwcCzaY9sKwhwTyuFzGDtsSeg8vB6qj7enkDdNCfyyg9z706jDX1u f4hZSW+wfBsmm4l5 X-Received: by 10.223.135.43 with SMTP id a40mr12710935wra.17.1496797207215; Tue, 06 Jun 2017 18:00:07 -0700 (PDT) Received: from localhost.localdomain ([91.215.176.151]) by smtp.gmail.com with ESMTPSA id q16sm338101wmg.2.2017.06.06.18.00.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 18:00:06 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH 6/7] Btrfs: __tree_mod_log_insert decrease max compare count Date: Wed, 7 Jun 2017 03:58:43 +0300 Message-Id: <20170607005844.2078-7-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170607005844.2078-1-nefelim4ag@gmail.com> References: <20170607005844.2078-1-nefelim4ag@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In worst case code do 4 comparison, just add some new checks to switch check branch faster now in worst case code do 3 comparison Signed-off-by: Timofey Titovets --- fs/btrfs/ctree.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a3a75f1de..318379531 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -460,15 +460,17 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm) while (*new) { cur = rb_entry(*new, struct tree_mod_elem, node); parent = *new; - if (cur->logical < tm->logical) - new = &((*new)->rb_left); - else if (cur->logical > tm->logical) - new = &((*new)->rb_right); - else if (cur->seq < tm->seq) - new = &((*new)->rb_left); - else if (cur->seq > tm->seq) - new = &((*new)->rb_right); - else + if (cur->logical != tm->logical) { + if (cur->logical < tm->logical) + new = &((*new)->rb_left); + else + new = &((*new)->rb_right); + } else if (cur->seq != tm->seq) { + if (cur->seq < tm->seq) + new = &((*new)->rb_left); + else + new = &((*new)->rb_right); + } else return -EEXIST; }