From patchwork Fri Nov 16 07:54:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685577 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 F214A109C for ; Fri, 16 Nov 2018 07:54:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E63CD2D41D for ; Fri, 16 Nov 2018 07:54:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DACAF2D427; Fri, 16 Nov 2018 07:54:35 +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 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 85F872D41D for ; Fri, 16 Nov 2018 07:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727567AbeKPSFs (ORCPT ); Fri, 16 Nov 2018 13:05:48 -0500 Received: from mx2.suse.de ([195.135.220.15]:46132 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSFs (ORCPT ); Fri, 16 Nov 2018 13:05:48 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CAAEEABDC for ; Fri, 16 Nov 2018 07:54:32 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/9] btrfs-progs: Makefile.extrawarn: Import cc-disable-warning Date: Fri, 16 Nov 2018 15:54:18 +0800 Message-Id: <20181116075426.4142-2-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 We imported cc-option but forgot to import cc-disable-warning. Fixes: b556a992c3ad ("btrfs-progs: build: allow to build with various compiler warnings") Signed-off-by: Qu Wenruo --- Makefile.extrawarn | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.extrawarn b/Makefile.extrawarn index 1f4bda94a167..5849036fd166 100644 --- a/Makefile.extrawarn +++ b/Makefile.extrawarn @@ -19,6 +19,12 @@ try-run = $(shell set -e; \ cc-option = $(call try-run,\ $(CC) $(CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) +# cc-disable-warning +# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) +cc-disable-warning = $(call try-run,\ + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + + # From linux.git/scripts/Makefile.extrawarn # ========================================================================== # From patchwork Fri Nov 16 07:54:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685579 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 2250C109C for ; Fri, 16 Nov 2018 07:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14FF52D41D for ; Fri, 16 Nov 2018 07:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0958C2D427; Fri, 16 Nov 2018 07:54:39 +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 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 D80E52D41D for ; Fri, 16 Nov 2018 07:54:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbeKPSFv (ORCPT ); Fri, 16 Nov 2018 13:05:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:46138 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSFu (ORCPT ); Fri, 16 Nov 2018 13:05:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1B050ABDC; Fri, 16 Nov 2018 07:54:35 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: Su Yanjun Subject: [PATCH 2/9] btrfs-progs: fix gcc8 default build warning caused by '-Wformat-truncation' Date: Fri, 16 Nov 2018 15:54:19 +0800 Message-Id: <20181116075426.4142-3-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 From: Su Yanjun When using gcc8 compiles utils.c, it complains as below: utils.c:852:45: warning: '%s' directive output may be truncated writing up to 4095 bytes into a region of size 4084 [-Wformat-truncation=] snprintf(path, sizeof(path), "/dev/mapper/%s", name); ^~ ~~~~ In file included from /usr/include/stdio.h:873, from utils.c:20: /usr/include/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output between 13 and 4108 bytes into a destination of size 4096 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This isn't a type of warning we care about, particularly when PATH_MAX is much less than either. Using the GCC option -Wno-format-truncation to disable this for default build. Signed-off-by: Su Yanjun [Use cc-disable-warning to fix the not working CFLAGS setting in configure.ac] Signed-off-by: Qu Wenruo --- Makefile | 1 + Makefile.extrawarn | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile b/Makefile index f4ab14ea74c8..252299f8869f 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ CSCOPE_CMD := cscope -u -b -c -q include Makefile.extrawarn EXTRA_CFLAGS := +EXTRA_CFLAGS += $(call cc-disable-warning, format-truncation) EXTRA_LDFLAGS := DEBUG_CFLAGS_DEFAULT = -O0 -U_FORTIFY_SOURCE -ggdb3 diff --git a/Makefile.extrawarn b/Makefile.extrawarn index 5849036fd166..bbb2d5173846 100644 --- a/Makefile.extrawarn +++ b/Makefile.extrawarn @@ -53,6 +53,7 @@ warning-1 += -Wold-style-definition warning-1 += $(call cc-option, -Wmissing-include-dirs) warning-1 += $(call cc-option, -Wunused-but-set-variable) warning-1 += $(call cc-disable-warning, missing-field-initializers) +warning-1 += $(call cc-disable-warning, format-truncation) warning-2 := -Waggregate-return warning-2 += -Wcast-align From patchwork Fri Nov 16 07:54:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685581 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 18C8C14E2 for ; Fri, 16 Nov 2018 07:54:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D6D02D41D for ; Fri, 16 Nov 2018 07:54:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01B1B2D427; Fri, 16 Nov 2018 07:54:39 +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 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 AF4602D41D for ; Fri, 16 Nov 2018 07:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389345AbeKPSFw (ORCPT ); Fri, 16 Nov 2018 13:05:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:46150 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSFw (ORCPT ); Fri, 16 Nov 2018 13:05:52 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EFD95AD56 for ; Fri, 16 Nov 2018 07:54:36 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 3/9] btrfs-progs: Makefile.extrawarn: Don't warn on sign compare Date: Fri, 16 Nov 2018 15:54:20 +0800 Message-Id: <20181116075426.4142-4-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 Under most case, we are just using 'int' for 'unsigned int', and doesn't care about the sign. The Wsign-compare is causing tons of false alerts. Suppressing it would make W=1 less noisy. Signed-off-by: Qu Wenruo --- Makefile.extrawarn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.extrawarn b/Makefile.extrawarn index bbb2d5173846..c108e98ee7ec 100644 --- a/Makefile.extrawarn +++ b/Makefile.extrawarn @@ -45,7 +45,7 @@ endif ifdef BUILD_ENABLE_EXTRA_GCC_CHECKS warning- := $(empty) -warning-1 := -Wextra -Wunused -Wno-unused-parameter +warning-1 := -Wextra -Wunused -Wno-unused-parameter -Wno-sign-compare warning-1 += -Wmissing-declarations warning-1 += -Wmissing-format-attribute warning-1 += $(call cc-option, -Wmissing-prototypes) From patchwork Fri Nov 16 07:54:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685583 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 C1A7E14E2 for ; Fri, 16 Nov 2018 07:54:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5E302D41D for ; Fri, 16 Nov 2018 07:54:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA76F2D427; Fri, 16 Nov 2018 07:54:42 +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 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 AAF4B2D41D for ; Fri, 16 Nov 2018 07:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389385AbeKPSFy (ORCPT ); Fri, 16 Nov 2018 13:05:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:46156 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSFy (ORCPT ); Fri, 16 Nov 2018 13:05:54 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B15B4ABDC for ; Fri, 16 Nov 2018 07:54:38 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 4/9] btrfs-progs: Fix Wempty-body warning Date: Fri, 16 Nov 2018 15:54:21 +0800 Message-Id: <20181116075426.4142-5-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 messages.h:49:24: warning: suggest braces around empty body in an 'if' statement [-Wempty-body] PRINT_TRACE_ON_ERROR; \ Just extra braces would solve the problem. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov --- messages.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/messages.h b/messages.h index ec7d93381a36..16f650d19a4b 100644 --- a/messages.h +++ b/messages.h @@ -45,13 +45,16 @@ #define error_on(cond, fmt, ...) \ do { \ - if ((cond)) \ + if ((cond)) { \ PRINT_TRACE_ON_ERROR; \ - if ((cond)) \ + } \ + if ((cond)) { \ PRINT_VERBOSE_ERROR; \ + } \ __btrfs_error_on((cond), (fmt), ##__VA_ARGS__); \ - if ((cond)) \ + if ((cond)) { \ DO_ABORT_ON_ERROR; \ + } \ } while (0) #define error_btrfs_util(err) \ @@ -76,10 +79,12 @@ #define warning_on(cond, fmt, ...) \ do { \ - if ((cond)) \ + if ((cond)) { \ PRINT_TRACE_ON_ERROR; \ - if ((cond)) \ + } \ + if ((cond)) { \ PRINT_VERBOSE_ERROR; \ + } \ __btrfs_warning_on((cond), (fmt), ##__VA_ARGS__); \ } while (0) From patchwork Fri Nov 16 07:54:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685585 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 087E9109C for ; Fri, 16 Nov 2018 07:54:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00252D41D for ; Fri, 16 Nov 2018 07:54:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E45812D427; Fri, 16 Nov 2018 07:54:43 +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 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 8B3D52D41D for ; Fri, 16 Nov 2018 07:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389395AbeKPSF4 (ORCPT ); Fri, 16 Nov 2018 13:05:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:46162 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSF4 (ORCPT ); Fri, 16 Nov 2018 13:05:56 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E7EB9ABDC for ; Fri, 16 Nov 2018 07:54:40 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 5/9] btrfs-progs: Fix Wimplicit-fallthrough warning Date: Fri, 16 Nov 2018 15:54:22 +0800 Message-Id: <20181116075426.4142-6-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 Although most fallthrough case is pretty obvious, we still need to teach the dumb compiler that it's an explicit fallthrough. Also reformat the code to use common indent. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov --- utils.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/utils.c b/utils.c index a310300829eb..b274f46fdd9d 100644 --- a/utils.c +++ b/utils.c @@ -1134,15 +1134,25 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod num_divs = 0; last_size = size; switch (unit_mode & UNITS_MODE_MASK) { - case UNITS_TBYTES: base *= mult; num_divs++; - case UNITS_GBYTES: base *= mult; num_divs++; - case UNITS_MBYTES: base *= mult; num_divs++; - case UNITS_KBYTES: num_divs++; - break; + case UNITS_TBYTES: + base *= mult; + num_divs++; + __attribute__ ((fallthrough)); + case UNITS_GBYTES: + base *= mult; + num_divs++; + __attribute__ ((fallthrough)); + case UNITS_MBYTES: + base *= mult; + num_divs++; + __attribute__ ((fallthrough)); + case UNITS_KBYTES: + num_divs++; + break; case UNITS_BYTES: - base = 1; - num_divs = 0; - break; + base = 1; + num_divs = 0; + break; default: if (negative) { s64 ssize = (s64)size; @@ -1907,13 +1917,17 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, default: case 4: allowed |= BTRFS_BLOCK_GROUP_RAID10; + __attribute__ ((fallthrough)); case 3: allowed |= BTRFS_BLOCK_GROUP_RAID6; + __attribute__ ((fallthrough)); case 2: allowed |= BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID5; + __attribute__ ((fallthrough)); case 1: allowed |= BTRFS_BLOCK_GROUP_DUP; + __attribute__ ((fallthrough)); } if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) { From patchwork Fri Nov 16 07:54:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685587 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 B288C109C for ; Fri, 16 Nov 2018 07:54:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6C1F2D41D for ; Fri, 16 Nov 2018 07:54:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B2A12D427; Fri, 16 Nov 2018 07:54:45 +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 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 54BE42D41D for ; Fri, 16 Nov 2018 07:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389401AbeKPSF6 (ORCPT ); Fri, 16 Nov 2018 13:05:58 -0500 Received: from mx2.suse.de ([195.135.220.15]:46198 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSF6 (ORCPT ); Fri, 16 Nov 2018 13:05:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AB47CABDC for ; Fri, 16 Nov 2018 07:54:42 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 6/9] btrfs-progs: Fix Wsuggest-attribute=format warning Date: Fri, 16 Nov 2018 15:54:23 +0800 Message-Id: <20181116075426.4142-7-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 Add __attribute__ ((format (printf, 4, 0))) to fix the vprintf calling function. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov --- string-table.c | 1 + 1 file changed, 1 insertion(+) diff --git a/string-table.c b/string-table.c index 95833768960d..455285702d51 100644 --- a/string-table.c +++ b/string-table.c @@ -48,6 +48,7 @@ struct string_table *table_create(int columns, int rows) * '>' the text is right aligned. If fmt is equal to '=' the text will * be replaced by a '=====' dimensioned on the basis of the column width */ +__attribute__ ((format (printf, 4, 0))) char *table_vprintf(struct string_table *tab, int column, int row, const char *fmt, va_list ap) { From patchwork Fri Nov 16 07:54:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685589 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 62BEB14E2 for ; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 572F42D41D for ; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BF542D427; Fri, 16 Nov 2018 07:54:47 +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 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 075892D41D for ; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389417AbeKPSGA (ORCPT ); Fri, 16 Nov 2018 13:06:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:46204 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSGA (ORCPT ); Fri, 16 Nov 2018 13:06:00 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6D589ABDC for ; Fri, 16 Nov 2018 07:54:44 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 7/9] btrfs-progs: Fix Wmaybe-uninitialized warning Date: Fri, 16 Nov 2018 15:54:24 +0800 Message-Id: <20181116075426.4142-8-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 The only location is the following code: int level = path->lowest_level + 1; BUG_ON(path->lowest_level + 1 >= BTRFS_MAX_LEVEL); while(level < BTRFS_MAX_LEVEL) { slot = path->slots[level] + 1; ... } path->slots[level] = slot; Again, it's the stupid compiler needs some hint for the fact that we will always enter the while loop for at least once, thus @slot should always be initialized. Fix it by assign level after the BUG_ON(), so the stupid compiler knows we will always go into the while loop. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov --- ctree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ctree.c b/ctree.c index 46e2ccedc0bf..9c9cb0dfdbf2 100644 --- a/ctree.c +++ b/ctree.c @@ -2961,11 +2961,12 @@ int btrfs_next_sibling_tree_block(struct btrfs_fs_info *fs_info, struct btrfs_path *path) { int slot; - int level = path->lowest_level + 1; + int level; struct extent_buffer *c; struct extent_buffer *next = NULL; BUG_ON(path->lowest_level + 1 >= BTRFS_MAX_LEVEL); + level = path->lowest_level + 1; while(level < BTRFS_MAX_LEVEL) { if (!path->nodes[level]) return 1; From patchwork Fri Nov 16 07:54:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685591 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 1753714E2 for ; Fri, 16 Nov 2018 07:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 081892D41D for ; Fri, 16 Nov 2018 07:54:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0C772D427; Fri, 16 Nov 2018 07:54:49 +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 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 E84192D41D for ; Fri, 16 Nov 2018 07:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389420AbeKPSGC (ORCPT ); Fri, 16 Nov 2018 13:06:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:46210 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSGB (ORCPT ); Fri, 16 Nov 2018 13:06:01 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 338E6ABDC for ; Fri, 16 Nov 2018 07:54:46 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 8/9] btrfs-progs: Fix Wtype-limits warning Date: Fri, 16 Nov 2018 15:54:25 +0800 Message-Id: <20181116075426.4142-9-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 The only hit is the following code: tlv_len = le16_to_cpu(tlv_hdr->tlv_len); if (tlv_type == 0 || tlv_type > BTRFS_SEND_A_MAX || tlv_len > BTRFS_SEND_BUF_SIZE) { error("invalid tlv in cmd tlv_type = %hu, tlv_len = %hu", tlv_type, tlv_len); @tlv_len is u16, while BTRFS_SEND_BUF_SIZE is 64K. u16 MAX is 64K - 1, so the final check is always false. Just remove it. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov --- send-stream.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/send-stream.c b/send-stream.c index 3b8e39c9486a..25461e92c37b 100644 --- a/send-stream.c +++ b/send-stream.c @@ -157,8 +157,7 @@ static int read_cmd(struct btrfs_send_stream *sctx) tlv_type = le16_to_cpu(tlv_hdr->tlv_type); tlv_len = le16_to_cpu(tlv_hdr->tlv_len); - if (tlv_type == 0 || tlv_type > BTRFS_SEND_A_MAX - || tlv_len > BTRFS_SEND_BUF_SIZE) { + if (tlv_type == 0 || tlv_type > BTRFS_SEND_A_MAX) { error("invalid tlv in cmd tlv_type = %hu, tlv_len = %hu", tlv_type, tlv_len); ret = -EINVAL; From patchwork Fri Nov 16 07:54:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685593 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 2AE22109C for ; Fri, 16 Nov 2018 07:54:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D2462D41D for ; Fri, 16 Nov 2018 07:54:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EABF2D427; Fri, 16 Nov 2018 07:54:54 +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 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 2E3562D41D for ; Fri, 16 Nov 2018 07:54:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389423AbeKPSGG (ORCPT ); Fri, 16 Nov 2018 13:06:06 -0500 Received: from mx2.suse.de ([195.135.220.15]:46218 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSGG (ORCPT ); Fri, 16 Nov 2018 13:06:06 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4D613ABDC for ; Fri, 16 Nov 2018 07:54:48 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 9/9] btrfs-progs: Cleanup warning reported by -Wmissing-prototypes except free space tree Date: Fri, 16 Nov 2018 15:54:26 +0800 Message-Id: <20181116075426.4142-10-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 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 The following missing prototypes will be fixed: 1) btrfs.c::handle_special_globals() 2) check/mode-lowmem.c::repair_ternary_lowmem() 3) extent-tree.c::btrfs_search_overlap_extent() Above 3 can be fixed by making them static 4) utils.c::btrfs_check_nodesize() Fixed by moving it to fsfeatures.c 5) chunk-recover.c::btrfs_recover_chunk_tree() 6) super-recover.c::btrfs_recover_superblocks() Fixed by moving the declaration from cmds-rescue.c to rescue.h 7) utils-lib.c::arg_strtou64() 8) utils-lib.c::lookup_path_rootid() Fixed by include "utils.h" 9) free-space-tree.c::set_free_space_tree_thresholds() Fixed by deleting it, as there is no user. 10) free-space-tree.c::convert_free_space_to_bitmaps() 11) free-space-tree.c::convert_free_space_to_extents() 12) free-space-tree.c::__remove_from_free_space_tree() 13) free-space-tree.c::__add_to_free_space_tree() 14) free-space-tree.c::btrfs_create_tree() Fixed by making them static. Signed-off-by: Qu Wenruo --- btrfs.c | 2 +- check/mode-lowmem.c | 6 ++--- chunk-recover.c | 1 + cmds-rescue.c | 4 +-- extent-tree.c | 2 +- free-space-tree.c | 59 ++++++++++++--------------------------------- fsfeatures.c | 22 +++++++++++++++++ rescue.h | 14 +++++++++++ super-recover.c | 1 + utils-lib.c | 1 + utils.c | 23 ------------------ 11 files changed, 60 insertions(+), 75 deletions(-) create mode 100644 rescue.h diff --git a/btrfs.c b/btrfs.c index 2d39f2ced3e8..78c468d2e050 100644 --- a/btrfs.c +++ b/btrfs.c @@ -210,7 +210,7 @@ static int handle_global_options(int argc, char **argv) return shift; } -void handle_special_globals(int shift, int argc, char **argv) +static void handle_special_globals(int shift, int argc, char **argv) { int has_help = 0; int has_full = 0; diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 14bbc9ee6cb6..f56b5e8d45dc 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -953,9 +953,9 @@ out: * returns 0 means success. * returns not 0 means on error; */ -int repair_ternary_lowmem(struct btrfs_root *root, u64 dir_ino, u64 ino, - u64 index, char *name, int name_len, u8 filetype, - int err) +static int repair_ternary_lowmem(struct btrfs_root *root, u64 dir_ino, u64 ino, + u64 index, char *name, int name_len, + u8 filetype, int err) { struct btrfs_trans_handle *trans; int stage = 0; diff --git a/chunk-recover.c b/chunk-recover.c index 1d30db51d8ed..1e554b8e8750 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -40,6 +40,7 @@ #include "utils.h" #include "btrfsck.h" #include "commands.h" +#include "rescue.h" struct recover_control { int verbose; diff --git a/cmds-rescue.c b/cmds-rescue.c index 2bc50c0841ed..36e9e1277e40 100644 --- a/cmds-rescue.c +++ b/cmds-rescue.c @@ -26,15 +26,13 @@ #include "commands.h" #include "utils.h" #include "help.h" +#include "rescue.h" static const char * const rescue_cmd_group_usage[] = { "btrfs rescue [options] ", NULL }; -int btrfs_recover_chunk_tree(const char *path, int verbose, int yes); -int btrfs_recover_superblocks(const char *path, int verbose, int yes); - static const char * const cmd_rescue_chunk_recover_usage[] = { "btrfs rescue chunk-recover [options] ", "Recover the chunk tree by scanning the devices one by one.", diff --git a/extent-tree.c b/extent-tree.c index cd98633992ac..8c9cdeff3b02 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -3749,7 +3749,7 @@ static void __get_extent_size(struct btrfs_root *root, struct btrfs_path *path, * Return >0 for not found. * Return <0 for err */ -int btrfs_search_overlap_extent(struct btrfs_root *root, +static int btrfs_search_overlap_extent(struct btrfs_root *root, struct btrfs_path *path, u64 bytenr, u64 len) { struct btrfs_key key; diff --git a/free-space-tree.c b/free-space-tree.c index 6641cdfa42ba..af141e6e611a 100644 --- a/free-space-tree.c +++ b/free-space-tree.c @@ -24,35 +24,6 @@ #include "bitops.h" #include "internal.h" -void set_free_space_tree_thresholds(struct btrfs_block_group_cache *cache, - u64 sectorsize) -{ - u32 bitmap_range; - size_t bitmap_size; - u64 num_bitmaps, total_bitmap_size; - - /* - * We convert to bitmaps when the disk space required for using extents - * exceeds that required for using bitmaps. - */ - bitmap_range = sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS; - num_bitmaps = div_u64(cache->key.offset + bitmap_range - 1, - bitmap_range); - bitmap_size = sizeof(struct btrfs_item) + BTRFS_FREE_SPACE_BITMAP_SIZE; - total_bitmap_size = num_bitmaps * bitmap_size; - cache->bitmap_high_thresh = div_u64(total_bitmap_size, - sizeof(struct btrfs_item)); - - /* - * We allow for a small buffer between the high threshold and low - * threshold to avoid thrashing back and forth between the two formats. - */ - if (cache->bitmap_high_thresh > 100) - cache->bitmap_low_thresh = cache->bitmap_high_thresh - 100; - else - cache->bitmap_low_thresh = 0; -} - static struct btrfs_free_space_info * search_free_space_info(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info, @@ -202,9 +173,9 @@ static void le_bitmap_set(unsigned long *map, unsigned int start, int len) } } -int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, - struct btrfs_block_group_cache *block_group, - struct btrfs_path *path) +static int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, + struct btrfs_block_group_cache *block_group, + struct btrfs_path *path) { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_root *root = fs_info->free_space_root; @@ -341,9 +312,9 @@ out: return ret; } -int convert_free_space_to_extents(struct btrfs_trans_handle *trans, - struct btrfs_block_group_cache *block_group, - struct btrfs_path *path) +static int convert_free_space_to_extents(struct btrfs_trans_handle *trans, + struct btrfs_block_group_cache *block_group, + struct btrfs_path *path) { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_root *root = fs_info->free_space_root; @@ -780,9 +751,9 @@ out: return ret; } -int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, - struct btrfs_block_group_cache *block_group, - struct btrfs_path *path, u64 start, u64 size) +static int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, + struct btrfs_block_group_cache *block_group, + struct btrfs_path *path, u64 start, u64 size) { struct btrfs_free_space_info *info; u32 flags; @@ -960,9 +931,9 @@ out: return ret; } -int __add_to_free_space_tree(struct btrfs_trans_handle *trans, - struct btrfs_block_group_cache *block_group, - struct btrfs_path *path, u64 start, u64 size) +static int __add_to_free_space_tree(struct btrfs_trans_handle *trans, + struct btrfs_block_group_cache *block_group, + struct btrfs_path *path, u64 start, u64 size) { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_free_space_info *info; @@ -1420,9 +1391,9 @@ out: return ret; } -struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, - struct btrfs_fs_info *fs_info, - u64 objectid) +static struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, + struct btrfs_fs_info *fs_info, + u64 objectid) { struct extent_buffer *leaf; struct btrfs_root *tree_root = fs_info->tree_root; diff --git a/fsfeatures.c b/fsfeatures.c index 7d85d60f1277..201d0f576688 100644 --- a/fsfeatures.c +++ b/fsfeatures.c @@ -225,3 +225,25 @@ u32 get_running_kernel_version(void) return version; } +int btrfs_check_nodesize(u32 nodesize, u32 sectorsize, u64 features) +{ + if (nodesize < sectorsize) { + error("illegal nodesize %u (smaller than %u)", + nodesize, sectorsize); + return -1; + } else if (nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) { + error("illegal nodesize %u (larger than %u)", + nodesize, BTRFS_MAX_METADATA_BLOCKSIZE); + return -1; + } else if (nodesize & (sectorsize - 1)) { + error("illegal nodesize %u (not aligned to %u)", + nodesize, sectorsize); + return -1; + } else if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS && + nodesize != sectorsize) { + error("illegal nodesize %u (not equal to %u for mixed block group)", + nodesize, sectorsize); + return -1; + } + return 0; +} diff --git a/rescue.h b/rescue.h new file mode 100644 index 000000000000..c9f6e7b80b16 --- /dev/null +++ b/rescue.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 SUSE. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ +int btrfs_recover_superblocks(const char *path, int verbose, int yes); +int btrfs_recover_chunk_tree(const char *path, int verbose, int yes); diff --git a/super-recover.c b/super-recover.c index 86b3df9867dc..a1af71786034 100644 --- a/super-recover.c +++ b/super-recover.c @@ -34,6 +34,7 @@ #include "crc32c.h" #include "volumes.h" #include "commands.h" +#include "rescue.h" struct btrfs_recover_superblock { struct btrfs_fs_devices *fs_devices; diff --git a/utils-lib.c b/utils-lib.c index 044f93fc4446..5bb89f2f1a8d 100644 --- a/utils-lib.c +++ b/utils-lib.c @@ -1,4 +1,5 @@ #include "kerncompat.h" +#include "utils.h" #include #include #include diff --git a/utils.c b/utils.c index b274f46fdd9d..a7e34b804551 100644 --- a/utils.c +++ b/utils.c @@ -2266,29 +2266,6 @@ int btrfs_tree_search2_ioctl_supported(int fd) return ret; } -int btrfs_check_nodesize(u32 nodesize, u32 sectorsize, u64 features) -{ - if (nodesize < sectorsize) { - error("illegal nodesize %u (smaller than %u)", - nodesize, sectorsize); - return -1; - } else if (nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) { - error("illegal nodesize %u (larger than %u)", - nodesize, BTRFS_MAX_METADATA_BLOCKSIZE); - return -1; - } else if (nodesize & (sectorsize - 1)) { - error("illegal nodesize %u (not aligned to %u)", - nodesize, sectorsize); - return -1; - } else if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS && - nodesize != sectorsize) { - error("illegal nodesize %u (not equal to %u for mixed block group)", - nodesize, sectorsize); - return -1; - } - return 0; -} - /* * Copy a path argument from SRC to DEST and check the SRC length if it's at * most PATH_MAX and fits into DEST. DESTLEN is supposed to be exact size of