Commit 7733b8dd authored by David Sterba's avatar David Sterba

btrfs: abort transaction on errors in btrfs_free_chunk()

The errors during removing a chunk item are fatal, we expect to have a
matching item in the chunk map from which the chunk_offset is taken.
Handle that by transaction abort.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b9878a89
...@@ -2989,16 +2989,19 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset) ...@@ -2989,16 +2989,19 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
if (ret < 0) if (ret < 0)
goto out; goto out;
else if (ret > 0) { /* Logic error or corruption */ else if (ret > 0) { /* Logic error or corruption */
btrfs_handle_fs_error(fs_info, -ENOENT, btrfs_err(fs_info, "failed to lookup chunk %llu when freeing",
"Failed lookup while freeing chunk."); chunk_offset);
ret = -ENOENT; btrfs_abort_transaction(trans, -ENOENT);
ret = -EUCLEAN;
goto out; goto out;
} }
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
if (ret < 0) if (ret < 0) {
btrfs_handle_fs_error(fs_info, ret, btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset);
"Failed to delete chunk item."); btrfs_abort_transaction(trans, ret);
goto out;
}
out: out:
btrfs_free_path(path); btrfs_free_path(path);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment