From 1aa4a9c609496fd16d11d93c0c7c92ab1f958e4b Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 24 May 2023 15:41:28 +0800 Subject: [PATCH] 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 Signed-off-by: David Sterba --- tune/change-csum.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tune/change-csum.c b/tune/change-csum.c index 2fa48318..8716af02 100644 --- a/tune/change-csum.c +++ b/tune/change-csum.c @@ -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;