From patchwork Fri Sep 8 17:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13377728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55D20EEB560 for ; Fri, 8 Sep 2023 17:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245304AbjIHRUy (ORCPT ); Fri, 8 Sep 2023 13:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244595AbjIHRUw (ORCPT ); Fri, 8 Sep 2023 13:20:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EC10CE6 for ; Fri, 8 Sep 2023 10:20:48 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67A6CC433C9 for ; Fri, 8 Sep 2023 17:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694193648; bh=gCXc2CaFF7Jt4URwSAn9CIJjkNy0IXpKpcarbaKkiD0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PzuNa6jTCy3huBnds3HxgEK71WL2Eq1RnsWeFAb09ocetzNED9n2ryNyzC5ivhFwq EC0y4DhxQToQYXYt7uf/3pzkbOSTsd+Q3F+/jXV1JBxhCo8tIQHgwp8KFFfMn4D+fW nGHCygmCjkd55DgBP/sP1O3xdWGHbJfgd2P72TrwDB+2xASXEOjshooV5YoZkveFoz kD1z/4r/KSgkstpaTwresUJpCVwtRtJEaP3V+4hK9dSjA76Eu0pAHiRqoLckwHQSfE Q/cP2TzWrs+n53txLNPaATlSGsRGOU9lHemfYwrVZzhYBtYOcr3l3BdWZ6+1PWu6Fr PPacKV7avC5uQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 06/21] btrfs: return -EUCLEAN for delayed tree ref with a ref count not equals to 1 Date: Fri, 8 Sep 2023 18:20:23 +0100 Message-Id: <55ab327daf38130664d2a4558a14dc1b04a76d2a.1694192469.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana When running a delayed tree reference, if we find a ref count different from 1, we return -EIO. This isn't an IO error, as it indicates either a bug in the delayed refs code or a memory corruption, so change the error code from -EIO to -EUCLEAN. Also tag the branch as 'unlikely' as this is not expected to ever happen, and change the error message to print the tree block's bytenr without the parenthesis (and there was a missing space between the 'block' word and the opening parenthesis), for consistency as that's the style we used everywhere else. Reviewed-by: Josef Bacik Signed-off-by: Filipe Manana --- fs/btrfs/extent-tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 929fbb620d68..8fca9c2b8917 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1699,12 +1699,12 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans, parent = ref->parent; ref_root = ref->root; - if (node->ref_mod != 1) { + if (unlikely(node->ref_mod != 1)) { btrfs_err(trans->fs_info, - "btree block(%llu) has %d references rather than 1: action %d ref_root %llu parent %llu", + "btree block %llu has %d references rather than 1: action %d ref_root %llu parent %llu", node->bytenr, node->ref_mod, node->action, ref_root, parent); - return -EIO; + return -EUCLEAN; } if (node->action == BTRFS_ADD_DELAYED_REF && insert_reserved) { BUG_ON(!extent_op || !extent_op->update_flags);