Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2415200rwi; Tue, 11 Oct 2022 08:30:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57t6P2I9/G8NA+5/mDA6jIkgwwv3PE6brtm+lL3jnqaawGdIJ+TEoLNEru6BjR2l2AQei2 X-Received: by 2002:a17:902:7481:b0:180:fde5:98a8 with SMTP id h1-20020a170902748100b00180fde598a8mr18072407pll.81.1665502235095; Tue, 11 Oct 2022 08:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665502235; cv=none; d=google.com; s=arc-20160816; b=j56UYoxJGKECyhVQ7Io/Ek5GC3LAUE7Qc9EnTIQMzWEE1UwAH+zs0/29nfn+mZr61B 2Mw7tZ0K4Cl65jX7+3LI5ZroZSZOtBg5Z4X758rJEfE5uKV8w3PWfmyeJY+lb4YmIYFZ g2O0nzZRksY7ZWnTyH861zDzGYThTl+zOnzyvB5HoyE9LP8k0OeUQoVRGMFS6C5m0Tv7 fDRlWFfJ8hXVxcgg7uCCdoPc3Re8xuRklpV5NG/q9RdyhE1Ki1mSUcd0uUHRYaDhu7L+ 2KtbiBbre9ExYMRzr8F5WwfTVPJR9tOpyhnEdo599c99UOMG3wPIw4F573gOCXnWn5fP AZ5g== 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=cjsIhCmhOqof/LCTmF6sgST4cjPfN+wPU4eFJGNs5Ng=; b=GVcZPCy7WbLxP4EXelAj1qsvg0wfhmRraDxdULCzUuR8jZDqQ+YeSbyOgdL4eDSmSc bdv3NJ4uRUn8vvafJSzxezrbAXFvsrQuH43fBg/1ZLd4jqfIbddkoGjnhk+iScWb/O8J S03tGHxbkP6IUTovlAI4YhTxU0apW3IjHtWHOK5hsLx8YJ1yT59HpGLiyVQdIuFm1mCJ N4VaAuV80X9AM76lg9JHpsQmlnA7gz65tiRvkARUYZY+Yd74q7ZOojwlh3KE5okkU2fl UONFUKiSFVysGxqLZIW3JsxrG/t88SDcQpeQDX5tqHe+AflVVkUeo5beyGyKY4oLNeId 8ffA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gxrhm95k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a170902e94300b00183baaecf95si2440201pll.562.2022.10.11.08.30.22; Tue, 11 Oct 2022 08:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gxrhm95k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbiJKOwg (ORCPT + 99 others); Tue, 11 Oct 2022 10:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiJKOvM (ORCPT ); Tue, 11 Oct 2022 10:51:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A8998C84; Tue, 11 Oct 2022 07:50:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 84F43611C9; Tue, 11 Oct 2022 14:50:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F046CC433B5; Tue, 11 Oct 2022 14:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665499854; bh=USN0DegjD2jdAYzzw+a6E24iyODsPCAphQhOpxQnV+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxrhm95kfYbq/Gzf6yP7OLvsIEJpgSiAF2NYXHXCMI4YLAOFHnviowUw4zB/563k9 f5dJeyMEAdkf2JFOSRwSh2AzkcTXF+LAcP8wpOQ5IwiubvkxbB+uaIWzoc9O9eG/ic kzvVmtKZp1I5zD9FSuY3DC/ECvPMeXVe4V7V/Qa2tHCL4VDtgYabKm5DDBRc/tjVC9 e9FhQVhOAaPYEotkH+QaT3ZG8fObXv1esIYCrY5V2tu/iQ0bsL7/LlWQrC1QlQjDxo rbgKwDVbd9h0R6X33iDs8Ja957mGisq3LvcrGWh0hDPRDr8jBUNwMkI/yu2cz7A1pA DsMVqGiCBoUow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qu Wenruo , Anand Jain , David Sterba , Sasha Levin , clm@fb.com, josef@toxicpanda.com, linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 23/46] btrfs: dump extra info if one free space cache has more bitmaps than it should Date: Tue, 11 Oct 2022 10:49:51 -0400 Message-Id: <20221011145015.1622882-23-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221011145015.1622882-1-sashal@kernel.org> References: <20221011145015.1622882-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qu Wenruo [ Upstream commit 62cd9d4474282a1eb84f945955c56cbfc42e1ffe ] There is an internal report on hitting the following ASSERT() in recalculate_thresholds(): ASSERT(ctl->total_bitmaps <= max_bitmaps); Above @max_bitmaps is calculated using the following variables: - bytes_per_bg 8 * 4096 * 4096 (128M) for x86_64/x86. - block_group->length The length of the block group. @max_bitmaps is the rounded up value of block_group->length / 128M. Normally one free space cache should not have more bitmaps than above value, but when it happens the ASSERT() can be triggered if CONFIG_BTRFS_ASSERT is also enabled. But the ASSERT() itself won't provide enough info to know which is going wrong. Is the bg too small thus it only allows one bitmap? Or is there something else wrong? So although I haven't found extra reports or crash dump to do further investigation, add the extra info to make it more helpful to debug. Reviewed-by: Anand Jain Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/free-space-cache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 996da650ecdc..85404c62a1c2 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -693,6 +693,12 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) max_bitmaps = max_t(u64, max_bitmaps, 1); + if (ctl->total_bitmaps > max_bitmaps) + btrfs_err(block_group->fs_info, +"invalid free space control: bg start=%llu len=%llu total_bitmaps=%u unit=%u max_bitmaps=%llu bytes_per_bg=%llu", + block_group->start, block_group->length, + ctl->total_bitmaps, ctl->unit, max_bitmaps, + bytes_per_bg); ASSERT(ctl->total_bitmaps <= max_bitmaps); /* -- 2.35.1