Skip to content

Commit 1aa4a9c

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: tune: implement resume support for half deleted old csums
If the csum conversion is interrupted when old csums are being deleted, we should resume by continue deleting the old csums. The function delete_old_data_csums() can handle half deleted cases already. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7f077e3 commit 1aa4a9c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tune/change-csum.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,15 @@ static int resume_data_csum_change(struct btrfs_fs_info *fs_info, u16 new_csum_t
875875
goto new_data_csums;
876876
}
877877

878+
/*
879+
* Both old and new csum exist, and old csum is a subset of the new ones.
880+
*
881+
* This means we're deleting the old csums.
882+
*/
883+
if (old_csum_found && new_csum_found && new_csum_first <= old_csum_first &&
884+
new_csum_last >= old_csum_last)
885+
goto delete_old;
886+
878887
/* Other cases are not yet supported. */
879888
return -EOPNOTSUPP;
880889

@@ -885,6 +894,7 @@ static int resume_data_csum_change(struct btrfs_fs_info *fs_info, u16 new_csum_t
885894
error("failed to generate new data csums: %m");
886895
return ret;
887896
}
897+
delete_old:
888898
ret = delete_old_data_csums(fs_info);
889899
if (ret < 0)
890900
return ret;

0 commit comments

Comments
 (0)