FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH] generic: test replacing a xattr with a larger value
@ 2026-09-25 16:50 fdmanana
  2026-09-25 17:16 ` [PATCH v2] " fdmanana
  0 siblings, 1 reply; 6+ messages in thread
From: fdmanana @ 2026-09-25 16:50 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Test that replacing a xattr's value with a larger value works. This is a
test that exercises a specific scenario on btrfs where two xattrs are
stored in the same item, and for that to happen their names must result
in the same crc32c hash.

This was recently fixed by the following patch:

  "btrfs: fix xattr replace when multiple xattrs are packed in the same item"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/generic/806     | 43 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/806.out | 11 +++++++++++
 2 files changed, 54 insertions(+)
 create mode 100755 tests/generic/806
 create mode 100644 tests/generic/806.out

diff --git a/tests/generic/806 b/tests/generic/806
new file mode 100755
index 00000000..6d74f445
--- /dev/null
+++ b/tests/generic/806
@@ -0,0 +1,43 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
+#
+# FS QA Test 806
+#
+# Test replacing a xattr's value with a larger value.
+#
+. ./common/preamble
+_begin_fstest auto quick metadata attr
+
+. ./common/filter
+. ./common/attr
+
+_require_scratch
+_require_attrs
+
+fixed_by_fs_commit btrfs xxxxxxxxxxxx \
+   "btrfs: fix xattr replace when multiple xattrs are packed in the same item"
+
+_scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+touch $SCRATCH_MNT/testfile
+
+# Add two xattrs that, on btrfs, have the same hash (crc32c) for their name
+# and therefore are packed into the same btrfs_dir_item.
+$SETFATTR_PROG -n user.foobar -v 123 $SCRATCH_MNT/testfile
+$SETFATTR_PROG -n user.WvG1c1Td -v qwerty $SCRATCH_MNT/testfile
+
+# Verify the xattrs are present.
+echo "xattrs before:"
+_getfattr --absolute-names --dump $SCRATCH_MNT/testfile | _filter_scratch
+
+# Now replace the value of the foobar xattr with a significantly larger value.
+$SETFATTR_PROG -n user.foobar -v abcdefghijklmnopqrstuvwxyz $SCRATCH_MNT/testfile
+
+# Check the xattrs have the expected values.
+echo "xattrs after:"
+_getfattr --absolute-names --dump $SCRATCH_MNT/testfile | _filter_scratch
+
+# success, all done
+_exit 0
diff --git a/tests/generic/806.out b/tests/generic/806.out
new file mode 100644
index 00000000..620a953e
--- /dev/null
+++ b/tests/generic/806.out
@@ -0,0 +1,11 @@
+QA output created by 806
+xattrs before:
+# file: SCRATCH_MNT/testfile
+user.WvG1c1Td="qwerty"
+user.foobar="123"
+
+xattrs after:
+# file: SCRATCH_MNT/testfile
+user.WvG1c1Td="qwerty"
+user.foobar="abcdefghijklmnopqrstuvwxyz"
+
-- 
2.47.2


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

end of thread, other threads:[~2026-09-27 11:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25 16:50 [PATCH] generic: test replacing a xattr with a larger value fdmanana
2026-09-25 17:16 ` [PATCH v2] " fdmanana
2026-09-25 20:05   ` Darrick J. Wong
2026-09-26  5:58   ` Qu Wenruo
2026-09-26 18:19     ` Filipe Manana
2026-09-27 11:44       ` Zorro Lang

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