Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp60146rdb; Wed, 18 Oct 2023 18:23:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGnRHI6vl+tnWm2QJ1/22h4TQpO0kgfi13vqACmWuZSrVIdyaox30byAaDLijTLMJ51hcy X-Received: by 2002:a17:902:d486:b0:1ca:abe:a090 with SMTP id c6-20020a170902d48600b001ca0abea090mr1206102plg.62.1697678585860; Wed, 18 Oct 2023 18:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697678585; cv=none; d=google.com; s=arc-20160816; b=Cf1rXHm1A7K3VCXr2gK+hVfUpPZoHUAcVa38KBUY6kqPMnEJpFsH88DoQduEDD5Zmi AFzQPPL5nuVEMmR/x7byE7K2zntRNPUAPwBfoHULIPwuTcYFUXrhnT3dVlxl8fMec/or 87l6UNWX1YUtKR9OQffSZsCFPV8a0EhgJsTNrMtJjqI3hTomvWFDZMhjhsjMhO+OHZ6K GF058xelF4D8AIP0mbkHg+R0ZVU4mMrlA7eFG6XnU1+VMF+CjqTO2hJNVmIDocOe7Brs TTEHlXGSer69n6t5/U075TmKUBiafQYBfHh1P5I8Nm//YuHq43B0ZrS1kcWf5xCwIJTu RcEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=bpnotyWVBmb8kaZoamasYyDYdsSoa0s+FhBau47xdlk=; fh=JHQNX3J6Fq3Et+rUF+IfNV0nof0vACmk4TJ+Wy+IcvI=; b=t7EV8a5fgbmOXfqi1zqto6cVBCCRaMyWq7jJ23PS0N5HTuub4K13iC0B9bCVe9x76T mptKlHIT6Vl7zkK0kvvCedp93tbsAKelhlD24za0WjV/VVdLZF0HnYlLgPwLYvAHk4Re yoPy3AsFeXzWUQTNXRxzL0dLBpRX+0GYDpnTKFwpLE01Kkgfl9hY6OVuYQyYSBOtPdOl v1CA2m0gb47HbYo0JhnbZmQ9pHRvVKxk+i863Cs3YPqbgKUAKh6/FaBd3Hxo1fXg2yGG y58ha3ZA5/xF14hpHSywpnfG+MShz/yKeKGVN+0vQnUCVuaCNLmEzqlcyNAmLIL/588M hMNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id y10-20020a1709029b8a00b001c722b269b4si981513plp.620.2023.10.18.18.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 18:23:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 413E1808458F; Wed, 18 Oct 2023 18:22:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbjJSBWY (ORCPT + 99 others); Wed, 18 Oct 2023 21:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjJSBWX (ORCPT ); Wed, 18 Oct 2023 21:22:23 -0400 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFE5C114 for ; Wed, 18 Oct 2023 18:22:20 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VuS1j91_1697678536; Received: from 30.221.128.175(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0VuS1j91_1697678536) by smtp.aliyun-inc.com; Thu, 19 Oct 2023 09:22:18 +0800 Message-ID: <7a8b2331-a252-58ef-6553-ceb73a9a63c9@linux.alibaba.com> Date: Thu, 19 Oct 2023 09:22:16 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] ocfs2: replace BUG_ON() at ocfs2_num_free_extents() with ocfs2_error() Content-Language: en-US To: Jia Rui , mark@fasheh.com, akpm Cc: jlbec@evilplan.org, ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org References: <20231018191811.412458-1-jindui71@gmail.com> From: Joseph Qi In-Reply-To: <20231018191811.412458-1-jindui71@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 18:22:59 -0700 (PDT) On 10/19/23 3:18 AM, Jia Rui wrote: > The BUG_ON() at ocfs2_num_free_extents() handles the error that > l_tree_deepth of leaf extent block just read form disk is invalid. > This error is mostly caused by file system metadata corruption on > the disk. There is no need to call BUG_ON() to handle such errors. > We can return error code, since the caller can deal with errors > from ocfs2_num_free_extents(). Also, we should make the file > system read-only to avoid the damage from expanding. > > Therefore, BUG_ON() is removed and ocfs2_error() is called instead. > > Signed-off-by: Jia Rui Looks reasonable. Reviewed-by: Joseph Qi > --- > fs/ocfs2/alloc.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c > index aef58f1395c8..d6bcf00f6843 100644 > --- a/fs/ocfs2/alloc.c > +++ b/fs/ocfs2/alloc.c > @@ -967,7 +967,14 @@ int ocfs2_num_free_extents(struct ocfs2_extent_tree *et) > el = &eb->h_list; > } > > - BUG_ON(el->l_tree_depth != 0); > + if (el->l_tree_depth != 0) { > + retval = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), > + "Owner %llu has leaf extent block %llu with an invalid l_tree_depth of %u\n", > + (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), > + (unsigned long long)last_eb_blk, > + le16_to_cpu(el->l_tree_depth)); > + goto bail; > + } > > retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); > bail: