btrfs-progs: check/lowmem: fix false alerts about verity items
PATCH 1/2 btrfs-progs: check/lowmem: recognize verity item keys
In reply to Qu WenruoCommit 4e88bb6e ("btrfs-progs: enhance detection on unknown inode keys") added stricter validation for inode keys in the lowmem mode checker, flagging unknown key types as errors. However, it did not add cases for BTRFS_VERITY_DESC_ITEM_KEY (36) and BTRFS_VERITY_MERKLE_ITEM_KEY (37), causing any filesystem with fs-verity enabled files to fail the lowmem mode check with the following error:
[5/8] checking fs roots
ERROR: ITEM[257 36 0] UNKNOWN TYPE in leaf 30490624
ERROR: ITEM[257 36 1] UNKNOWN TYPE in leaf 30490624
ERROR: ITEM[257 37 0] UNKNOWN TYPE in leaf 30490624
ERROR: ITEM[257 37 2048] UNKNOWN TYPE in leaf 30490624
ERROR: errors found in fs roots
Add the missing switch cases so that verity metadata items are recognized and silently skipped during the lowmem check.
--- check/mode-lowmem.c | 3 +++ 1 file changed, 3 insertions(+)
check/mode-lowmem.c +3 -0
@@ -2817,7 +2817,10 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path) err |= ret;break ;case BTRFS_XATTR_ITEM_KEY : +case BTRFS_VERITY_DESC_ITEM_KEY : +case BTRFS_VERITY_MERKLE_ITEM_KEY :break ; +default :error ("ITEM[%llu %u %llu] UNKNOWN TYPE in leaf %llu" , key.objectid, key.type, key.offset, node->start);
Signature · 1 line
2.53.0
PATCH 2/2 btrfs-progs: fsck-tests: add a test case for verity items
In reply to Qu WenruoLeo recently fixed a false alerts in btrfs-check where verity items are reported as unknown items.
Add a test case for such case, the image is generated by enabling fsverity on a small file, which will have VERITY_DESC_ITEM and VERITY_MERKLE_ITEM items to trigger the previous false alerts.
--- .../fsck-tests/072-verity-items/fsverity.img.xz | Bin 0 -> 2364 bytes tests/fsck-tests/072-verity-items/test.sh | 15 +++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/fsck-tests/072-verity-items/fsverity.img.xz create mode 100755 tests/fsck-tests/072-verity-items/test.sh
tests/fsck-tests/072-verity-items/fsverity.img.xz new file binary +0 -0
tests/fsck-tests/072-verity-items/test.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/bash +# +# Verify that check can handle btrfs with fsverity features properly + +source "$TEST_TOP/common" || exit + +check_prereq btrfs + +check_image() { + # The image contains verity data in the fs tree. + # The check should not report verity items as errors. + run_check "$TOP/btrfs" check "$1" +} + +check_all_images
Signature · 1 line
2.53.0
cover btrfs-progs: check/lowmem: fix false alerts about verity items
Leo reported and fixed a bug in original mode where false alerts were triggered about verity items.
Unfortunately we have a similar problem in lowmem mode too.
Fix the lowmem mode false alert and add a test case to prevent similar problems in the future.
Qu Wenruo (2):
btrfs-progs: check/lowmem: recognize verity item keys
btrfs-progs: fsck-tests: add a test case for verity items
check/mode-lowmem.c | 3 +++ .../fsck-tests/072-verity-items/fsverity.img.xz | Bin 0 -> 2364 bytes tests/fsck-tests/072-verity-items/test.sh | 15 +++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/fsck-tests/072-verity-items/fsverity.img.xz create mode 100755 tests/fsck-tests/072-verity-items/test.sh
--
2.53.0