From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF8E222A4FE; Fri, 31 Oct 2025 14:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761919580; cv=none; b=LtBIfSGpKTUJKuV8/DFRikE9/U8WcoXMMZI1pOzYbjYZheK/h6gmMQZnc3k11ZbLh8e67UM2RUbKlkwUh9H1UZYs3PQC8XFFRYG5LwTabgWCIz1MDtTFsy4l5EahOw2aK/Tv4JCrRma2ZNIVqq1LYKxJiVBso7bHkFjWvONKY40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761919580; c=relaxed/simple; bh=4FSv81Zvx18IsAkIUctc7Y/jVGlChm97k7ws7PYtSe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TDwYC63tCsYd2UyyCOOnJHqqgumyTwmNvCiPdXyvAn6Xz+2MkXSFx+zolQ+rtk0pEpBjXfYOStW0sf/ean18uG76m0O9gmO4eKr665KpIbJWjoF7QfcOtYfJeM9bjHV3DqzGFdphrArHupmamMtKzvEFqDuXDpkiZiCDQHQ8IqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XPRi52vy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XPRi52vy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78A09C4CEE7; Fri, 31 Oct 2025 14:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761919579; bh=4FSv81Zvx18IsAkIUctc7Y/jVGlChm97k7ws7PYtSe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XPRi52vyp3/KP0cbDgCTZx8GuCSxaF2u6lC1JQvSRPk5/Mcvtd4WKfNBBOJWoFGiU OoBrJ2InEB6eMObZtGs4t/cU9EGGXcE31oz6K5EH2zefFnijXP0Gt1d0Vn32YYnJ8C 8fngMEqQ2BKvsiW0ew6+JC2VxNjTbXoPyt0TJ/Ok= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Boris Burkov , Qu Wenruo , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 6.17 25/35] btrfs: abort transaction in the process_one_buffer() log tree walk callback Date: Fri, 31 Oct 2025 15:01:33 +0100 Message-ID: <20251031140044.172337085@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251031140043.564670400@linuxfoundation.org> References: <20251031140043.564670400@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit e6dd405b6671b9753b98d8bdf76f8f0ed36c11cd ] In the process_one_buffer() log tree walk callback we return errors to the log tree walk caller and then the caller aborts the transaction, if we have one, or turns the fs into error state if we don't have one. While this reduces code it makes it harder to figure out where exactly an error came from. So add the transaction aborts after every failure inside the process_one_buffer() callback, so that it helps figuring out why failures happen. Reviewed-by: Boris Burkov Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/tree-log.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 6d92326a1a0c7..50ed84cb68a69 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -347,6 +347,7 @@ static int process_one_buffer(struct btrfs_root *log, struct extent_buffer *eb, struct walk_control *wc, u64 gen, int level) { + struct btrfs_trans_handle *trans = wc->trans; struct btrfs_fs_info *fs_info = log->fs_info; int ret = 0; @@ -361,18 +362,29 @@ static int process_one_buffer(struct btrfs_root *log, }; ret = btrfs_read_extent_buffer(eb, &check); - if (ret) + if (ret) { + if (trans) + btrfs_abort_transaction(trans, ret); + else + btrfs_handle_fs_error(fs_info, ret, NULL); return ret; + } } if (wc->pin) { - ret = btrfs_pin_extent_for_log_replay(wc->trans, eb); - if (ret) + ASSERT(trans != NULL); + ret = btrfs_pin_extent_for_log_replay(trans, eb); + if (ret) { + btrfs_abort_transaction(trans, ret); return ret; + } if (btrfs_buffer_uptodate(eb, gen, 0) && - btrfs_header_level(eb) == 0) + btrfs_header_level(eb) == 0) { ret = btrfs_exclude_logged_extents(eb); + if (ret) + btrfs_abort_transaction(trans, ret); + } } return ret; } -- 2.51.0