Skip to content

Commit

Permalink
btrfs-progs: change-csum: add error handling for search old checksums
Browse files Browse the repository at this point in the history
Inside delete_old_data_csums(), after calling btrfs_search_slot() there
is no error handling at all.

Fix it by doing a proper error detection and abort the current transaction.

Signed-off-by: Qu Wenruo <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
adam900710 authored and kdave committed Jun 27, 2024
1 parent db2cd62 commit 8e8c554
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tune/change-csum.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ static int delete_old_data_csums(struct btrfs_fs_info *fs_info)
int nr;

ret = btrfs_search_slot(trans, csum_root, &last_key, &path, -1, 1);
if (ret < 0) {
errno = -ret;
error("failed to search the last old csum item: %m");
btrfs_abort_transaction(trans, ret);
return ret;
}
assert(ret > 0);

nr = btrfs_header_nritems(path.nodes[0]);
/* No item left (empty csum tree), exit. */
Expand Down

0 comments on commit 8e8c554

Please sign in to comment.