From patchwork Thu Sep 13 17:55:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10599871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F65E14F9 for ; Thu, 13 Sep 2018 17:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BE6E2B40D for ; Thu, 13 Sep 2018 17:56:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 303192B415; Thu, 13 Sep 2018 17:56:07 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 80B082B40D for ; Thu, 13 Sep 2018 17:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727369AbeIMXGi (ORCPT ); Thu, 13 Sep 2018 19:06:38 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:36520 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726637AbeIMXGi (ORCPT ); Thu, 13 Sep 2018 19:06:38 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=bo.liu@linux.alibaba.com;NM=1;PH=DS;RN=1;SR=0;TI=SMTPD_---0T8bbXgO_1536861362; Received: from localhost(mailfrom:bo.liu@linux.alibaba.com fp:SMTPD_---0T8bbXgO_1536861362) by smtp.aliyun-inc.com(127.0.0.1); Fri, 14 Sep 2018 01:56:02 +0800 From: Liu Bo To: Subject: [PATCH v2] Btrfs: remove level==0 check in balance_level Date: Fri, 14 Sep 2018 01:55:59 +0800 Message-Id: <1536861359-55509-1-git-send-email-bo.liu@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536703587-94565-4-git-send-email-bo.liu@linux.alibaba.com> References: <1536703587-94565-4-git-send-email-bo.liu@linux.alibaba.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 btrfs_search_slot() if (level != 0) setup_nodes_for_search() balance_level() It is just impossible to have level=0 in balance_level. Reviewed-by: Nikolay Borisov Signed-off-by: Liu Bo Reviewed-by: David Sterba --- v2: add assertion for level just in case someone breaks the rule in the future. fs/btrfs/ctree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 8b31caa60b0a..ada44c786f2e 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1778,8 +1778,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, int orig_slot = path->slots[level]; u64 orig_ptr; - if (level == 0) - return 0; + ASSERT(level > 0); mid = path->nodes[level];