]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: replace BUG() with error handling in __btrfs_balance()
authorAdarsh Das <adarshdas950@gmail.com>
Tue, 3 Feb 2026 17:23:57 +0000 (22:53 +0530)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:20:49 +0000 (07:20 -0500)
[ Upstream commit be6324a809dbda76d5fdb23720ad9b20e5c1905c ]

We search with offset (u64)-1 which should never match exactly.
Previously this was handled with BUG(). Now logs an error
and return -EUCLEAN.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Adarsh Das <adarshdas950@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/volumes.c

index 99e167a697ba8e08b571017bc607c527ad2b64d6..1cbe7c6a2889c318bf42b955bd9c1338bf9a8929 100644 (file)
@@ -4234,8 +4234,14 @@ again:
                 * this shouldn't happen, it means the last relocate
                 * failed
                 */
-               if (ret == 0)
-                       BUG(); /* FIXME break ? */
+               if (unlikely(ret == 0)) {
+                       btrfs_err(fs_info,
+                                 "unexpected exact match of CHUNK_ITEM in chunk tree, offset 0x%llx",
+                                 key.offset);
+                       mutex_unlock(&fs_info->reclaim_bgs_lock);
+                       ret = -EUCLEAN;
+                       goto error;
+               }
 
                ret = btrfs_previous_item(chunk_root, path, 0,
                                          BTRFS_CHUNK_ITEM_KEY);