Commit 4d95b9ef authored by David Sterba's avatar David Sterba
Browse files

btrfs: handle unexpected free-space-tree key types



Replace the conditional assertions with proper error handling and
transaction abort if we find an unexpected key type in the free space
tree.

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 99975723
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -259,7 +259,11 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
				nr++;
				path->slots[0]--;
			} else {
				ASSERT(0);
				btrfs_err(fs_info, "unexpected free space tree key type %u",
					  found_key.type);
				ret = -EUCLEAN;
				btrfs_abort_transaction(trans, ret);
				goto out;
			}
		}

@@ -405,7 +409,11 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,

				nr++;
			} else {
				ASSERT(0);
				btrfs_err(fs_info, "unexpected free space tree key type %u",
					  found_key.type);
				ret = -EUCLEAN;
				btrfs_abort_transaction(trans, ret);
				goto out;
			}
		}

@@ -1518,7 +1526,11 @@ int btrfs_remove_block_group_free_space(struct btrfs_trans_handle *trans,
				nr++;
				path->slots[0]--;
			} else {
				ASSERT(0);
				btrfs_err(trans->fs_info, "unexpected free space tree key type %u",
					  found_key.type);
				ret = -EUCLEAN;
				btrfs_abort_transaction(trans, ret);
				return ret;
			}
		}