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 122A7205E3B; Fri, 31 Oct 2025 14:02:02 +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=1761919323; cv=none; b=gJP+4QSJMTYmWkmz9h5DZJlwIsY4QV0SAfxVPoik1veJcy2c1pK3DRdYJfaI+0SLlee6xYmWOvxZxDp2aPbS1Ik3qw3hbujUe+SMrEW3w7wwB8chRXUhVKhhbrP1VAyuU4V6165hAGPNGnsBw3pO0R/3ikZpirQi8vR94ddpZ3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761919323; c=relaxed/simple; bh=A5E/QjiASGwXRgkMRYgzEvvhs5WyGzad+a4CEXvLsw4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hrkAD7R5zQ0dPFq6RUBBMm9hSAqSNwFGo0mnxtgubG26wQJiKJwRYWH2CLAs1wwHc2K1/hBjW8Yux9THOd7V3Mw2tp6YQenu3h7m+GfW3Op71dGe2/yhIXmwbj45qT85PcLvRpJlNpsHrAtBQAtPVri2hkMhL96ia4ch5LPkWG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XO8F79VQ; 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="XO8F79VQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08459C4CEE7; Fri, 31 Oct 2025 14:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761919322; bh=A5E/QjiASGwXRgkMRYgzEvvhs5WyGzad+a4CEXvLsw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XO8F79VQOXPo5hz+KY+vgGyC/+EQSei8xLseyvuTSySL+iM4+FtSZt5KXaL2zSf/7 A+x7oOoTwX1MK6HdtSfjrSWYLQC/Ke3nnVT2QeLx40l59nWudAsFZvulSw4/W7AZVc gSqi6fB012BKKCUh0Fv+/sXBVaZqlqRjvjwsRtfk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 6.6 12/32] btrfs: always drop log root tree reference in btrfs_replay_log() Date: Fri, 31 Oct 2025 15:01:06 +0100 Message-ID: <20251031140042.714780590@linuxfoundation.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251031140042.387255981@linuxfoundation.org> References: <20251031140042.387255981@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit 2f5b8095ea47b142c56c09755a8b1e14145a2d30 ] Currently we have this odd behaviour: 1) At btrfs_replay_log() we drop the reference of the log root tree if the call to btrfs_recover_log_trees() failed; 2) But if the call to btrfs_recover_log_trees() did not fail, we don't drop the reference in btrfs_replay_log() - we expect that btrfs_recover_log_trees() does it in case it returns success. Let's simplify this and make btrfs_replay_log() always drop the reference on the log root tree, not only this simplifies code as it's what makes sense since it's btrfs_replay_log() who grabbed the reference in the first place. Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/tree-log.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index bb5f7911d473c..7ad1734cbbfc9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2080,10 +2080,10 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info, /* returns with log_tree_root freed on success */ ret = btrfs_recover_log_trees(log_tree_root); + btrfs_put_root(log_tree_root); if (ret) { btrfs_handle_fs_error(fs_info, ret, "Failed to recover log tree"); - btrfs_put_root(log_tree_root); return ret; } diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 4b53e19f7520f..e00298c6c30a1 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -7422,7 +7422,6 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) log_root_tree->log_root = NULL; clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags); - btrfs_put_root(log_root_tree); return 0; error: -- 2.51.0