From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA9C4C433E1 for ; Thu, 13 Aug 2020 14:11:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C196B20675 for ; Thu, 13 Aug 2020 14:11:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbgHMOLY (ORCPT ); Thu, 13 Aug 2020 10:11:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:53586 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbgHMOLX (ORCPT ); Thu, 13 Aug 2020 10:11:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EB984B1CE; Thu, 13 Aug 2020 14:11:44 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 2F705DA6EF; Thu, 13 Aug 2020 16:10:20 +0200 (CEST) Date: Thu, 13 Aug 2020 16:10:19 +0200 From: David Sterba To: Qu Wenruo Cc: linux-btrfs@vger.kernel.org, Nikolay Borisov , Josef Bacik Subject: Re: [PATCH v4 2/4] btrfs: extent-tree: Kill BUG_ON() in __btrfs_free_extent() and do better comment Message-ID: <20200813141019.GI2026@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Qu Wenruo , linux-btrfs@vger.kernel.org, Nikolay Borisov , Josef Bacik References: <20200812060509.71590-1-wqu@suse.com> <20200812060509.71590-3-wqu@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812060509.71590-3-wqu@suse.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Aug 12, 2020 at 02:05:07PM +0800, Qu Wenruo wrote: > @@ -2987,13 +3049,20 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, > found_extent = 1; > break; > } > + > + /* Quick path didn't find the EXTEMT/METADATA_ITEM */ > if (path->slots[0] - extent_slot > 5) > break; > extent_slot--; > } > > if (!found_extent) { > - BUG_ON(iref); > + if (unlikely(iref)) { > + btrfs_crit(info, > +"invalid iref, no EXTENT/METADATA_ITEM found but has inline extent ref"); > + goto err_dump_abort; This is not calling transaction abort at the place where it happens, here and several other places too. > @@ -3164,6 +3267,21 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, > out: > btrfs_free_path(path); > return ret; > +err_dump_abort: > + /* > + * Leaf dump can take up a lot of dmesg buffer since default nodesize > + * is already 16K. > + * So we only do full leaf dump for debug build. > + */ > + if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) { > + btrfs_crit(info, "path->slots[0]=%d extent_slot=%d", > + path->slots[0], extent_slot); > + btrfs_print_leaf(path->nodes[0]); Preceded by a potentially long-running action, so this will delay the acutal abort. > + } > + > + btrfs_abort_transaction(trans, -EUCLEAN); > + btrfs_free_path(path); > + return -EUCLEAN; > }