diff mbox series

[5/7] btrfs-progs: tune: implement resume support for half deleted old csums

Message ID e6ba13630eedc0b8a893520841342190a7297843.1684913599.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: tune: add resume support for csum conversion | expand

Commit Message

Qu Wenruo May 24, 2023, 7:41 a.m. UTC
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>
---
 tune/change-csum.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/tune/change-csum.c b/tune/change-csum.c
index aef3b05a0d9d..2ec2d6cc5271 100644
--- a/tune/change-csum.c
+++ b/tune/change-csum.c
@@ -876,6 +876,15 @@  static int resume_data_csum_change(struct btrfs_fs_info *fs_info,
 		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;
 
@@ -886,6 +895,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;