public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs-progs: check/lowmem: fix false alerts on
@ 2026-04-12  5:08 Qu Wenruo
  2026-04-12  5:08 ` [PATCH 1/3] btrfs-progs: print-tree: fix the format string for EXTENT_OWNER_REF_KEY Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-04-12  5:08 UTC (permalink / raw)
  To: linux-btrfs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] btrfs-progs: print-tree: fix the format string for EXTENT_OWNER_REF_KEY
  2026-04-12  5:08 [PATCH 0/3] btrfs-progs: check/lowmem: fix false alerts on Qu Wenruo
@ 2026-04-12  5:08 ` Qu Wenruo
  2026-04-12  5:08 ` [PATCH 2/3] btrfs-progs: check/lowmem: fix false alerts about EXTENT_OWNER Qu Wenruo
  2026-04-12  5:08 ` [PATCH 3/3] btrfs-progs: fsck-tests: add a new test case for squota lowmem false alerts Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-04-12  5:08 UTC (permalink / raw)
  To: linux-btrfs

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

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 kernel-shared/print-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 28d6f4ded3f4..0afa36963b6a 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -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:
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] btrfs-progs: check/lowmem: fix false alerts about EXTENT_OWNER
  2026-04-12  5:08 [PATCH 0/3] btrfs-progs: check/lowmem: fix false alerts on Qu Wenruo
  2026-04-12  5:08 ` [PATCH 1/3] btrfs-progs: print-tree: fix the format string for EXTENT_OWNER_REF_KEY Qu Wenruo
@ 2026-04-12  5:08 ` Qu Wenruo
  2026-04-12  5:08 ` [PATCH 3/3] btrfs-progs: fsck-tests: add a new test case for squota lowmem false alerts Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-04-12  5:08 UTC (permalink / raw)
  To: linux-btrfs

[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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/mode-lowmem.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 9db58f6c1702..a7465268ad89 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -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);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] btrfs-progs: fsck-tests: add a new test case for squota lowmem false alerts
  2026-04-12  5:08 [PATCH 0/3] btrfs-progs: check/lowmem: fix false alerts on Qu Wenruo
  2026-04-12  5:08 ` [PATCH 1/3] btrfs-progs: print-tree: fix the format string for EXTENT_OWNER_REF_KEY Qu Wenruo
  2026-04-12  5:08 ` [PATCH 2/3] btrfs-progs: check/lowmem: fix false alerts about EXTENT_OWNER Qu Wenruo
@ 2026-04-12  5:08 ` Qu Wenruo
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-04-12  5:08 UTC (permalink / raw)
  To: linux-btrfs

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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 tests/fsck-tests/073-squota/test.sh | 31 +++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100755 tests/fsck-tests/073-squota/test.sh

diff --git a/tests/fsck-tests/073-squota/test.sh b/tests/fsck-tests/073-squota/test.sh
new file mode 100755
index 000000000000..54a38d9b2d18
--- /dev/null
+++ b/tests/fsck-tests/073-squota/test.sh
@@ -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"
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-12  5:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12  5:08 [PATCH 0/3] btrfs-progs: check/lowmem: fix false alerts on Qu Wenruo
2026-04-12  5:08 ` [PATCH 1/3] btrfs-progs: print-tree: fix the format string for EXTENT_OWNER_REF_KEY Qu Wenruo
2026-04-12  5:08 ` [PATCH 2/3] btrfs-progs: check/lowmem: fix false alerts about EXTENT_OWNER Qu Wenruo
2026-04-12  5:08 ` [PATCH 3/3] btrfs-progs: fsck-tests: add a new test case for squota lowmem false alerts Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox