From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3A1DD5187EB; Wed, 30 Sep 2026 17:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790791163; cv=none; b=fBk3dqQa3aiFOGg6TDraUOqoG5ico3ZPjWTyodPEf91bO7vuyStOYS9m8l4DJAvpghapAFTrpjgWKnMA+q2jLL5AQ788d+sQdfOLUCAKG4+ZeynVjh9R2mLP4CkunPZ5pMsykLzFpxpBjjDWpjvzjiFjXwbVyp1zSVE1uCp3d7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790791163; c=relaxed/simple; bh=G6InFzK5uoRzgnUHPr7dPySaSxEibxQL6UoCd/7gs2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P+ncfPElMUONELUtKOAkp6AFTC4WlutUJc9dtMJ3ize+BP1vB5ucx1ULqXK/5QCLKWcaD6IjpkJ7XPqPYAR2O6PHc/fB8Mt+lDtT8V5po/9kz7Q9p4fRcYnX239lwx/qe10Ar3Fv1Gf8dz9XAxr+gBpBZNnpnCv5gH8PaYw3xfk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fWyuRlQ9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fWyuRlQ9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93E971F000FF; Wed, 30 Sep 2026 17:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790791162; bh=780bODhlhzIZTJX2OOfuC9R01GBkWgJ6vOwrRCmZHaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fWyuRlQ97WpFrbI4JEfv2ZBPt66FP1iapTdCH9tn59ad+8G4bCLo6P4uOdlksGl/f UhYk0tOWVm81tEx6onr4svsH6fOfBfqEKHLPzOuF/fXy0dlQEHfhP5rt9SClcFtMKu qWRrIVLNKjKQswUm6Ryo05zsYr/FKCAU+hzacTUs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Boris Burkov , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 5.15 205/752] btrfs: fix reloc root cleanup in merge_reloc_roots() Date: Wed, 30 Sep 2026 17:21:15 +0200 Message-ID: <20260930152402.663695525@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit b78fe9563e2d5ae47805f1e5dc722c91fd30e1f8 ] If the root we got has zero root refs in its root item, we are resetting the root's ->reloc_root without using barriers like we do everywhere else. Sashiko complained about this while reviewing another patch, and it's correct (see the Link tag below). Also, we should not clear BTRFS_ROOT_DEAD_RELOC_TREE from the root unless the root points to the reloc root we have. Fix this by using clear_reloc_root(), which issues the memory barrier after setting the root's ->reloc_root to NULL and before clearing the bit BTRFS_ROOT_DEAD_RELOC_TREE from the root. Link: https://sashiko.dev/#/patchset/cf84f1a217c719e25b6b69e4298dd7afd36c9427.1781194426.git.fdmanana%40suse.com Reviewed-by: Boris Burkov Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/relocation.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 258b792045aa7..a95cab1433613 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2086,11 +2086,10 @@ void merge_reloc_roots(struct reloc_control *rc) } else { if (!IS_ERR(root)) { if (root->reloc_root == reloc_root) { - root->reloc_root = NULL; + clear_reloc_root(root); + /* Drop the ref for root->reloc_root. */ btrfs_put_root(reloc_root); } - clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, - &root->state); btrfs_put_root(root); } -- 2.53.0