Skip to content

Commit 03b4952

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: tune: implement resume support for data csum objectid change
When the csum conversion is interrupted when changing data csum objectid, we should just resume the objectid conversion. This situation can be detected by comparing the old and new csum items. They should both exist but doesn't intersect (interrupted halfway), or only new csum items exist (interrupted after we have deleted old csums). Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 1aa4a9c commit 03b4952

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tune/change-csum.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,26 @@ static int resume_data_csum_change(struct btrfs_fs_info *fs_info, u16 new_csum_t
884884
new_csum_last >= old_csum_last)
885885
goto delete_old;
886886

887-
/* Other cases are not yet supported. */
888-
return -EOPNOTSUPP;
887+
/*
888+
* Both csums exist but not covering each other, or only new csum exists.
889+
*
890+
* This means we have already deleted all the old csums, is going to or
891+
* have already started objectid change.
892+
*/
893+
if ((old_csum_found && new_csum_found && old_csum_last <= new_csum_first) &&
894+
(!old_csum_found && new_csum_found))
895+
goto change;
896+
897+
/* The remaining cases should not be possible. */
898+
error("unexpected resume condition:");
899+
error("old csum found=%d start=%llu last=%llu new csum found=%d start=%llu last=%llu",
900+
old_csum_found,
901+
old_csum_found ? old_csum_first : 0,
902+
old_csum_found ? old_csum_last : 0,
903+
new_csum_found,
904+
new_csum_found ? new_csum_first : 0,
905+
new_csum_found ? new_csum_last : 0);
906+
return -EUCLEAN;
889907

890908
new_data_csums:
891909
ret = generate_new_data_csums_range(fs_info, resume_start, new_csum_type);
@@ -898,6 +916,7 @@ static int resume_data_csum_change(struct btrfs_fs_info *fs_info, u16 new_csum_t
898916
ret = delete_old_data_csums(fs_info);
899917
if (ret < 0)
900918
return ret;
919+
change:
901920
ret = change_csum_objectids(fs_info);
902921
if (ret < 0)
903922
return ret;

0 commit comments

Comments
 (0)