diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index eaf5cd043dacea0bb54bbb9e32a8d806ef87b4e0..6f5735bec8e28f953184d813cd310216a6b7757b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3178,7 +3178,18 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info) mutex_unlock(&fs_info->delete_unused_bgs_mutex); goto error; } - BUG_ON(ret == 0); /* Corruption */ + if (ret == 0) { + /* + * On the first search we would find chunk tree with + * offset -1, which is not possible. On subsequent + * loops this would find an existing item on an invalid + * offset (one less than the previous one, wrong + * alignment and size). + */ + ret = -EUCLEAN; + mutex_unlock(&fs_info->delete_unused_bgs_mutex); + goto error; + } ret = btrfs_previous_item(chunk_root, path, key.objectid, key.type);