Skip to content

btrfs-progs: csum-change: add the initial support for offline csum type change

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 3 repliesIn review
  2. v17 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Skip csum item checks if the fs is under csum change Tree-checker can be too sensitive if the csum size doesn not match the old csum size, which can lead to false alerts on overlapping csum items.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7btrfs-progs: tune: rework the main idea of csum changekernel-shared/ctree.c kernel-shared/ctree.h kernel-shared/disk-io.c +6 more+34 -5430 replies
2/7btrfs-progs: tune: implement the prerequisite checks for csum changetune/change-csum.c+59 -00 replies
3/7btrfs-progs: tune: add the ability to read and verify the data before generating new checksumtune/change-csum.c+244 -00 replies
4/7btrfs-progs: tune: add the ability to generate new data checksumscheck/mode-common.c convert/main.c kernel-shared/file-item.c +4 more+52 -350 replies
5/7btrfs-progs: tune: add the ability to delete old data csumstune/change-csum.c+65 -00 replies
6/7btrfs-progs: tune: add the ability to migrate the temporary csum items to regular csum itemstune/change-csum.c+86 -00 replies
7/7btrfs-progs: tune: add the ability to change metadata csumstune/change-csum.c+142 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/7] btrfs-progs: csum-change: add the initial support for offline csum type change

[CHANGELOG]
v2:
- Skip csum item checks if the fs is under csum change Tree-checker can be too sensitive if the csum size doesn not match the old csum size, which can lead to false alerts on overlapping csum items.

But we still want the tree checker functionality overall, so just disable csum item related checks for csum change.

[DESIGN]
The csum change workflow looks like this:

- Generate new data csums
New data csums would have a different objectid (CSUM_CHANGE -13), other than the existing one (EXTENT_CSUM -10).

The generation part would also verify the data contents, if any mismatch we would error out.

- Delete the old data csums

- Change data csums objectid

- Rewrite metadata csums in-place
At this stage, we would check the checksum for both old and new algo. If the metadata matches the old csum, we rewrite using new csum. If the metadata matches the new csum, we skip it.
If the metadata doesn't match either csum, we error out.

[TESTS]
For now it's only basically tested manually.

So far the result looks good, the result fs can pass "btrfs check --check-data-csum".

[TODO]
- Support for resume
Currently we won't resume an interrupted csum conversion. Although the design should be able to handle any interruption at data csum conversion part, and as long as metadata csum writes are atomic, the metadata rewrites should also be fine.

- Support for revert if errors are found
If we hit data csum mismatch and can not repair from any copy, then we should revert back to the old csum.

- Suppot for precaustious metadata check
We'd better read and very metadata before rewriting them.

- Extra test cases

Qu Wenruo (7):
btrfs-progs: tune: rework the main idea of csum change
btrfs-progs: tune: implement the prerequisite checks for csum change
btrfs-progs: tune: add the ability to read and verify the data before
generating new checksum
btrfs-progs: tune: add the ability to generate new data checksums
btrfs-progs: tune: add the ability to delete old data csums
btrfs-progs: tune: add the ability to migrate the temporary csum items
to regular csum items
btrfs-progs: tune: add the ability to change metadata csums

 check/mode-common.c             |   11 +-
 convert/main.c                  |   12 +-
 kernel-shared/ctree.c           |    3 -
 kernel-shared/ctree.h           |   19 +-
 kernel-shared/disk-io.c         |    8 -
 kernel-shared/file-item.c       |   46 +-
 kernel-shared/file-item.h       |    4 +-
 kernel-shared/print-tree.c      |   11 +-
 kernel-shared/tree-checker.c    |    5 +
 kernel-shared/uapi/btrfs_tree.h |    1 +
 mkfs/rootdir.c                  |   11 +-
 tune/change-csum.c              | 1053 +++++++++++++++++--------------
 tune/main.c                     |    2 +-
 tune/tune.h                     |    3 +-
 14 files changed, 646 insertions(+), 543 deletions(-)
Signature · 1 line
2.40.1