Skip to content

Commit ca84db7

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: change-csum: add error handling for search old checksums
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]>
1 parent 04bb847 commit ca84db7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tune/change-csum.c

+7
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ static int delete_old_data_csums(struct btrfs_fs_info *fs_info)
395395
int nr;
396396

397397
ret = btrfs_search_slot(trans, csum_root, &last_key, &path, -1, 1);
398+
if (ret < 0) {
399+
errno = -ret;
400+
error("failed to search the last old csum item: %m");
401+
btrfs_abort_transaction(trans, ret);
402+
return ret;
403+
}
404+
assert(ret > 0);
398405

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

0 commit comments

Comments
 (0)