Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3917590rwi; Sat, 22 Oct 2022 02:10:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CHeljlaWdA0KNuxS5I2xppQkyOiGT+KQ9z2wIMUbTTlXJEtXjiSVxrBnyfHHASJgnKfov X-Received: by 2002:a17:90b:38cf:b0:212:d06c:9489 with SMTP id nn15-20020a17090b38cf00b00212d06c9489mr7823524pjb.220.1666429833547; Sat, 22 Oct 2022 02:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666429833; cv=none; d=google.com; s=arc-20160816; b=IHSKvYVY0QKeHh/uZX0clHVLtFsdFTiKwaQLX3uM4lhMmQm3TtFkHRk6rKF/4BD7KM fyLphQ5DxkafN2jt4oEh6eGDJWcspbCYbiyDC/LiElGqWRL0VQhAlU8D/ncZnUTJfMjo xToS4LPqSrYV2RxtEziN+BnXXpZWlofa4O5bbqZGgn8Y/dbu4nM3arGt5hXscoWpF1Jk Jtg/oO5AaDIM2Es1NketOwxUkAoDzVct6I+4dsvBYfJdppuHRu0+gGaqbkhgn0mwgn4/ 2cWYRCkgOjB5c1Sd5msJsE2G+SEv8kMUc56/77j33sjU1YCWORVyYkBLNrRp799qUOi7 bqMQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2Dy5fW4udrPL9eT64rpudFX1d89p05yNbSniuvel9pc=; b=CWdoR1z+liwbozwWpWbVZ8Qqj0vUZiDhmU0CUN1Berst8cPka7ewkEWIwCSpFXjthY aow7V0D//nAUT+Acigkf2s6tbNo0kHTDIQHBSFtiJLCNCyL9ZLFfwS7z1qvPzRKHWIgd db48DwV4sTwRRON0IpW9AjsNt96CGhn5KD4CmAISVEs0TO+zimCqY0DrxNLlyRYMHhTB XYnsM92WxES9//fkOZpf3PW3xW8aBzmRv47vIzRlIsPPfLsXONrJWqYfkdgfB+f429Fm NFvmm/ToYTf3jQKjBkGoqjOT1islokZKshnYhEimfks0t8hbZc44t+GblPWITu5GEwhW pwRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HCWCIZbJ; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a170903110f00b00178b88d40ebsi32876934plh.51.2022.10.22.02.10.20; Sat, 22 Oct 2022 02:10:33 -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=@linuxfoundation.org header.s=korg header.b=HCWCIZbJ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234333AbiJVIkv (ORCPT + 99 others); Sat, 22 Oct 2022 04:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234514AbiJVIfn (ORCPT ); Sat, 22 Oct 2022 04:35:43 -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 48B71491C2; Sat, 22 Oct 2022 01:04:46 -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 E871C60B8C; Sat, 22 Oct 2022 08:04:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF183C433D6; Sat, 22 Oct 2022 08:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425869; bh=TlFvzsGM4Nex1avejFrjzErcNggEJVizUEc0EWbwmEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HCWCIZbJ+BfSgD1rMQ04suN/eiJXWuZkubvyS7BPtr6Rboo+9fv6zH+b7Nqzq3G8O Iw4vdUitwmN5jqx9fUuSsSVyla6D2OedR1qa0estQD8++GplGKc0Q9qQaVFXoGGrl/ iPSvNSKxgZHVP3sACh3MI6Ne6sKLel5qtiHR/UjY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anand Jain , Qu Wenruo , David Sterba , Sasha Levin Subject: [PATCH 5.19 642/717] btrfs: dump extra info if one free space cache has more bitmaps than it should Date: Sat, 22 Oct 2022 09:28:41 +0200 Message-Id: <20221022072526.841385048@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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 b1ae3ba2ca2c..16710d4571da 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