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>
This commit is contained in:
Qu Wenruo 2023-05-24 15:41:28 +08:00 committed by David Sterba
parent 7f077e3173
commit 1aa4a9c609
1 changed files with 10 additions and 0 deletions

View File

@ -875,6 +875,15 @@ static int resume_data_csum_change(struct btrfs_fs_info *fs_info, u16 new_csum_t
goto new_data_csums;
}
/*
* Both old and new csum exist, and old csum is a subset of the new ones.
*
* This means we're deleting the old csums.
*/
if (old_csum_found && new_csum_found && new_csum_first <= old_csum_first &&
new_csum_last >= old_csum_last)
goto delete_old;
/* Other cases are not yet supported. */
return -EOPNOTSUPP;
@ -885,6 +894,7 @@ new_data_csums:
error("failed to generate new data csums: %m");
return ret;
}
delete_old:
ret = delete_old_data_csums(fs_info);
if (ret < 0)
return ret;