Skip to content

Commit 6c701fb

Browse files
committed
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: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 3ea6970 commit 6c701fb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

fs/btrfs/volumes.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,16 +2989,19 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
29892989
if (ret < 0)
29902990
goto out;
29912991
else if (ret > 0) { /* Logic error or corruption */
2992-
btrfs_handle_fs_error(fs_info, -ENOENT,
2993-
"Failed lookup while freeing chunk.");
2994-
ret = -ENOENT;
2992+
btrfs_err(fs_info, "failed to lookup chunk %llu when freeing",
2993+
chunk_offset);
2994+
btrfs_abort_transaction(trans, -ENOENT);
2995+
ret = -EUCLEAN;
29952996
goto out;
29962997
}
29972998

29982999
ret = btrfs_del_item(trans, root, path);
2999-
if (ret < 0)
3000-
btrfs_handle_fs_error(fs_info, ret,
3001-
"Failed to delete chunk item.");
3000+
if (ret < 0) {
3001+
btrfs_err(fs_info, "failed to delete chunk %llu item", chunk_offset);
3002+
btrfs_abort_transaction(trans, ret);
3003+
goto out;
3004+
}
30023005
out:
30033006
btrfs_free_path(path);
30043007
return ret;

0 commit comments

Comments
 (0)