Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp435189pxb; Tue, 2 Feb 2021 08:41:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOKFb60F1ASdpM3mebCmo+xhvAYbZIXsYGC/uYTsZzwhQprzJEicWGCLNPZS1m+z2x/pzK X-Received: by 2002:a17:906:7f83:: with SMTP id f3mr22782009ejr.282.1612284073195; Tue, 02 Feb 2021 08:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612284073; cv=none; d=google.com; s=arc-20160816; b=bOfT1IuFvqV3MMCJQlDAX892BRDlF3Nu7wI+Vm8P2qE6UcgLrRsfRP500yRCuDEosY ct+VDWEZ6Fw/Uw9i/atfU8lObZZvFVajIU7GIe7Tox4qwKJEu8QsFkL9boi84TKyJpUg 4JxPLO7/e8oP255VSX1TV6DAJQdrC8kxeihan35UJpdeD9KQ1rsFQkjf5HcpTZxR4CdF 8d4r/oTz0g6iNop5SlcVHTSPVUqWg4A4wxgNkkB05bO0zHl1Kky/THfsnXrBPEjfGngS rKLSbcaM41nE1to0Nvx4Jqe7gI8TRH4mKK+z8VvRTEOAHqQkMf9JFjPg+TNONDQaZ0NZ ulqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=acTr1665vWrpkNtr60MLNyhztGeZCGtXmoVAckbTx+Y=; b=s6z18frm8DvRy27Q4CTh8t44CdHrzyzp4LBOZlxgx1UDMx8I+g5R2G9wi0YV5eYqMH F7X+BW+6F+sPLNyNFInho52j5F0DGXv9koZTEsy9zhPNLdTE9FTZP1JyjtN32PFVxpDv AGqoAEMJBAyLUAPLMIdqRWiAUD9WRVmajK5CR0MUUQi0yu8VIQe11PBXbLdcA/Yz1/+l GiDUaic+eFKuZs7TRtZJuyC6zchMU4IXW+gpvgCdWLIW07HPvsRtVwxl9qtYXflRDQGD IHQg5e+rfvcyTy4Pi9iPHlscBj91Z4OqIUzwmb7zsX4ubRbt/E7sety1A5JRd5AYwdux jQ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vaTAaaqv; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx25si1053242ejb.12.2021.02.02.08.40.45; Tue, 02 Feb 2021 08:41:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vaTAaaqv; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236605AbhBBQgz (ORCPT + 99 others); Tue, 2 Feb 2021 11:36:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236511AbhBBQeu (ORCPT ); Tue, 2 Feb 2021 11:34:50 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF89FC061D7F; Tue, 2 Feb 2021 08:29:21 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id d6so19623703ilo.6; Tue, 02 Feb 2021 08:29:21 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=acTr1665vWrpkNtr60MLNyhztGeZCGtXmoVAckbTx+Y=; b=vaTAaaqvRwgGSpX8k2TeCxg6+UctH1IP5fl7yVZ+fUtjTNxK1p5ADAIg9xEKcAPzjH YOnP4O8ZQNKONgkEr8fdJsF7UE7JlJrelRcawSVxScn9hlrerRzm6YchWoQOGnJP9Xr0 puSa6PTtrMUap7LHOPThrADpRf4Hn2BjqM3eJJArI1quNyMYZzQghx7ioqS8NHv8c0Pm dhmxoywyJOhpkRCcZMap0S9QJnXlfoNGHA2/v8ipQY3s4/fnsnJnKy0+OcslnqDBLmNs VIy9fNIpoyR317pXgOIP1jfBG/nSqe/HVwu7JsuSp5Lm7o4VOyc+NwDvA/wDD6dBrfhS Y2dw== 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:mime-version:content-transfer-encoding; bh=acTr1665vWrpkNtr60MLNyhztGeZCGtXmoVAckbTx+Y=; b=AorFgz7P95iHVI6FEDrIRGf9x/yGCiGQYxBYi2D+1FAxPi4yERvc0LdBuagZux7TvU km6S21ij1MAUHVUuALqdR/XrtZoIH/zAK7xnto1XqvZYC7idRUFDYDUsarKXJ6Ixoo5J YWk2RN2t5vmd6csNNj6Bmu7grDv8xnuLp+ZwNoxlQiitbtIAcz6kiSBzos43m0/a8Bt8 ogSgd3HmQvuxUXc5ASkZZ+hcFSHNSBR/WNhbgqqc8Gwg+sFrC18D7WR6CZ4aDQ4NCzDR 44FJSYqQ+B9wHz8blxInvJgtTeniA7lBsGgTG+uKK4Si/RYflThZ1ZiiktHjp2ofU11q rITA== X-Gm-Message-State: AOAM532J9xpsIESmnOTLXX5i6yL8GHSAW/DygYjbXCZ4iIPs02zOEV2N 96mNDRadfw7fJSKBnUZHMAU= X-Received: by 2002:a05:6e02:18c9:: with SMTP id s9mr20776364ilu.265.1612283361413; Tue, 02 Feb 2021 08:29:21 -0800 (PST) Received: from llvm-development.us-central1-a.c.llvm-285123.internal (1.45.188.35.bc.googleusercontent.com. [35.188.45.1]) by smtp.googlemail.com with ESMTPSA id k11sm10844005ilo.8.2021.02.02.08.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 08:29:20 -0800 (PST) From: Vinicius Tinti To: Theodore Ts'o , Christoph Hellwig , Andreas Dilger , Nathan Chancellor , Nick Desaulniers Cc: Vinicius Tinti , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH v3] ext4: Enable code path when DX_DEBUG is set Date: Tue, 2 Feb 2021 16:28:37 +0000 Message-Id: <20210202162837.129631-1-viniciustinti@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210202080508.GA3550351@infradead.org> References: <20210202080508.GA3550351@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Clang with -Wunreachable-code-aggressive is being used to try to find unreachable code that could cause potential bugs. There is no plan to enable it by default. The following code was detected as unreachable: fs/ext4/namei.c:831:17: warning: code will never be executed [-Wunreachable-code] unsigned n = count - 1; ^~~~~ fs/ext4/namei.c:830:7: note: silence by adding parentheses to mark code as explicitly dead if (0) { // linear search cross check ^ /* DISABLES CODE */ ( ) This has been present since commit ac27a0ec112a ("[PATCH] ext4: initial copy of files from ext3") and fs/ext3 had it present at the beginning of git history. It has not been changed since. This patch moves the code to a new function `htree_rep_invariant_check` which only performs the check when DX_DEBUG is set. This allows the function to be used in other parts of the code. Suggestions from: Andreas, Christoph, Nathan, Nick and Ted. Signed-off-by: Vinicius Tinti --- fs/ext4/namei.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index cf652ba3e74d..a6e28b4b5a95 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -731,6 +731,29 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir, (space/bcount)*100/blocksize); return (struct stats) { names, space, bcount}; } + +/* + * Linear search cross check + */ +static inline void htree_rep_invariant_check(struct dx_entry *at, + struct dx_entry *target, + u32 hash, unsigned int n) +{ + while (n--) { + dxtrace(printk(KERN_CONT ",")); + if (dx_get_hash(++at) > hash) { + at--; + break; + } + } + ASSERT(at == target - 1); +} +#else /* DX_DEBUG */ +static inline void htree_rep_invariant_check(struct dx_entry *at, + struct dx_entry *target, + u32 hash, unsigned int n) +{ +} #endif /* DX_DEBUG */ /* @@ -827,20 +850,7 @@ dx_probe(struct ext4_filename *fname, struct inode *dir, p = m + 1; } - if (0) { // linear search cross check - unsigned n = count - 1; - at = entries; - while (n--) - { - dxtrace(printk(KERN_CONT ",")); - if (dx_get_hash(++at) > hash) - { - at--; - break; - } - } - ASSERT(at == p - 1); - } + htree_rep_invariant_check(entries, p, hash, count - 1); at = p - 1; dxtrace(printk(KERN_CONT " %x->%u\n", -- 2.25.1