Skip to contentSkip to conversation

btrfs-progs: check/lowmem: fix false alerts on

PATCH New Qu Wenruo 1 participant 4 messages Apr 12 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

cover btrfs-progs: check/lowmem: fix false alerts on

The lowmem mode check doesn't recognize the new EXTENT_OWNER_REF key type, thus it will always treat it as an unknown inline type and cause false alerts.

Fix it by adding such types to lowmem check.

The first patch is to fix a format string error during the add of inline backref sequence output, which breaks the indent.

The second patch is the real fix for lowmem btrfs check on squota feature.

The last one is a new test case for fsck on squota.

Qu Wenruo (3):
btrfs-progs: print-tree: fix the format string for
EXTENT_OWNER_REF_KEY
btrfs-progs: check/lowmem: fix false alerts about EXTENT_OWNER
btrfs-progs: fsck-tests: add a new test case for squota lowmem false
alerts

 check/mode-lowmem.c                 |  7 +++++++
 kernel-shared/print-tree.c          |  2 +-
 tests/fsck-tests/073-squota/test.sh | 31 +++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 tests/fsck-tests/073-squota/test.sh

--
2.53.0

author
#1 lore raw

PATCH 1/3 btrfs-progs: print-tree: fix the format string for EXTENT_OWNER_REF_KEY

There is missing tab for EXTENT_OWNER_REF_KEY, which results output not following the same indent:

	item 13 key (84082688 EXTENT_ITEM 1048576) itemoff 15763 itemsize 62
		refs 1 gen 14 flags DATA
	(172 0x100) textent owner root 256 <<<
		(178 0xdea30debbf5f519) extent data backref root 256 objectid 258 offset 0 count 1

And it's caused by a misplaced 't':

			printf("\t\(%u 0x%llx) textent owner root %llu\n",

There is no special escape sequence "\(", nor the word "textent", it looks like the 't' is incorrectly placed by commit ad8a831a742c ("btrfs-progs: dump-tree: output the sequence number for inline references").

Fix it so that the output is correct now:

	item 13 key (84082688 EXTENT_ITEM 1048576) itemoff 15763 itemsize 62
		refs 1 gen 14 flags DATA
		(172 0x100) textent owner root 256
		(178 0xdea30debbf5f519) extent data backref root 256 objectid 258 offset 0 count 1
---
 kernel-shared/print-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shared/print-tree.c +1 -1
index 28d6f4ded3f4..0afa36963b6a 100644
@@ -579,7 +579,7 @@ void print_extent_item(struct extent_buffer *eb, int slot, int metadata)
 			       type, seq, offset, btrfs_shared_data_ref_count(eb, sref));
 			break;
 		case BTRFS_EXTENT_OWNER_REF_KEY:
-			printf("\t\(%u 0x%llx) textent owner root %llu\n",
+			printf("\t\t(%u 0x%llx) extent owner root %llu\n",
 			       type, seq, offset);
 			break;
 		default:
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH 2/3 btrfs-progs: check/lowmem: fix false alerts about EXTENT_OWNER

In reply to Qu Wenruo

[BUG]
When simple quota is enabled, lowmem will give false alerts:

[3/8] checking extents
ERROR: extent[13631488 168 1048576] has unknown ref type: 172
ERROR: extent[63963136 168 131072] has unknown ref type: 172
ERROR: extent[63963136 168 131072] has unknown ref type: 172
ERROR: file extent[257 0] root 256 owner 256 backref lost
ERROR: extent[13631488 168 1048576] has unknown ref type: 172
ERROR: file extent[258 0] root 256 owner 256 backref lost
ERROR: errors found in extent allocation tree or chunk allocation

[CAUSE]
Lowmem mode has strict checks on the inlined backref type, and unfortunately EXTENT_OWNER_REF is not inside the support 4 backre types, thus it's treated as an unknown type, and caused the false alerts.

[FIX]
Add the EXTENT_OWNER_REF type into the supported types.

For lowmem check itself, those key types are just skipped as it's only to indicate the owner of a data extent, which will be verified by qgroup part.

---
 check/mode-lowmem.c | 7 +++++++
 1 file changed, 7 insertions(+)
check/mode-lowmem.c +7 -0
index 9db58f6c1702..a7465268ad89 100644
@@ -3053,6 +3053,7 @@ static int check_extent_inline_ref(struct extent_buffer *eb,
 	case BTRFS_EXTENT_DATA_REF_KEY:
 	case BTRFS_SHARED_BLOCK_REF_KEY:
 	case BTRFS_SHARED_DATA_REF_KEY:
+	case BTRFS_EXTENT_OWNER_REF_KEY:
 		ret = 0;
 		break;
 	default:
@@ -4645,6 +4646,12 @@ next:
 		parent = offset;
 		tmp_err |= check_shared_data_backref(offset, key.objectid);
 		break;
+	case BTRFS_EXTENT_OWNER_REF_KEY:
+		/*
+		 * This is showing the initial owner for SIMPLE QUOTA.
+		 * It will be hanled by qgroup check, skip it here.
+		 */
+		break;
 	default:
 		error("extent[%llu %d %llu] has unknown ref type: %d",
 			key.objectid, key.type, key.offset, type);
Signature · 1 line
2.53.0
author
#3 lore raw

PATCH 3/3 btrfs-progs: fsck-tests: add a new test case for squota lowmem false alerts

In reply to Qu Wenruo

The new test script will fill a btrfs with squota enabled:

- A file with regular data extents
- A file with preallocated extents
- Several files with inline extents to bump up the tree level
- Snapshot of a subvolume containing above files

Then run btrfs check to verify no error is found.

---
 tests/fsck-tests/073-squota/test.sh | 31 +++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100755 tests/fsck-tests/073-squota/test.sh
tests/fsck-tests/073-squota/test.sh new file +31 -0
new file mode 100755
index 000000000000..54a38d9b2d18
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Make sure "btrfs check" can handle EXTENT_OWNER_REF key type for squota
+#
+
+source "$TEST_TOP/common" || exit
+
+check_prereq btrfs
+check_prereq mkfs.btrfs
+check_global_prereq fallocate
+
+if [ ! -f /sys/fs/btrfs/features/simple_quota ] ; then
+	_not_run "no kernel simple quota support"
+fi
+
+setup_root_helper
+prepare_test_dev
+
+run_check_mkfs_test_dev -O squota
+run_check_mount_test_dev
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
+run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=1 of="$TEST_MNT/subv1/regular"
+run_check $SUDO_HELPER fallocate -l 8m "$TEST_MNT/subv1/preallocated"
+for ((i = 0; i < 64; i++)); do
+	run_check $SUDO_HELPER dd if=/dev/urandom bs=1K count=1 of="$TEST_MNT/subv1/inline_$i"
+done
+
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot "$TEST_MNT/subv1" "$TEST_MNT/snap1"
+run_check_umount_test_dev
+
+run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
Signature · 1 line
2.53.0