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 86F4A4F55DB; Wed, 30 Sep 2026 15:41:40 +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=1790782905; cv=none; b=HOBWG8Z4ScL401C5yzhjVERTsudAvb9/oa+vtOGj7lUxSjrftmzkBI1kd/1+BiPBs/9Ov5t3GhmYfhAgMZkbspbSxLV/6knLrw+k81oV22Impoig3G/mgagkjEYBWrRDClTdGdXlz+SFjrZ9KOq5tjPjBZZJOsCQRGvlAdGNhbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790782905; c=relaxed/simple; bh=IXwshge6qLATqAVdjt7rjiYLvCdeFWiS9vj+RsZRD0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dNEkkhC0Ygn0giVvYYlC1O8oypJjp+PRu1fcJZ3IhpfZse1f3MFMWF+NdBICC0CwfQX52ar3wvRv0OB1RD3upDGu1qblLXavm332CW9huD+OUBvsIkFhCYma7Dpe/XUxrI1upyNCx7G+QzhhJR6urEJNiFZoZSAXfi2sNc28WVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lLJIGNB1; 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="lLJIGNB1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 089C11F000FF; Wed, 30 Sep 2026 15:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790782899; bh=2otzwxi7vU2djeOq1vPDZXcY+GMR1oSIr1uaPlg77Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lLJIGNB14vbm2IRNRifZxay9tr+1NmhnSRRDOAUkXyb11GVgQaR87yWODkXXWQb65 qoTVj1WPuhJFgTzyOh6CTTdbSzbIGa87sJUX/GEvYBjb97UvM3LEG3gmlbSBXYbhab 7w3ZMaZZL8YmYrsUfgtikoLkz5tS7H4/EvQNmj2Y= 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.10 164/595] btrfs: fix reloc root cleanup in merge_reloc_roots() Date: Wed, 30 Sep 2026 17:20:57 +0200 Message-ID: <20260930152351.265205618@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152347.700140858@linuxfoundation.org> References: <20260930152347.700140858@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.10-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 db8a2a3e99f2d..34be7160cc9ce 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1974,11 +1974,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