fstests: catch us up to 6.12-6.14 changes
PATCH 3/3 xfs: regression testing of quota on the realtime device
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Make sure that quota accounting and enforcement work correctly for realtime volumes on XFS.
--- tests/xfs/1858 | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1858.out | 47 ++++++++++++++ 2 files changed, 221 insertions(+) create mode 100755 tests/xfs/1858 create mode 100644 tests/xfs/1858.out
tests/xfs/1858 new file +174 -0
@@ -0,0 +1,174 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1858 +# +# Functional testing for realtime quotas. + +. ./common/preamble +_begin_fstest auto quick quota realtime + +. ./common/quota +. ./common/filter + +_require_test_program "punch-alternating" +_require_scratch +_require_user + +echo "Format filesystem" | tee -a $seqres.full +_scratch_mkfs > $seqres.full +_try_scratch_mount -o usrquota || \ + _notrun "Can't mount with realtime quota enabled" + +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_scratch_supports_rtquota || _notrun "Requires realtime quota" + +# Make sure all our files are on the rt device +_xfs_force_bdev realtime $SCRATCH_MNT +chmod a+rwx $SCRATCH_MNT + +# Record rt geometry +bmbt_blksz=$(_get_block_size $SCRATCH_MNT) +file_blksz=$(_get_file_block_size $SCRATCH_MNT) +rextsize=$((file_blksz / bmbt_blksz)) +echo "bmbt_blksz $bmbt_blksz" >> $seqres.full +echo "file_blksz $file_blksz" >> $seqres.full +echo "rextsize $rextsize" >> $seqres.full + +note() { + echo -e "\n$*" | tee -a $seqres.full +} + +# Report on the user's block and rt block usage, soft limit, hard limit, and +# warning count for rt volumes +report_rtusage() { + local user="$1" + local timeout_arg="$2" + local print_timeout=0 + + test -z "$user" && user=$qa_user + test -n "$timeout_arg" && print_timeout=1 + + $XFS_QUOTA_PROG -c "quota -u -r -n -N $user" $SCRATCH_MNT | \ + sed -e 's/ days/_days/g' >> $seqres.full + + $XFS_QUOTA_PROG -c "quota -u -r -n -N $user" $SCRATCH_MNT | \ + sed -e 's/ days/_days/g' | \ + awk -v user=$user -v print_timeout=$print_timeout -v file_blksz=$file_blksz \ + '{printf("%s[real] %d %d %d %d %s\n", user, $2 * 1024 / file_blksz, $3 * 1024 / file_blksz, $4 * 1024 / file_blksz, $5, print_timeout ? $6 : "---");}' +} + +note "Write 128rx to root" +$XFS_IO_PROG -f -c "pwrite 0 $((128 * file_blksz))" $SCRATCH_MNT/file1 > /dev/null +chmod a+r $SCRATCH_MNT/file1 +_scratch_sync +report_rtusage 0 + +note "Write 64rx to root, 4444, and 5555." +$XFS_IO_PROG -f -c "pwrite 0 $((64 * file_blksz))" $SCRATCH_MNT/file3.5555 > /dev/null +chown 5555 $SCRATCH_MNT/file3.5555 +$XFS_IO_PROG -f -c "pwrite 0 $((64 * file_blksz))" $SCRATCH_MNT/file3.4444 > /dev/null +chown 4444 $SCRATCH_MNT/file3.4444 +$XFS_IO_PROG -f -c "pwrite 0 $((64 * file_blksz))" $SCRATCH_MNT/file3 > /dev/null +_scratch_sync +report_rtusage 0 +report_rtusage 4444 +report_rtusage 5555 + +note "Move 64rx from root to 5555" +chown 5555 $SCRATCH_MNT/file3 +report_rtusage 0 +report_rtusage 4444 +report_rtusage 5555 + +note "Move 64rx from 5555 to 4444" +chown 4444 $SCRATCH_MNT/file3 +report_rtusage 0 +report_rtusage 4444 +report_rtusage 5555 + +note "Set hard limit of 1024rx and check enforcement" +$XFS_QUOTA_PROG -x -c "limit -u rtbhard=$((1024 * file_blksz)) $qa_user" $SCRATCH_MNT +# fsync (-w) after pwrite because enforcement only begins when space usage is +# committed. If delalloc is enabled, this doesn't happen until writeback. +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w 0 $((2048 * file_blksz))' $SCRATCH_MNT/file2" +report_rtusage + +note "Set soft limit of 512rx and check timelimit enforcement" +rm -f $SCRATCH_MNT/file2 $SCRATCH_MNT/file2.1 +period=6 # seconds +$XFS_QUOTA_PROG -x \ + -c "limit -u rtbsoft=$((512 * file_blksz)) rtbhard=0 $qa_user" \ + -c "timer -u -r -d $period" \ + -c 'state -u' $SCRATCH_MNT >> $seqres.full + +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w 0 $((512 * file_blksz))' $SCRATCH_MNT/file2" > /dev/null +report_rtusage + +overflow=$(date +%s) +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w -b $file_blksz 0 $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage +sleep $((period / 2)) +note "Try again after $((period / 2))s" +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w -b $file_blksz $file_blksz $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage +sleep $period +note "Try again after another ${period}s" +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w -b $file_blksz $((2 * file_blksz)) $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage + +note "Extend time limits and warnings" +rm -f $SCRATCH_MNT/file2 $SCRATCH_MNT/file2.1 +$XFS_QUOTA_PROG -x \ + -c "limit -u rtbsoft=$((512 * file_blksz)) rtbhard=0 $qa_user" \ + -c "timer -u -r -d 49h" $SCRATCH_MNT \ + -c 'state -u' $SCRATCH_MNT >> $seqres.full + +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w 0 $((512 * file_blksz))' $SCRATCH_MNT/file2" > /dev/null +report_rtusage $qa_user want_timeout + +note "Try to trip a 2 day grace period" +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w -b $file_blksz 0 $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage $qa_user want_timeout + +$XFS_QUOTA_PROG -x -c "timer -u -r 73h $qa_user" $SCRATCH_MNT + +note "Try to trip a 3 day grace period" +_su $qa_user -c "$XFS_IO_PROG -f -c 'pwrite -w -b $file_blksz $file_blksz $file_blksz' $SCRATCH_MNT/file2.1" > /dev/null +report_rtusage $qa_user want_timeout + +note "Test quota applied to bmbt" + +# Testing quota enforcement for bmbt shape changes is tricky. The block +# reservation will be for enough blocks to handle the maximal btree split. +# This is (approximately) 9 blocks no matter the size of the existing extent +# map structure, so we set the hard limit to one more than this quantity. +# +# However, that means that we need to make a file of at least twice that size +# to ensure that we create enough extent records even in the rextsize==1 case +# where punching doesn't just create unwritten records. +# +# Unfortunately, it's very difficult to predict when exactly the EDQUOT will +# come down, so we just look for the error message. +extent_records=$(( (25 * bmbt_blksz) / 16)) +echo "extent_records $extent_records" >> $seqres.full + +rm -f $SCRATCH_MNT/file2 +$XFS_QUOTA_PROG -x \ + -c "limit -u rtbsoft=0 rtbhard=0 $qa_user" \ + -c "limit -u bhard=$((bmbt_blksz * 10)) bsoft=0 $qa_user" \ + -c 'state -u' $SCRATCH_MNT >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x58 -b 64m 0 $((extent_records * file_blksz))" $SCRATCH_MNT/file2 > /dev/null +_scratch_sync +chown $qa_user $SCRATCH_MNT/file2 +$here/src/punch-alternating $SCRATCH_MNT/file2 2>&1 | _filter_scratch + +$XFS_QUOTA_PROG -c "quota -u -r -n -N $qa_user" -c "quota -u -b -n -N $qa_user" $SCRATCH_MNT >> $seqres.full +$XFS_IO_PROG -c "bmap -e -l -p -v" $SCRATCH_MNT/file2 >> $seqres.full + +# success, all done +$XFS_QUOTA_PROG -x -c 'report -a -u' -c 'report -a -u -r' $SCRATCH_MNT >> $seqres.full +ls -latr $SCRATCH_MNT >> $seqres.full +status=0 +exit
tests/xfs/1858.out new file +47 -0
47 lines not on this page · raw message
Re: [PATCH 3/3] xfs: regression testing of quota on the realtime device
Looks good:
PATCH 9/12 fstests: check new 6.14 behaviors
In reply to Darrick J. WongHi all,
Adjust fstests to check for new behaviors introduced in 6.14.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
With a bit of luck, this should all go splendidly. Comments and questions are, as always, welcome.
--D
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=linux-6.14-sync
---
Commits in this patchset:
* common: test statfs reporting with project quota
--- tests/generic/1955 | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1955.out | 13 +++++ 2 files changed, 127 insertions(+) create mode 100755 tests/generic/1955 create mode 100644 tests/generic/1955.out
PATCH 1/1 common: test statfs reporting with project quota
From: Darrick J. Wong <[email protected]>
Create a test to check that statfs on a directory tree with a project quota will report the quota limit and available blocks; and that the available blocks reported doesn't exceed that of the whole filesystem.
--- tests/generic/1955 | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1955.out | 13 +++++ 2 files changed, 127 insertions(+) create mode 100755 tests/generic/1955 create mode 100644 tests/generic/1955.out
tests/generic/1955 new file +114 -0
@@ -0,0 +1,114 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1955 +# +# Make sure that statfs reporting works when project quotas are set on a +# directory tree. +# +. ./common/preamble +_begin_fstest auto quota + +_fixed_by_git_commit kernel XXXXXXXXXXXXXX \ + "xfs: don't over-report free space or inodes in statvfs" + +. ./common/filter +. ./common/quota + +_require_quota +_require_scratch +_require_xfs_io_command 'chproj' +_require_xfs_io_command "falloc" + +_scratch_mkfs >$seqres.full 2>&1 +_scratch_enable_pquota +_qmount_option "prjquota" +_qmount +_force_vfs_quota_testing $SCRATCH_MNT +_require_prjquota $SCRATCH_DEV + +mkdir $SCRATCH_MNT/dir + +bsize() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_bsize | awk '{print $3}' +} + +blocks() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_blocks | awk '{print $3}' +} + +bavail() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_bavail | awk '{print $3}' +} + +bsize=$(bsize $SCRATCH_MNT) +orig_bavail=$(bavail $SCRATCH_MNT) +orig_blocks=$(blocks $SCRATCH_MNT) + +# Set a project quota limit of half the free space, make sure both report the +# same number of blocks +pquot_limit=$(( orig_bavail / 2 )) +setquota -P 55 0 $((pquot_limit * bsize / 1024))K 0 0 $SCRATCH_DEV +$XFS_IO_PROG -c 'chproj 55' -c 'chattr +P' $SCRATCH_MNT/dir + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks1" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks1" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +expected_dir_bavail=$pquot_limit +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail1" $fs_bavail $orig_bavail 1% -v +_within_tolerance "dir bavail1" $dir_bavail $expected_dir_bavail 1% -v + +# use up most of the free space in the filesystem +rem_free=$(( orig_bavail / 10 )) # bsize blocks +fallocate -l $(( (orig_bavail - rem_free) * bsize )) $SCRATCH_MNT/a + +if [ $rem_free -gt $pquot_limit ]; then + echo "rem_free $rem_free greater than pquot_limit $pquot_limit??" +fi + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks2" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks2" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail2" $fs_bavail $rem_free 1% -v +_within_tolerance "dir bavail2" $dir_bavail $rem_free 1% -v + +# use up 10 blocks of project quota +$XFS_IO_PROG -f -c "pwrite -S 0x99 0 $((bsize * 10))" -c fsync $SCRATCH_MNT/dir/a >> $seqres.full + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks3" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks3" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail3" $fs_bavail $rem_free 1% -v +_within_tolerance "dir bavail3" $dir_bavail $((rem_free - 10)) 1% -v + +# final state diagnostics +$XFS_IO_PROG -c 'statfs' $SCRATCH_MNT $SCRATCH_MNT/dir | grep statfs >> $seqres.full +repquota -P $SCRATCH_DEV >> $seqres.full +df $SCRATCH_MNT >> $seqres.full +ls -laR $SCRATCH_MNT/ >> $seqres.full + +# success, all done +status=0 +exit
tests/generic/1955.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 1955 +root blocks1 is in range +dir blocks1 is in range +root bavail1 is in range +dir bavail1 is in range +root blocks2 is in range +dir blocks2 is in range +root bavail2 is in range +dir bavail2 is in range +root blocks3 is in range +dir blocks3 is in range +root bavail3 is in range +dir bavail3 is in range
Re: [PATCH 1/1] common: test statfs reporting with project quota
Looks good:
Re: [PATCH 1/1] common: test statfs reporting with project quota
In reply to Darrick J. WongQuoted 25 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Create a test to check that statfs on a directory tree with a project quota will report the quota limit and available blocks; and that the available blocks reported doesn't exceed that of the whole filesystem.
Signed-off-by "Darrick J. Wong" <[email protected]>--- tests/generic/1955 | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1955.out | 13 +++++ 2 files changed, 127 insertions(+) create mode 100755 tests/generic/1955 create mode 100644 tests/generic/1955.outtests/generic/1955 new file +4
-0@@ -0,0 +1,114 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024-2025 Oracle. All Rights Reserved. +#
tests/generic/1955 line 14
Quoted 10 lines
tests/generic/1955 new file +10
-0+# FS QA Test No. 1955 +# +# Make sure that statfs reporting works when project quotas are set on a +# directory tree. +# +. ./common/preamble +_begin_fstest auto quota + +_fixed_by_git_commit kernel XXXXXXXXXXXXXX \ + "xfs: don't over-report free space or inodes in statvfs"
Ext4 fails on this test [1], is it a known issue of ext4 besides xfs?
Thanks,
Zorro
[1]
FSTYP -- ext4 PLATFORM -- Linux/aarch64 hpe-apollo-cn99xx-14-vm-28 6.14.0-rc4+ #1 SMP PREEMPT_DYNAMIC Sat Mar 1 16:57:43 EST 2025 MKFS_OPTIONS -- -F /dev/vda3
MOUNT_OPTIONS -- -o acl,user_xattr -o context=system_u:object_r:root_t:s0 /dev/vda3 /mnt/xfstests/scratch
generic/762 - output mismatch (see /var/lib/xfstests/results//generic/762.out.bad)
--- tests/generic/762.out 2025-03-01 17:23:52.961878242 -0500
+++ /var/lib/xfstests/results//generic/762.out.bad 2025-03-01 19:13:03.026588012 -0500
@@ -6,8 +6,10 @@
root blocks2 is in range
dir blocks2 is in range
root bavail2 is in range
-dir bavail2 is in range
+dir bavail2 has value of 1821553
+dir bavail2 is NOT in range 360666.9 .. 367953.1
root blocks3 is in range
...
(Run 'diff -u /var/lib/xfstests/tests/generic/762.out /var/lib/xfstests/results//generic/762.out.bad' to see the entire diff)
HINT: You _MAY_ be missing kernel fix:
XXXXXXXXXXXXXX xfs: don't over-report free space or inodes in statvfs
Ran: generic/762
Failures: generic/762
Failed 1 of 1 tests
Quoted 120 lines
tests/generic/1955 new file +100
-0+ +. ./common/filter +. ./common/quota + +_require_quota +_require_scratch +_require_xfs_io_command 'chproj' +_require_xfs_io_command "falloc" + +_scratch_mkfs >$seqres.full 2>&1 +_scratch_enable_pquota +_qmount_option "prjquota" +_qmount +_force_vfs_quota_testing $SCRATCH_MNT +_require_prjquota $SCRATCH_DEV + +mkdir $SCRATCH_MNT/dir + +bsize() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_bsize | awk '{print $3}' +} + +blocks() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_blocks | awk '{print $3}' +} + +bavail() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_bavail | awk '{print $3}' +} + +bsize=$(bsize $SCRATCH_MNT) +orig_bavail=$(bavail $SCRATCH_MNT) +orig_blocks=$(blocks $SCRATCH_MNT) + +# Set a project quota limit of half the free space, make sure both report the +# same number of blocks +pquot_limit=$(( orig_bavail / 2 )) +setquota -P 55 0 $((pquot_limit * bsize / 1024))K 0 0 $SCRATCH_DEV +$XFS_IO_PROG -c 'chproj 55' -c 'chattr +P' $SCRATCH_MNT/dir + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks1" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks1" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +expected_dir_bavail=$pquot_limit +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail1" $fs_bavail $orig_bavail 1% -v +_within_tolerance "dir bavail1" $dir_bavail $expected_dir_bavail 1% -v + +# use up most of the free space in the filesystem +rem_free=$(( orig_bavail / 10 )) # bsize blocks +fallocate -l $(( (orig_bavail - rem_free) * bsize )) $SCRATCH_MNT/a + +if [ $rem_free -gt $pquot_limit ]; then + echo "rem_free $rem_free greater than pquot_limit $pquot_limit??" +fi + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks2" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks2" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail2" $fs_bavail $rem_free 1% -v +_within_tolerance "dir bavail2" $dir_bavail $rem_free 1% -v + +# use up 10 blocks of project quota +$XFS_IO_PROG -f -c "pwrite -S 0x99 0 $((bsize * 10))" -c fsync $SCRATCH_MNT/dir/a >> $seqres.full + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks3" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks3" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail3" $fs_bavail $rem_free 1% -v +_within_tolerance "dir bavail3" $dir_bavail $((rem_free - 10)) 1% -v + +# final state diagnostics +$XFS_IO_PROG -c 'statfs' $SCRATCH_MNT $SCRATCH_MNT/dir | grep statfs >> $seqres.full +repquota -P $SCRATCH_DEV >> $seqres.full +df $SCRATCH_MNT >> $seqres.full +ls -laR $SCRATCH_MNT/ >> $seqres.full + +# success, all done +status=0 +exittests/generic/1955.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 1955 +root blocks1 is in range +dir blocks1 is in range +root bavail1 is in range +dir bavail1 is in range +root blocks2 is in range +dir blocks2 is in range +root bavail2 is in range +dir bavail2 is in range +root blocks3 is in range +dir blocks3 is in range +root bavail3 is in range +dir bavail3 is in range
Re: [PATCH 1/1] common: test statfs reporting with project quota
Quoted 31 lines · Zorro Lang
Quoted 30 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Create a test to check that statfs on a directory tree with a project quota will report the quota limit and available blocks; and that the available blocks reported doesn't exceed that of the whole filesystem.
Signed-off-by "Darrick J. Wong" <[email protected]>--- tests/generic/1955 | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1955.out | 13 +++++ 2 files changed, 127 insertions(+) create mode 100755 tests/generic/1955 create mode 100644 tests/generic/1955.outtests/generic/1955 new file +9
-0@@ -0,0 +1,114 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1955 +# +# Make sure that statfs reporting works when project quotas are set on a +# directory tree. +#
Quoted 8 lines
tests/generic/1955 line 14
Quoted 5 lines
tests/generic/1955 new file +5
-0+. ./common/preamble +_begin_fstest auto quota + +_fixed_by_git_commit kernel XXXXXXXXXXXXXX \ + "xfs: don't over-report free space or inodes in statvfs"Ext4 fails on this test [1], is it a known issue of ext4 besides xfs?
Yeah, known issue on ext4 (and probably f2fs too).
--D
Quoted 152 lines
Thanks,
Zorro[1]
FSTYP -- ext4 PLATFORM -- Linux/aarch64 hpe-apollo-cn99xx-14-vm-28 6.14.0-rc4+ #1 SMP PREEMPT_DYNAMIC Sat Mar 1 16:57:43 EST 2025 MKFS_OPTIONS -- -F /dev/vda3
MOUNT_OPTIONS-- -o acl,user_xattr -o context=system_u:object_r:root_t:s0/dev/vda3/mnt/xfstests/scratchgeneric/762 - output mismatch (see
/var/lib/xfstests/results//generic/762.out.bad)
--- tests/generic/762.out 2025-03-01 17:23:52.961878242 -0500
+++/var/lib/xfstests/results//generic/762.out.bad2025-03-01 19:13:03.026588012 -0500
@@ -6,8 +6,10 @@
root blocks2 is in range
dir blocks2 is in range
root bavail2 is in range
-dir bavail2 is in range
+dir bavail2 has value of 1821553
+dir bavail2 is NOT in range 360666.9 .. 367953.1
root blocks3 is in range
...
(Run 'diff -u/var/lib/xfstests/tests/generic/762.out/var/lib/xfstests/results//generic/762.out.bad' to see the entire diff)HINT: You _MAY_ be missing kernel fix:
XXXXXXXXXXXXXX xfs: don't over-report free space or inodes in statvfsRan: generic/762
Failures: generic/762
Failed 1 of 1 testsQuoted 120 lines
tests/generic/1955 new file +100
-0+ +. ./common/filter +. ./common/quota + +_require_quota +_require_scratch +_require_xfs_io_command 'chproj' +_require_xfs_io_command "falloc" + +_scratch_mkfs >$seqres.full 2>&1 +_scratch_enable_pquota +_qmount_option "prjquota" +_qmount +_force_vfs_quota_testing $SCRATCH_MNT +_require_prjquota $SCRATCH_DEV + +mkdir $SCRATCH_MNT/dir + +bsize() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_bsize | awk '{print $3}' +} + +blocks() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_blocks | awk '{print $3}' +} + +bavail() { + $XFS_IO_PROG -c 'statfs' $1 | grep f_bavail | awk '{print $3}' +} + +bsize=$(bsize $SCRATCH_MNT) +orig_bavail=$(bavail $SCRATCH_MNT) +orig_blocks=$(blocks $SCRATCH_MNT) + +# Set a project quota limit of half the free space, make sure both report the +# same number of blocks +pquot_limit=$(( orig_bavail / 2 )) +setquota -P 55 0 $((pquot_limit * bsize / 1024))K 0 0 $SCRATCH_DEV +$XFS_IO_PROG -c 'chproj 55' -c 'chattr +P' $SCRATCH_MNT/dir + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks1" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks1" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +expected_dir_bavail=$pquot_limit +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail1" $fs_bavail $orig_bavail 1% -v +_within_tolerance "dir bavail1" $dir_bavail $expected_dir_bavail 1% -v + +# use up most of the free space in the filesystem +rem_free=$(( orig_bavail / 10 )) # bsize blocks +fallocate -l $(( (orig_bavail - rem_free) * bsize )) $SCRATCH_MNT/a + +if [ $rem_free -gt $pquot_limit ]; then + echo "rem_free $rem_free greater than pquot_limit $pquot_limit??" +fi + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks2" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks2" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail2" $fs_bavail $rem_free 1% -v +_within_tolerance "dir bavail2" $dir_bavail $rem_free 1% -v + +# use up 10 blocks of project quota +$XFS_IO_PROG -f -c "pwrite -S 0x99 0 $((bsize * 10))" -c fsync $SCRATCH_MNT/dir/a >> $seqres.full + +# check statfs reporting +fs_blocks=$(blocks $SCRATCH_MNT) +dir_blocks=$(blocks $SCRATCH_MNT/dir) + +_within_tolerance "root blocks3" $fs_blocks $orig_blocks 1% -v +_within_tolerance "dir blocks3" $dir_blocks $pquot_limit 1% -v + +fs_bavail=$(bavail $SCRATCH_MNT) +dir_bavail=$(bavail $SCRATCH_MNT/dir) + +_within_tolerance "root bavail3" $fs_bavail $rem_free 1% -v +_within_tolerance "dir bavail3" $dir_bavail $((rem_free - 10)) 1% -v + +# final state diagnostics +$XFS_IO_PROG -c 'statfs' $SCRATCH_MNT $SCRATCH_MNT/dir | grep statfs >> $seqres.full +repquota -P $SCRATCH_DEV >> $seqres.full +df $SCRATCH_MNT >> $seqres.full +ls -laR $SCRATCH_MNT/ >> $seqres.full + +# success, all done +status=0 +exittests/generic/1955.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 1955 +root blocks1 is in range +dir blocks1 is in range +root bavail1 is in range +dir bavail1 is in range +root blocks2 is in range +dir blocks2 is in range +root bavail2 is in range +dir bavail2 is in range +root blocks3 is in range +dir blocks3 is in range +root bavail3 is in range +dir bavail3 is in range
PATCH 10/12 fstests: realtime reverse-mapping support
In reply to Darrick J. WongHi all,
Fix a few regressions in fstests when rmap is enabled on the realtime volume.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-rmap
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-rmap
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-rmap
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=realtime-rmap
---
Commits in this patchset:
* xfs: fix tests that try to access the realtime rmap inode
* xfs/336: port to common/metadump
* fuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file
* xfs: race fsstress with realtime rmap btree scrub and repair
* xfs: fix various problems with fsmap detecting the data device
* xfs/341: update test for rtgroup-based rmap
* xfs/3{43,32}: adapt tests for rt extent size greater than 1
* xfs/291: use _scratch_mkfs_sized instead of opencoding the logic
* xfs: skip tests if formatting small filesystem fails
* xfs/443: use file allocation unit, not dbsize
* populate: adjust rtrmap calculations for rtgroups
* populate: check that we created a realtime rmap btree of the given height
* fuzzy: create missing fuzz tests for rt rmap btrees
--- common/populate | 36 +++++++++++++++++++++++++ common/xfs | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/104 | 1 + tests/xfs/122.out | 1 - tests/xfs/1528 | 38 +++++++++++++++++++++++++++ tests/xfs/1528.out | 4 +++ tests/xfs/1529 | 37 ++++++++++++++++++++++++++ tests/xfs/1529.out | 4 +++ tests/xfs/1817 | 39 +++++++++++++++++++++++++++ tests/xfs/1817.out | 2 + tests/xfs/1821 | 45 ++++++++++++++++++++++++++++++++ tests/xfs/1821.out | 2 + tests/xfs/1857 | 39 +++++++++++++++++++++++++++ tests/xfs/1857.out | 2 + tests/xfs/1893 | 2 + tests/xfs/272 | 2 + tests/xfs/276 | 2 + tests/xfs/277 | 2 + tests/xfs/291 | 2 + tests/xfs/332 | 6 +--- tests/xfs/332.out | 2 - tests/xfs/333 | 43 ------------------------------ tests/xfs/333.out | 6 ---- tests/xfs/336 | 34 ++++++++---------------- tests/xfs/336.out | 4 +-- tests/xfs/337 | 2 + tests/xfs/338 | 30 ++++++++++++++++++--- tests/xfs/339 | 5 ++-- tests/xfs/340 | 25 ++++++++++++++---- tests/xfs/341 | 12 +++----- tests/xfs/341.out | 1 - tests/xfs/342 | 4 +-- tests/xfs/343 | 2 + tests/xfs/406 | 6 +++- tests/xfs/407 | 6 +++- tests/xfs/408 | 7 ++++- tests/xfs/409 | 7 ++++- tests/xfs/443 | 9 ++++-- tests/xfs/481 | 6 +++- tests/xfs/482 | 7 ++++- 40 files changed, 429 insertions(+), 129 deletions(-) create mode 100755 tests/xfs/1528 create mode 100644 tests/xfs/1528.out create mode 100755 tests/xfs/1529 create mode 100644 tests/xfs/1529.out create mode 100755 tests/xfs/1817 create mode 100644 tests/xfs/1817.out create mode 100755 tests/xfs/1821 create mode 100644 tests/xfs/1821.out create mode 100755 tests/xfs/1857 create mode 100644 tests/xfs/1857.out delete mode 100755 tests/xfs/333 delete mode 100644 tests/xfs/333.out
PATCH 1/13 xfs: fix tests that try to access the realtime rmap inode
From: Darrick J. Wong <[email protected]>
The realtime rmap tests were added to fstests a long time ago. Since they were added, we decided to create a metadata file directory structure instead of adding more fields to the superblock. Therefore, fix all the tests that try to access these paths.
While we're at it, fix xfs/409 to run the *online* scrub program like it's supposed to. xfs/408 is the fuzzer for xfs_repair testing.
--- common/xfs | 41 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/122.out | 1 - tests/xfs/333 | 43 ------------------------------------------- tests/xfs/333.out | 6 ------ tests/xfs/337 | 2 +- tests/xfs/338 | 30 +++++++++++++++++++++++++----- tests/xfs/339 | 5 +++-- tests/xfs/340 | 25 ++++++++++++++++++++----- tests/xfs/341 | 2 +- tests/xfs/342 | 4 ++-- 10 files changed, 93 insertions(+), 66 deletions(-) delete mode 100755 tests/xfs/333 delete mode 100644 tests/xfs/333.out
common/xfs +41 -0
@@ -2135,3 +2135,44 @@ _require_xfs_rtquota_if_rtdev() { _notrun "Quotas probably not supported on realtime scratch device; set TEST_RTDEV" fi } + +# Resolve a metadata directory tree path and return the inode number. +_scratch_metadir_lookup() { + local res="$(_scratch_xfs_db -c "ls -i -m $1")" + test "${PIPESTATUS[0]}" -eq 0 && echo "$res" +} + +# Figure out which directory entry we have to change to update the rtrmap +# inode pointer. The last line of output is inumber field within a metadata +# object; any previous lines are the accessor commands that must be fed to +# xfs_db to get to the correct directory block. +_scratch_find_rt_metadir_entry() { + local sfkey="$(_scratch_xfs_db -c 'path -m /rtgroups' -c print | \ + grep "\"$1\"" | \ + sed -e 's/.name.*$//g' -e 's/\[/\\[/g' -e 's/\]/\\]/g' )" + if [ -n "$sfkey" ]; then + echo 'path -m /rtgroups' + _scratch_xfs_db -c 'path -m /rtgroups' -c print | \ + grep "${sfkey}.inumber" | awk '{print $1}' + return 0 + fi + + local size=$(_scratch_xfs_db -c 'path -m /rtgroups' -c 'print core.size' | awk '{print $3}') + local blksz=$(_scratch_xfs_db -c 'sb 0' -c 'print blocksize' | awk '{print $3}') + local dirblklog=$(_scratch_xfs_db -c 'sb 0' -c 'print dirblklog' | awk '{print $3}') + local dirblksz=$((blksz << dirblklog )) + for ((fileoff = 0; fileoff < (size / dirblksz); fileoff++)); do + local dbkey="$(_scratch_xfs_db -c 'path -m /rtgroups' -c "dblock $fileoff" -c 'print' | \ + grep "\"$1\"" | \ + sed -e 's/.name.*$//g' -e 's/\[/\\[/g' -e 's/\]/\\]/g' )" + if [ -n "$dbkey" ]; then + echo 'path -m /rtgroups' + echo "dblock $fileoff" + _scratch_xfs_db -c 'path -m /rtgroups' -c "dblock $fileoff" -c print | \ + grep "${dbkey}.inumber" | awk '{print $1}' + return 0 + fi + done + + return 1 +}
tests/xfs/122.out +0 -1
@@ -44,7 +44,6 @@ offsetof(xfs_sb_t, sb_rextents) = 24 offsetof(xfs_sb_t, sb_rextsize) = 80 offsetof(xfs_sb_t, sb_rextslog) = 125 offsetof(xfs_sb_t, sb_rootino) = 56 -offsetof(xfs_sb_t, sb_rrmapino) = 264 offsetof(xfs_sb_t, sb_rsumino) = 72 offsetof(xfs_sb_t, sb_sectlog) = 121 offsetof(xfs_sb_t, sb_sectsize) = 102
tests/xfs/333 deleted +0 -43
43 lines not on this page · raw message
tests/xfs/333.out deleted +0 -6
@@ -1,6 +0,0 @@ -QA output created by 333 -Format and mount -Create some files -Corrupt fs -mount: Structure needs cleaning -Test done, mount should have failed
tests/xfs/337 +1 -1
@@ -51,7 +51,7 @@ echo "+ check fs" _scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "xfs_repair should not fail" echo "+ corrupt image" -_scratch_xfs_db -x -c "sb" -c "addr rrmapino" -c "addr u3.rtrmapbt.ptrs[1]" \ +_scratch_xfs_db -x -c "path -m /rtgroups/0.rmap" -c "addr u3.rtrmapbt.ptrs[1]" \ -c "stack" -c "blocktrash -x 4096 -y 4096 -n 8 -3 -z" \ >> $seqres.full 2>&1
tests/xfs/338 +25 -5
@@ -27,13 +27,33 @@ $XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full _scratch_unmount echo "Corrupt fs" -_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \ - -c 'write core.nlinkv2 0' -c 'write core.mode 0' -c 'sb 0' \ - -c 'write rrmapino 0' >> $seqres.full -_try_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed" +readarray -t rtrmap_path < <(_scratch_find_rt_metadir_entry 0.rmap) + +rtrmap_accessors=() +rtrmap_path_len="${#rtrmap_path[@]}" +for ((i = 0; i < rtrmap_path_len - 1; i++)); do + rtrmap_accessors+=(-c "${rtrmap_path[i]}") +done +rtrmap_entry="${rtrmap_path[rtrmap_path_len - 1]}" +test -n "$rtrmap_entry" || _fail "Could not find rtrmap metadir entry?" + +_scratch_xfs_db -x -c 'path -m /rtgroups/0.rmap' \ + -c 'write core.nlinkv2 0' -c 'write core.mode 0' \ + "${rtrmap_accessors[@]}" \ + -c "print $rtrmap_entry" \ + -c "write -d $rtrmap_entry 0" >> $seqres.full +if _try_scratch_mount >> $seqres.full 2>&1; then + echo "mount should have failed" + _scratch_unmount +else + # If the verifiers are working properly, the mount will fail because + # we fuzzed the metadata root directory. This causes loud complaints + # to dmesg, so we want to ignore those. + _disable_dmesg_check +fi echo "Repair fs" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot _repair_scratch_fs >> $seqres.full 2>&1 echo "Try to create more files (again)"
tests/xfs/339 +3 -2
@@ -29,7 +29,8 @@ ln $SCRATCH_MNT/f3 $SCRATCH_MNT/f4 _scratch_unmount echo "Corrupt fs" -rrmapino=`_scratch_xfs_get_sb_field rrmapino` +rrmapino=$(_scratch_metadir_lookup /rtgroups/0.rmap) +test -n "$rrmapino" || _fail "Could not find rtrmap inode?" _scratch_xfs_set_metadata_field "u3.sfdir3.list[3].inumber.i4" $rrmapino \ 'sb 0' 'addr rootino' >> $seqres.full _scratch_mount
@@ -41,7 +42,7 @@ echo "Try to create more files" $XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1 echo "Repair fs" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot _repair_scratch_fs >> $seqres.full 2>&1 echo "Try to create more files (again)"
tests/xfs/340 +20 -5
@@ -29,16 +29,31 @@ ino=$(stat -c '%i' $SCRATCH_MNT/f3) _scratch_unmount echo "Corrupt fs" -rrmapino=$(_scratch_xfs_get_sb_field rrmapino) -_scratch_xfs_db -x -c "inode $rrmapino" \ +readarray -t rtrmap_path < <(_scratch_find_rt_metadir_entry 0.rmap) + +rtrmap_accessors=() +rtrmap_path_len="${#rtrmap_path[@]}" +for ((i = 0; i < rtrmap_path_len - 1; i++)); do + rtrmap_accessors+=(-c "${rtrmap_path[i]}") +done +rtrmap_entry="${rtrmap_path[rtrmap_path_len - 1]}" +test -n "$rtrmap_entry" || _fail "Could not find rtrmap metadir entry?" + +rrmapino=$(_scratch_metadir_lookup /rtgroups/0.rmap) +test -n "$rrmapino" || _fail "Could not find rtrmap inode?" +_scratch_xfs_db -x -c "path -m /rtgroups/0.rmap" \ -c 'write core.format 2' -c 'write core.size 0' \ - -c 'write core.nblocks 0' -c 'sb 0' -c 'addr rootino' \ + -c 'write core.nblocks 0' \ + -c 'sb 0' -c 'addr rootino' \ + -c "print u3.sfdir3.list[2].inumber" \ -c "write u3.sfdir3.list[2].inumber.i4 $rrmapino" \ - -c 'sb 0' -c "write rrmapino $ino" >> $seqres.full + "${rtrmap_accessors[@]}" \ + -c "print $rtrmap_entry" \ + -c "write $rtrmap_entry $ino" >> $seqres.full _try_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed" echo "Repair fs" -_scratch_unmount 2>&1 | _filter_scratch +_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot _repair_scratch_fs >> $seqres.full 2>&1 echo "Try to create more files (again)"
tests/xfs/341 +1 -1
@@ -51,7 +51,7 @@ echo "Corrupt fs" fsbno=$(_scratch_xfs_db -c "inode $ino" -c 'bmap' | grep 'flag 0' | head -n 1 | \ sed -e 's/^.*startblock \([0-9]*\) .*$/\1/g') -_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \ +_scratch_xfs_db -x -c 'path -m /rtgroups/0.rmap' \ -c "write u3.rtrmapbt.ptrs[1] $fsbno" -c 'p' >> $seqres.full _scratch_mount
tests/xfs/342 +2 -2
@@ -45,9 +45,9 @@ ino=$(stat -c '%i' $SCRATCH_MNT/f3) _scratch_unmount echo "Corrupt fs" -_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full +_scratch_xfs_db -c 'path -m /rtgroups/0.rmap' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full -fsbno=$(_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' \ +fsbno=$(_scratch_xfs_db -c 'path -m /rtgroups/0.rmap' \ -c 'p u3.rtrmapbt.ptrs[1]' | sed -e 's/^.*://g') _scratch_xfs_db -x -c "inode $ino" -c "write u3.bmx[0].startblock $fsbno" >> $seqres.full _scratch_mount
Re: [PATCH 01/13] xfs: fix tests that try to access the realtime rmap inode
Looks good:
PATCH 2/13 xfs/336: port to common/metadump
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
xfs/336 does this somewhat sketchy thing where it mdrestores into a regular file, and then does this to validate the restored metadata:
SCRATCH_DEV=$TEST_DIR/image _scratch_mount
Unfortunately, commit 1a49022fab9b4d causes the following regression:
--- /tmp/fstests/tests/xfs/336.out 2024-11-12 16:17:36.733447713 -0800
+++ /var/tmp/fstests/xfs/336.out.bad 2025-01-04 19:10:39.861871114 -0800
@@ -5,4 +5,5 @@ Create big file
Explode the rtrmapbt
Create metadump file
Restore metadump
-Check restored fs
+Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content> +(see /var/tmp/fstests/xfs/336.full for details)
This is due to the fact that SCRATCH_DEV is temporarily reassigned to the regular file. That path is passed straight through _scratch_mount to _xfs_prepare_for_eio_shutdown, but that helper _fails because the "dev" argument isn't actually a path to a block device.
Fix this by porting it to the new common/metadump code that we merged last year.
--- tests/xfs/336 | 34 +++++++++++----------------------- tests/xfs/336.out | 4 +--- 2 files changed, 12 insertions(+), 26 deletions(-)
tests/xfs/336 +11 -23
@@ -9,21 +9,22 @@ . ./common/preamble _begin_fstest auto rmap realtime metadump prealloc -# Override the default cleanup function. _cleanup() { cd / - rm -rf "$tmp".* $metadump_file + rm -rf "$tmp".* + _xfs_cleanup_verify_metadump } -# Import common functions. . ./common/filter +. ./common/metadump _require_command "$XFS_MDRESTORE_PROG" "xfs_mdrestore" _require_realtime _require_xfs_scratch_rmapbt _require_test_program "punch-alternating" _require_xfs_io_command "falloc" +_xfs_setup_verify_metadump rm -f "$seqres.full"
@@ -34,16 +35,13 @@ cat $tmp.mkfs > "$seqres.full" 2>&1 _scratch_mount blksz="$(_get_file_block_size $SCRATCH_MNT)" -metadump_file=$TEST_DIR/${seq}_metadump -rm -rf $metadump_file - echo "Create a three-level rtrmapbt" -# inode core size is at least 176 bytes; btree header is 56 bytes; -# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes. +# inode core size is at least 176 bytes; btree block header is 64 bytes; +# rtrmap record is 24 bytes; and rtrmap key/pointer are 48 bytes. i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)" -i_ptrs=$(( (isize - i_core_size) / 56 )) -bt_ptrs=$(( (blksz - 56) / 56 )) -bt_recs=$(( (blksz - 56) / 32 )) +i_ptrs=$(( (isize - i_core_size) / 48 )) +bt_ptrs=$(( (blksz - 64) / 48 )) +bt_recs=$(( (blksz - 64) / 24 )) blocks=$((i_ptrs * bt_ptrs * bt_recs)) _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
@@ -56,20 +54,10 @@ $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCR echo "Explode the rtrmapbt" $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full" $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full" -_scratch_cycle_mount - -echo "Create metadump file" _scratch_unmount -_scratch_xfs_metadump $metadump_file -a -o -# Now restore the obfuscated one back and take a look around -echo "Restore metadump" -SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file -SCRATCH_DEV=$TEST_DIR/image _scratch_mount -SCRATCH_DEV=$TEST_DIR/image _scratch_unmount - -echo "Check restored fs" -_check_scratch_fs $TEST_DIR/image +echo "Test metadump" +_xfs_verify_metadumps '-a -o' # success, all done status=0
tests/xfs/336.out +1 -3
@@ -3,6 +3,4 @@ Format and mount Create a three-level rtrmapbt Create big file Explode the rtrmapbt -Create metadump file -Restore metadump -Check restored fs +Test metadump
Re: [PATCH 02/13] xfs/336: port to common/metadump
Looks good:
PATCH 3/13 fuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The fs population code creates a realtime rmap btree in /some/ realtime group with at least two levels. This rmapbt file isn't necessarily the one for group 0, so we need to find it programmatically.
--- common/xfs | 33 +++++++++++++++++++++++++++++++++ tests/xfs/406 | 6 ++++-- tests/xfs/407 | 6 ++++-- tests/xfs/408 | 7 +++++-- tests/xfs/409 | 7 +++++-- tests/xfs/481 | 6 ++++-- tests/xfs/482 | 7 +++++-- 7 files changed, 60 insertions(+), 12 deletions(-)
common/xfs +33 -0
@@ -1827,6 +1827,39 @@ _scratch_xfs_find_agbtree_height() { return 1 } +# Find us the path to the inode containing a realtime btree with a specific +# height. +_scratch_xfs_find_rgbtree_height() { + local bt_type="$1" + local bt_height="$2" + local rgcount=$(_xfs_mount_rgcount $SCRATCH_DEV) + local path + local path_format + local bt_prefix + + case "${bt_type}" in + "rmap") + path_format="/rtgroups/%u.rmap" + bt_prefix="u3.rtrmapbt" + ;; + *) + _fail "Don't know about rt btree ${bt_type}" + ;; + esac + + for ((rgno = 0; rgno < rgcount; rgno++)); do + path="$(printf "${path_format}" "${rgno}")" + bt_level=$(_scratch_xfs_db -c "path -m ${path}" -c "p ${bt_prefix}.level" | awk '{print $3}') + # "level" is the actual level within the btree + if [ "${bt_level}" -eq "$((bt_height - 1))" ]; then + echo "${path}" + return 0 + fi + done + + return 1 +} + _require_xfs_mkfs_atomicswap() { # atomicswap can be activated on rmap or reflink filesystems.
tests/xfs/406 +4 -2
@@ -24,10 +24,12 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino') +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") echo "Fuzz rtrmapbt recs" -_scratch_xfs_fuzz_metadata '' 'offline' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +_scratch_xfs_fuzz_metadata '' 'offline' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full echo "Done fuzzing rtrmapbt recs" # success, all done
tests/xfs/407 +4 -2
@@ -24,10 +24,12 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino') +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 1)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") echo "Fuzz rtrmapbt recs" -_scratch_xfs_fuzz_metadata '' 'online' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +_scratch_xfs_fuzz_metadata '' 'online' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full echo "Done fuzzing rtrmapbt recs" # success, all done
tests/xfs/408 +5 -2
@@ -4,7 +4,7 @@ # # FS QA Test No. 408 # -# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field. # Use xfs_repair to fix the corruption. # . ./common/preamble
@@ -24,8 +24,11 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + echo "Fuzz rtrmapbt keyptrs" -_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full echo "Done fuzzing rtrmapbt keyptrs" # success, all done
tests/xfs/409 +5 -2
@@ -4,7 +4,7 @@ # # FS QA Test No. 409 # -# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field. # Use xfs_scrub to fix the corruption. # . ./common/preamble
@@ -24,8 +24,11 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + echo "Fuzz rtrmapbt keyptrs" -_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'online' "path -m $path" >> $seqres.full echo "Done fuzzing rtrmapbt keyptrs" # success, all done
tests/xfs/481 +4 -2
@@ -25,10 +25,12 @@ _disable_dmesg_check echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'sb 0' 'addr rrmapino') +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") echo "Fuzz rtrmapbt recs" -_scratch_xfs_fuzz_metadata '' 'none' 'sb 0' 'addr rrmapino' "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +_scratch_xfs_fuzz_metadata '' 'none' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full echo "Done fuzzing rtrmapbt recs" # success, all done
tests/xfs/482 +5 -2
@@ -4,7 +4,7 @@ # # FS QA Test No. 482 # -# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Populate a XFS filesystem and fuzz every rtrmapbt key/pointer field. # Do not fix the filesystem, to test metadata verifiers. . ./common/preamble
@@ -25,8 +25,11 @@ _disable_dmesg_check echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + echo "Fuzz rtrmapbt keyptrs" -_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' 'sb 0' 'addr rrmapino' >> $seqres.full +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full echo "Done fuzzing rtrmapbt keyptrs" # success, all done
Re: [PATCH 03/13] fuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file
Looks good:
PATCH 4/13 xfs: race fsstress with realtime rmap btree scrub and repair
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Race checking and rebuilding realtime rmap btrees with fsstress.
--- tests/xfs/1817 | 39 +++++++++++++++++++++++++++++++++++++++ tests/xfs/1817.out | 2 ++ tests/xfs/1821 | 45 +++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1821.out | 2 ++ tests/xfs/1857 | 39 +++++++++++++++++++++++++++++++++++++++ tests/xfs/1857.out | 2 ++ tests/xfs/1893 | 2 +- 7 files changed, 130 insertions(+), 1 deletion(-) create mode 100755 tests/xfs/1817 create mode 100644 tests/xfs/1817.out create mode 100755 tests/xfs/1821 create mode 100644 tests/xfs/1821.out create mode 100755 tests/xfs/1857 create mode 100644 tests/xfs/1857.out
tests/xfs/1817 new file +39 -0
@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1817 +# +# Race fsstress and rtrmapbt scrub for a while to see if we crash or livelock. +# +. ./common/preamble +_begin_fstest scrub fsstress_scrub + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +_require_realtime +_require_scratch +_require_xfs_stress_scrub + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_require_xfs_has_feature "$SCRATCH_MNT" rmapbt +_xfs_force_bdev realtime $SCRATCH_MNT + +_scratch_xfs_stress_scrub -s "scrub rtrmapbt %rgno%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/1817.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1817 +Silence is golden
tests/xfs/1821 new file +45 -0
45 lines not on this page · raw message
tests/xfs/1821.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1821 +Silence is golden
tests/xfs/1857 new file +39 -0
@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1857 +# +# Race fsstress and rtrmapbt repair for a while to see if we crash or livelock. +# +. ./common/preamble +_begin_fstest online_repair fsstress_online_repair + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +_require_realtime +_require_scratch +_require_xfs_stress_online_repair + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_require_xfs_has_feature "$SCRATCH_MNT" rmapbt +_xfs_force_bdev realtime $SCRATCH_MNT + +_scratch_xfs_stress_online_repair -s "repair rtrmapbt %rgno%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/1857.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1857 +Silence is golden
tests/xfs/1893 +1 -1
@@ -46,7 +46,7 @@ done # Metapath verbs that take a rt group number for ((rgno = 0; rgno < rgcount; rgno++)); do - for v in rtbitmap rtsummary; do + for v in rtbitmap rtsummary rtrmapbt; do testio=$(try_verb "$v" "$rgno") test -z "$testio" && verbs+=("$v $rgno") done
Re: [PATCH 04/13] xfs: race fsstress with realtime rmap btree scrub and repair
Looks good:
PATCH 5/13 xfs: fix various problems with fsmap detecting the data device
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Various tests of realtime rmap functionality assumed that the data device could be picked out from the GETFSMAP output by looking for static fs metadata. This is no longer true, since rtgroups filesystems write a superblock header at the start of the rt device, so update these tests.
--- tests/xfs/272 | 2 +- tests/xfs/276 | 2 +- tests/xfs/277 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tests/xfs/272 +1 -1
@@ -55,7 +55,7 @@ cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total c done echo "Check device field of FS metadata and regular file" -data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') +data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"
tests/xfs/276 +1 -1
@@ -59,7 +59,7 @@ cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total c done echo "Check device field of FS metadata and realtime file" -data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') +data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*[[:space:]]*[0-9]*$" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') test "${data_dev}" != "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"
tests/xfs/277 +1 -1
@@ -36,7 +36,7 @@ $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap echo "Check device field of FS metadata and journalling log" -data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') +data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') journal_dev=$(grep 'journalling log' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') test "${data_dev}" = "${journal_dev}" || echo "data ${data_dev} journal ${journal_dev}?"
Re: [PATCH 05/13] xfs: fix various problems with fsmap detecting the data device
Looks good:
PATCH 6/13 xfs/341: update test for rtgroup-based rmap
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we're sharding the realtime volume into multiple allocation groups, update this test to reflect the new reality. The realtime rmap btree record and key sizes have shrunk, and we can't guarantee that a quick file write actually hits the same rt group as the one we fuzzed, so eliminate the file write test since we're really only curious if xfs_repair will fix the problem.
--- tests/xfs/341 | 10 +++------- tests/xfs/341.out | 1 - 2 files changed, 3 insertions(+), 8 deletions(-)
tests/xfs/341 +3 -7
@@ -30,10 +30,10 @@ blksz="$(_get_block_size $SCRATCH_MNT)" rtextsz_blks=$((rtextsz / blksz)) # inode core size is at least 176 bytes; btree header is 56 bytes; -# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes. +# rtrmap record is 24 bytes; and rtrmap key/pointer are 48 bytes. i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)" -i_ptrs=$(( (isize - i_core_size) / 56 )) -bt_recs=$(( (blksz - 56) / 32 )) +i_ptrs=$(( (isize - i_core_size) / 48 )) +bt_recs=$(( (blksz - 56) / 24 )) blocks=$((i_ptrs * bt_recs + 1)) len=$((blocks * rtextsz))
@@ -55,10 +55,6 @@ _scratch_xfs_db -x -c 'path -m /rtgroups/0.rmap' \ -c "write u3.rtrmapbt.ptrs[1] $fsbno" -c 'p' >> $seqres.full _scratch_mount -echo "Try to create more files" -$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1 -test -e $SCRATCH_MNT/f5 && echo "should not have been able to write f5" - echo "Repair fs" _scratch_unmount 2>&1 | _filter_scratch _repair_scratch_fs >> $seqres.full 2>&1
tests/xfs/341.out +0 -1
@@ -2,6 +2,5 @@ QA output created by 341 Format and mount Create some files Corrupt fs -Try to create more files Repair fs Try to create more files (again)
Re: [PATCH 06/13] xfs/341: update test for rtgroup-based rmap
Looks good:
PATCH 7/13 xfs/3{43,32}: adapt tests for rt extent size greater than 1
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Both of these tests for the realtime volume can fail when the rt extent size is larger than a single block.
332 is a read-write functionality test that encodes md5sum in the output, so we need to skip it if $blksz isn't congruent with the extent size, because the fcollapse call will fail.
343 is a test of the rmap btree, so the fix here is simpler -- make $blksz the file allocation unit, and get rid of the md5sum in the golden output.
--- tests/xfs/332 | 6 +----- tests/xfs/332.out | 2 -- tests/xfs/343 | 2 ++ 3 files changed, 3 insertions(+), 7 deletions(-)
tests/xfs/332 +1 -5
@@ -26,7 +26,7 @@ rm -f "$seqres.full" echo "Format and mount" _scratch_mkfs > "$seqres.full" 2>&1 _scratch_mount -blksz=65536 +blksz=$(_get_file_block_size $SCRATCH_MNT) # 65536 blocks=16 len=$((blocks * blksz))
@@ -43,10 +43,6 @@ $XFS_IO_PROG -c "fpunch $blksz $blksz" \ -c "fcollapse $((9 * blksz)) $blksz" \ -c "finsert $((10 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full -echo "Check file" -md5sum $SCRATCH_MNT/f1 | _filter_scratch -od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full - echo "Unmount" _scratch_unmount
tests/xfs/332.out +0 -2
@@ -2,8 +2,6 @@ QA output created by 332 Format and mount Create some files Manipulate file -Check file -e45c5707fcf6817e914ffb6ce37a0ac7 SCRATCH_MNT/f1 Unmount Try a regular fsmap Try a bad fsmap
tests/xfs/343 +2 -0
@@ -29,6 +29,8 @@ blksz=65536 blocks=16 len=$((blocks * blksz)) +_require_congruent_file_oplen $SCRATCH_MNT $blksz + echo "Create some files" $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
Re: [PATCH 07/13] xfs/3{43,32}: adapt tests for rt extent size greater than 1
Looks good:
PATCH 8/13 xfs/291: use _scratch_mkfs_sized instead of opencoding the logic
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that _scratch_mkfs_xfs_sized accepts arbitrary mkfs arguments, this test doesn't need to open-code the helper just to add the dir block and log size arguments. Clean this up, which will also help us to avoid problems with rtrmap if the rt devices is large enough to cause format failures with the 133M data device size.
--- tests/xfs/291 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/xfs/291 +1 -1
@@ -26,7 +26,7 @@ _xfs_setup_verify_metadump _require_scratch logblks=$(_scratch_find_xfs_min_logblocks -n size=16k -d size=133m) -_scratch_mkfs_xfs -n size=16k -l size=${logblks}b -d size=133m >> $seqres.full 2>&1 +_scratch_mkfs_sized $((133 * 1048576)) '' -n size=16k -l size=${logblks}b >> $seqres.full 2>&1 _scratch_mount # First we cause very badly fragmented freespace, then
Re: [PATCH 08/13] xfs/291: use _scratch_mkfs_sized instead of opencoding the logic
Looks good:
PATCH 9/13 xfs: skip tests if formatting small filesystem fails
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
There are a few tests that try to exercise XFS functionality with an unusually small (< 500MB) filesystem. Formatting can fail if the test configuration also specifies a very large realtime device because mkfs hits ENOSPC when allocating the realtime metadata. The test proceeds anyway (which causes an immediate mount failure) so we might as well skip these.
--- tests/xfs/104 | 1 + 1 file changed, 1 insertion(+)
tests/xfs/104 +1 -0
@@ -16,6 +16,7 @@ _create_scratch() { echo "*** mkfs" _scratch_mkfs_xfs $@ | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs + test "${PIPESTATUS[0]}" -eq 0 || _notrun "formatting small scratch fs failed" . $tmp.mkfs echo "*** mount"
Re: [PATCH 09/13] xfs: skip tests if formatting small filesystem fails
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
There are a few tests that try to exercise XFS functionality with an unusually small (< 500MB) filesystem. Formatting can fail if the test configuration also specifies a very large realtime device because mkfs hits ENOSPC when allocating the realtime metadata. The test proceeds anyway (which causes an immediate mount failure) so we might as well skip these.
In this patch only a single test case is touched and not a few. But I remember hitting a few more with the zoned testing.
Re: [PATCH 09/13] xfs: skip tests if formatting small filesystem fails
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
There are a few tests that try to exercise XFS functionality with an unusually small (< 500MB) filesystem. Formatting can fail if the test configuration also specifies a very large realtime device because mkfs hits ENOSPC when allocating the realtime metadata. The test proceeds anyway (which causes an immediate mount failure) so we might as well skip these.
Quoted 2 lines
In this patch only a single test case is touched and not a few. But I remember hitting a few more with the zoned testing.
Originally there were a few more, but most of the others I fixed by making _scratch_mkfs_sized constrict the size of both the data and rt volumes. The 2022 version of this patch changed both xfs/104 and xfs/291.
Oh, wait, the xfs/291 change became its own patch.
Right. _scratch_mkfs_sized takes arguments now. So this patch should make create_scratch() use that instead of plain _scratch_mkfs_xfs.
--D
PATCH 9/13 xfs/104: use _scratch_mkfs_sized
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Use _scratch_mkfs_sized instead of opencoding the small fs creation logic because the helper scales down the size of the rt volume to match the data volume. This means the format won't fail if SCRATCH_RTDEV is quite large.
Also fix some incorrect bash usage of "$@" and remove the leading underscore because it's a private test function.
---
v6.4.1: use _scratch_mkfs_sized this time
--- tests/xfs/104 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/xfs/104 +3 -3
@@ -12,10 +12,10 @@ _begin_fstest growfs ioctl prealloc auto stress # Import common functions. . ./common/filter -_create_scratch() +create_scratch_sized() { echo "*** mkfs" - _scratch_mkfs_xfs $@ | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs + _scratch_mkfs_sized "$@" | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs . $tmp.mkfs echo "*** mount"
@@ -61,7 +61,7 @@ size=`expr 125 \* 1048576` # 120 megabytes initially sizeb=`expr $size / $dbsize` # in data blocks echo "*** creating scratch filesystem" logblks=$(_scratch_find_xfs_min_logblocks -dsize=${size} -dagcount=${nags}) -_create_scratch -lsize=${logblks}b -dsize=${size} -dagcount=${nags} +create_scratch_sized "${size}" '' -lsize=${logblks}b -dagcount=${nags} echo "*** using some initial space on scratch filesystem" for i in `seq 125 -1 90`; do
Re: [PATCH v6.4.1 09/13] xfs/104: use _scratch_mkfs_sized
Looks good:
PATCH 10/13 xfs/443: use file allocation unit, not dbsize
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
We can only punch in units of file allocation boundaries, so update this test to use that instead of the fs blocksize.
--- tests/xfs/443 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tests/xfs/443 +5 -4
@@ -38,14 +38,15 @@ _scratch_mount file1=$SCRATCH_MNT/file1 file2=$SCRATCH_MNT/file2 +file_blksz=$(_get_file_block_size $SCRATCH_MNT) # The goal is run an extent swap where one of the associated files has the # minimum number of extents to remain in btree format. First, create a couple # files with large enough extent counts (200 or so should be plenty) to ensure # btree format on the largest possible inode size filesystems. -$XFS_IO_PROG -fc "falloc 0 $((400 * dbsize))" $file1 +$XFS_IO_PROG -fc "falloc 0 $((400 * file_blksz))" $file1 $here/src/punch-alternating $file1 -$XFS_IO_PROG -fc "falloc 0 $((400 * dbsize))" $file2 +$XFS_IO_PROG -fc "falloc 0 $((400 * file_blksz))" $file2 $here/src/punch-alternating $file2 # Now run an extent swap at every possible extent count down to 0. Depending on
@@ -53,12 +54,12 @@ $here/src/punch-alternating $file2 # btree format. for i in $(seq 1 2 399); do # punch one extent from the tmpfile and swap - $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2 + $XFS_IO_PROG -c "fpunch $((i * file_blksz)) $file_blksz" $file2 $XFS_IO_PROG -c "exchangerange $file2" $file1 # punch the same extent from the old fork (now in file2) to resync the # extent counts and repeat - $XFS_IO_PROG -c "fpunch $((i * dbsize)) $dbsize" $file2 + $XFS_IO_PROG -c "fpunch $((i * file_blksz)) $file_blksz" $file2 done # sanity check that no extents are left over
Re: [PATCH 10/13] xfs/443: use file allocation unit, not dbsize
Looks good:
PATCH 11/13 populate: adjust rtrmap calculations for rtgroups
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we've sharded the realtime volume and created per-group rmap btrees, we need to adjust downward the size of rtrmapbt records since the block counts are now 32-bit instead of 64-bit.
--- common/populate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/populate +1 -1
@@ -463,7 +463,7 @@ _scratch_xfs_populate() { is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" if [ $is_rmapbt -gt 0 ] && [ $is_rt -gt 0 ]; then echo "+ rtrmapbt btree" - nr="$((blksz * 2 / 32))" + nr="$((blksz * 2 / 24))" $XFS_IO_PROG -R -f -c 'truncate 0' "${SCRATCH_MNT}/RTRMAPBT" __populate_create_file $((blksz * nr)) "${SCRATCH_MNT}/RTRMAPBT" fi
Re: [PATCH 11/13] populate: adjust rtrmap calculations for rtgroups
Looks good:
PATCH 12/13 populate: check that we created a realtime rmap btree of the given height
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Make sure that we actually create an rt rmap btree of the desired height somewhere in the filesystem.
--- common/populate | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
common/populate +34 -0
@@ -766,6 +766,37 @@ __populate_check_xfs_agbtree_height() { return 1 } +# Check that there's at least one rt btree with multiple levels +__populate_check_xfs_rgbtree_height() { + local bt_type="$1" + local rgcount=$(_scratch_xfs_db -c 'sb 0' -c 'p rgcount' | awk '{print $3}') + local path + local path_format + local bt_prefix + + case "${bt_type}" in + "rmap") + path_format="/rtgroups/%u.rmap" + bt_prefix="u3.rtrmapbt" + ;; + *) + _fail "Don't know about rt btree ${bt_type}" + ;; + esac + + for ((rgno = 0; rgno < rgcount; rgno++)); do + path="$(printf "${path_format}" "${rgno}")" + bt_level=$(_scratch_xfs_db -c "path -m ${path}" -c "p ${bt_prefix}.level" | awk '{print $3}') + # "level" is the actual level within the btree + if [ "${bt_level}" -gt 0 ]; then + return 0 + fi + done + + __populate_fail "Failed to create rt ${bt_type} of sufficient height!" + return 1 +} + # Check that populate created all the types of files we wanted _scratch_xfs_populate_check() { _scratch_mount
@@ -789,6 +820,7 @@ _scratch_xfs_populate_check() { is_finobt=$(_xfs_has_feature "$SCRATCH_MNT" finobt -v) is_rmapbt=$(_xfs_has_feature "$SCRATCH_MNT" rmapbt -v) is_reflink=$(_xfs_has_feature "$SCRATCH_MNT" reflink -v) + is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" dblksz="$(_xfs_get_dir_blocksize "$SCRATCH_MNT")"
@@ -819,6 +851,8 @@ _scratch_xfs_populate_check() { test $is_finobt -ne 0 && __populate_check_xfs_agbtree_height "fino" test $is_rmapbt -ne 0 && __populate_check_xfs_agbtree_height "rmap" test $is_reflink -ne 0 && __populate_check_xfs_agbtree_height "refcnt" + test $is_rmapbt -ne 0 && test $is_rt -gt 0 && \ + __populate_check_xfs_rgbtree_height "rmap" } # Check data fork format of ext4 file
Re: [PATCH 12/13] populate: check that we created a realtime rmap btree of the given height
Looks good:
PATCH 13/13 fuzzy: create missing fuzz tests for rt rmap btrees
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Back when I first created the fuzz tests for the realtime rmap btree, I forgot a couple of things. Add tests to fuzz rtrmap btree leaf records, and node keys.
--- tests/xfs/1528 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1528.out | 4 ++++ tests/xfs/1529 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1529.out | 4 ++++ tests/xfs/407 | 2 +- 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100755 tests/xfs/1528 create mode 100644 tests/xfs/1528.out create mode 100755 tests/xfs/1529 create mode 100644 tests/xfs/1529.out
tests/xfs/1528 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1528 +# +# Populate a XFS filesystem and fuzz every rtrmapbt record field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub repair fuzzers_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_realtime +_require_xfs_scratch_rmapbt +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrmapbt recs" +_scratch_xfs_fuzz_metadata '' 'both' "path -m $path" "addr u${inode_ver}.rtrmapbt.ptrs[1]" >> $seqres.full +echo "Done fuzzing rtrmapbt recs" + +# success, all done +status=0 +exit
tests/xfs/1528.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1528 +Format and populate +Fuzz rtrmapbt recs +Done fuzzing rtrmapbt recs
tests/xfs/1529 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1529 +# +# Populate a XFS filesystem and fuzz every rtrmapbt keyptr field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub repair fuzzers_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_realtime +_require_xfs_scratch_rmapbt +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ + _fail "could not find two-level rtrmapbt" + +echo "Fuzz rtrmapbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrmapbt)' 'offline' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrmapbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1529.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1529 +Format and populate +Fuzz rtrmapbt keyptrs +Done fuzzing rtrmapbt keyptrs
tests/xfs/407 +1 -1
@@ -24,7 +24,7 @@ _require_scratch_xfs_fuzz_fields echo "Format and populate" _scratch_populate_cached nofill > $seqres.full 2>&1 -path="$(_scratch_xfs_find_rgbtree_height 'rmap' 1)" || \ +path="$(_scratch_xfs_find_rgbtree_height 'rmap' 2)" || \ _fail "could not find two-level rtrmapbt" inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path")
Re: [PATCH 13/13] fuzzy: create missing fuzz tests for rt rmap btrees
Looks good:
PATCH 11/12 fstests: reflink on the realtime device
In reply to Darrick J. WongHi all,
This patchset enables use of the file data block sharing feature (i.e. reflink) on the realtime device. It follows the same basic sequence as the realtime rmap series -- first a few cleanups; then widening of the API parameters; and introduction of the new btree format and inode fork format. Next comes enabling CoW and remapping for the rt device; new scrub, repair, and health reporting code; and at the end we implement some code to lengthen write requests so that rt extents are always CoWed fully.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=realtime-reflink
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=realtime-reflink
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=realtime-reflink
xfsdocs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-documentation.git/log/?h=realtime-reflink
---
Commits in this patchset:
* common/populate: create realtime refcount btree
* xfs: create fuzz tests for the realtime refcount btree
* xfs/27[24]: adapt for checking files on the realtime volume
* xfs: race fsstress with realtime refcount btree scrub and repair
* xfs: remove xfs/131 now that we allow reflink on realtime volumes
* generic/331,xfs/240: support files that skip delayed allocation
* common/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section
--- common/populate | 26 ++++++++++++++++++--- common/xfs | 15 ++++++++++++ tests/generic/331 | 13 +++++++++- tests/generic/331.out | 2 +- tests/xfs/131 | 46 ------------------------------------ tests/xfs/131.out | 5 ---- tests/xfs/1538 | 38 ++++++++++++++++++++++++++++++ tests/xfs/1538.out | 4 +++ tests/xfs/1539 | 38 ++++++++++++++++++++++++++++++ tests/xfs/1539.out | 4 +++ tests/xfs/1540 | 38 ++++++++++++++++++++++++++++++ tests/xfs/1540.out | 4 +++ tests/xfs/1541 | 39 +++++++++++++++++++++++++++++++ tests/xfs/1541.out | 4 +++ tests/xfs/1542 | 38 ++++++++++++++++++++++++++++++ tests/xfs/1542.out | 4 +++ tests/xfs/1543 | 37 +++++++++++++++++++++++++++++ tests/xfs/1543.out | 4 +++ tests/xfs/1544 | 37 +++++++++++++++++++++++++++++ tests/xfs/1544.out | 4 +++ tests/xfs/1545 | 38 ++++++++++++++++++++++++++++++ tests/xfs/1545.out | 4 +++ tests/xfs/1818 | 40 ++++++++++++++++++++++++++++++++ tests/xfs/1818.out | 2 ++ tests/xfs/1819 | 40 ++++++++++++++++++++++++++++++++ tests/xfs/1819.out | 2 ++ tests/xfs/1893 | 2 +- tests/xfs/240 | 12 ++++++++- tests/xfs/240.out | 2 +- tests/xfs/272 | 40 +++++++++++++++++++++----------- tests/xfs/274 | 62 ++++++++++++++++++++++++++++++++++--------------- 31 files changed, 551 insertions(+), 93 deletions(-) delete mode 100755 tests/xfs/131 delete mode 100644 tests/xfs/131.out create mode 100755 tests/xfs/1538 create mode 100644 tests/xfs/1538.out create mode 100755 tests/xfs/1539 create mode 100644 tests/xfs/1539.out create mode 100755 tests/xfs/1540 create mode 100644 tests/xfs/1540.out create mode 100755 tests/xfs/1541 create mode 100644 tests/xfs/1541.out create mode 100755 tests/xfs/1542 create mode 100644 tests/xfs/1542.out create mode 100755 tests/xfs/1543 create mode 100644 tests/xfs/1543.out create mode 100755 tests/xfs/1544 create mode 100644 tests/xfs/1544.out create mode 100755 tests/xfs/1545 create mode 100644 tests/xfs/1545.out create mode 100755 tests/xfs/1818 create mode 100644 tests/xfs/1818.out create mode 100755 tests/xfs/1819 create mode 100644 tests/xfs/1819.out
PATCH 1/7 common/populate: create realtime refcount btree
From: Darrick J. Wong <[email protected]>
Populate a realtime refcount btree when we're creating a sample fs.
--- common/populate | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
common/populate +23 -3
@@ -451,16 +451,30 @@ _scratch_xfs_populate() { local dir="${SCRATCH_MNT}/INOBT" __populate_create_dir "${dir}" "${nr}" true --file-pct 100 - # Reverse-mapping btree + is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" is_rmapbt="$(_xfs_has_feature "$SCRATCH_MNT" rmapbt -v)" + is_reflink="$(_xfs_has_feature "$SCRATCH_MNT" reflink -v)" + + # Reverse-mapping btree if [ $is_rmapbt -gt 0 ]; then echo "+ rmapbt btree" nr="$((blksz * 2 / 24))" __populate_create_file $((blksz * nr)) "${SCRATCH_MNT}/RMAPBT" fi + # Realtime Reference-count btree comes before the rtrmapbt so that + # the refcount entries are created in rtgroup 0. + if [ $is_reflink -gt 0 ] && [ $is_rt -gt 0 ]; then + echo "+ rtreflink btree" + rt_blksz=$(_xfs_get_rtextsize "$SCRATCH_MNT") + nr="$((rt_blksz * 2 / 12))" + $XFS_IO_PROG -R -f -c 'truncate 0' "${SCRATCH_MNT}/RTREFCOUNTBT" + __populate_create_file $((blksz * nr)) "${SCRATCH_MNT}/RTREFCOUNTBT" + $XFS_IO_PROG -R -f -c 'truncate 0' "${SCRATCH_MNT}/RTREFCOUNTBT2" + cp --reflink=always "${SCRATCH_MNT}/RTREFCOUNTBT" "${SCRATCH_MNT}/RTREFCOUNTBT2" + fi + # Realtime Reverse-mapping btree - is_rt="$(_xfs_get_rtextents "$SCRATCH_MNT")" if [ $is_rmapbt -gt 0 ] && [ $is_rt -gt 0 ]; then echo "+ rtrmapbt btree" nr="$((blksz * 2 / 24))"
@@ -469,7 +483,6 @@ _scratch_xfs_populate() { fi # Reference-count btree - is_reflink="$(_xfs_has_feature "$SCRATCH_MNT" reflink -v)" if [ $is_reflink -gt 0 ]; then echo "+ reflink btree" nr="$((blksz * 2 / 12))"
@@ -534,6 +547,7 @@ _scratch_xfs_populate() { __populate_fragment_file "${SCRATCH_MNT}/RMAPBT" __populate_fragment_file "${SCRATCH_MNT}/RTRMAPBT" __populate_fragment_file "${SCRATCH_MNT}/REFCOUNTBT" + __populate_fragment_file "${SCRATCH_MNT}/RTREFCOUNTBT" _scratch_unmount }
@@ -779,6 +793,10 @@ __populate_check_xfs_rgbtree_height() { path_format="/rtgroups/%u.rmap" bt_prefix="u3.rtrmapbt" ;; + "refcnt") + path_format="/rtgroups/%u.refcount" + bt_prefix="u3.rtrefcbt" + ;; *) _fail "Don't know about rt btree ${bt_type}" ;;
@@ -853,6 +871,8 @@ _scratch_xfs_populate_check() { test $is_reflink -ne 0 && __populate_check_xfs_agbtree_height "refcnt" test $is_rmapbt -ne 0 && test $is_rt -gt 0 && \ __populate_check_xfs_rgbtree_height "rmap" + test $is_reflink -ne 0 && test $is_rt -gt 0 && \ + __populate_check_xfs_rgbtree_height "refcnt" } # Check data fork format of ext4 file
Re: [PATCH 1/7] common/populate: create realtime refcount btree
Looks good:
PATCH 2/7 xfs: create fuzz tests for the realtime refcount btree
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Create fuzz tests for the realtime refcount btree record and key/ptr blocks.
--- common/xfs | 4 ++++ tests/xfs/1538 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1538.out | 4 ++++ tests/xfs/1539 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1539.out | 4 ++++ tests/xfs/1540 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1540.out | 4 ++++ tests/xfs/1541 | 39 +++++++++++++++++++++++++++++++++++++++ tests/xfs/1541.out | 4 ++++ tests/xfs/1542 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1542.out | 4 ++++ tests/xfs/1543 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1543.out | 4 ++++ tests/xfs/1544 | 37 +++++++++++++++++++++++++++++++++++++ tests/xfs/1544.out | 4 ++++ tests/xfs/1545 | 38 ++++++++++++++++++++++++++++++++++++++ tests/xfs/1545.out | 4 ++++ 17 files changed, 339 insertions(+) create mode 100755 tests/xfs/1538 create mode 100644 tests/xfs/1538.out create mode 100755 tests/xfs/1539 create mode 100644 tests/xfs/1539.out create mode 100755 tests/xfs/1540 create mode 100644 tests/xfs/1540.out create mode 100755 tests/xfs/1541 create mode 100644 tests/xfs/1541.out create mode 100755 tests/xfs/1542 create mode 100644 tests/xfs/1542.out create mode 100755 tests/xfs/1543 create mode 100644 tests/xfs/1543.out create mode 100755 tests/xfs/1544 create mode 100644 tests/xfs/1544.out create mode 100755 tests/xfs/1545 create mode 100644 tests/xfs/1545.out
common/xfs +4 -0
@@ -1842,6 +1842,10 @@ _scratch_xfs_find_rgbtree_height() { path_format="/rtgroups/%u.rmap" bt_prefix="u3.rtrmapbt" ;; + "refcnt") + path_format="/rtgroups/%u.refcount" + bt_prefix="u3.rtrefcbt" + ;; *) _fail "Don't know about rt btree ${bt_type}" ;;
tests/xfs/1538 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1538 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt record field. +# Use xfs_scrub to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub fuzzers_online_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrefcountbt recs" +_scratch_xfs_fuzz_metadata '' 'online' "path -m $path" "addr u${inode_ver}.rtrefcbt.ptrs[1]" >> $seqres.full +echo "Done fuzzing rtrefcountbt recs" + +# success, all done +status=0 +exit
tests/xfs/1538.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1538 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1539 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1539 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt record field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers repair fuzzers_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrefcountbt recs" +_scratch_xfs_fuzz_metadata '' 'offline' "path -m $path" "addr u${inode_ver}.rtrefcbt.ptrs[1]" >> $seqres.full +echo "Done fuzzing rtrefcountbt recs" + +# success, all done +status=0 +exit
tests/xfs/1539.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1539 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1540 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1540 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt record field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers fuzzers_norepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrefcountbt recs" +_scratch_xfs_fuzz_metadata '' 'none' "path -m $path" "addr u${inode_ver}.rtrefcbt.ptrs[1]" >> $seqres.full +echo "Done fuzzing rtrefcountbt recs" + +# success, all done +status=0 +exit
tests/xfs/1540.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1540 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1541 new file +39 -0
@@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1541 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt record field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub repair fuzzers_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrefcountbt recs" +_scratch_xfs_fuzz_metadata '' 'both' "path -m $path" "addr u${inode_ver}.rtrefcbt.ptrs[1]" >> $seqres.full +echo "Done fuzzing rtrefcountbt recs" + +# success, all done +status=0 +exit
tests/xfs/1541.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1541 +Format and populate +Fuzz rtrefcountbt recs +Done fuzzing rtrefcountbt recs
tests/xfs/1542 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1542 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt key/ptr field. +# Use xfs_scrub to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub fuzzers_online_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" "path -m $path") + +echo "Fuzz rtrefcountbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrefcbt)' 'online' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrefcountbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1542.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1542 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
tests/xfs/1543 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1543 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt key/ptr field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers repair fuzzers_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" + +echo "Fuzz rtrefcountbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrefcbt)' 'offline' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrefcountbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1543.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1543 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
tests/xfs/1544 new file +37 -0
@@ -0,0 +1,37 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1544 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt key/ptr field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers fuzzers_norepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" + +echo "Fuzz rtrefcountbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrefcbt)' 'none' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrefcountbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1544.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1544 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
tests/xfs/1545 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1545 +# +# Populate a XFS filesystem and fuzz every rtrefcountbt key/ptr field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub repair fuzzers_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy +. ./common/reflink + +_require_realtime +_require_scratch_reflink +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +path="$(_scratch_xfs_find_rgbtree_height 'refcnt' 2)" || \ + _fail "could not find two-level rtrefcountbt" + +echo "Fuzz rtrefcountbt keyptrs" +_scratch_xfs_fuzz_metadata '(rtrefcbt)' 'both' "path -m $path" >> $seqres.full +echo "Done fuzzing rtrefcountbt keyptrs" + +# success, all done +status=0 +exit
tests/xfs/1545.out new file +4 -0
@@ -0,0 +1,4 @@ +QA output created by 1545 +Format and populate +Fuzz rtrefcountbt keyptrs +Done fuzzing rtrefcountbt keyptrs
Re: [PATCH 2/7] xfs: create fuzz tests for the realtime refcount btree
Looks good:
PATCH 3/7 xfs/27[24]: adapt for checking files on the realtime volume
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Adapt both tests to behave properly if the two files being tested are on the realtime volume.
--- tests/xfs/272 | 40 +++++++++++++++++++++++++------------ tests/xfs/274 | 62 ++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 70 insertions(+), 32 deletions(-)
tests/xfs/272 +27 -13
@@ -38,26 +38,40 @@ $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full ino=$(stat -c '%i' $SCRATCH_MNT/urk) echo "Get fsmap" | tee -a $seqres.full -$XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap +cat $TEST_DIR/fsmap >> $seqres.full echo "Get bmap" | tee -a $seqres.full -$XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk >> $seqres.full $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' ' ' > $TEST_DIR/bmap +cat $TEST_DIR/bmap >> $seqres.full echo "Check bmap and fsmap" | tee -a $seqres.full -cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do - qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}(| [01]*)$" - echo "${qstr}" >> $seqres.full - grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full - found=$(grep -E -c "${qstr}" $TEST_DIR/fsmap) - test $found -eq 1 || echo "Unexpected output for offset ${offrange}." -done +if $XFS_IO_PROG -c 'stat -v' $SCRATCH_MNT/urk | grep -q realtime; then + # file on rt volume + cat $TEST_DIR/bmap | while read ext offrange colon rtblockrange total crap; do + qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${rtblockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${total}(| [01]*)$" + echo "${qstr}" >> $seqres.full + grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full + found=$(grep -E -c "${qstr}" $TEST_DIR/fsmap) + test $found -eq 1 || echo "Unexpected output for offset ${offrange}." + done -echo "Check device field of FS metadata and regular file" -data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') -rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') -test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?" + echo "Check device field of FS metadata and regular file" +else + # file on data volume + cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do + qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}(| [01]*)$" + echo "${qstr}" >> $seqres.full + grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full + found=$(grep -E -c "${qstr}" $TEST_DIR/fsmap) + test $found -eq 1 || echo "Unexpected output for offset ${offrange}." + done + + echo "Check device field of FS metadata and regular file" + data_dev=$(grep 'inode btree' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') + rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}') + test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?" +fi # success, all done status=0
tests/xfs/274 +43 -19
77 lines not on this page · raw message
Re: [PATCH 3/7] xfs/27[24]: adapt for checking files on the realtime volume
Looks good:
PATCH 4/7 xfs: race fsstress with realtime refcount btree scrub and repair
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Race checking and rebuilding realtime refcount btrees with fsstress.
--- tests/xfs/1818 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1818.out | 2 ++ tests/xfs/1819 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/xfs/1819.out | 2 ++ tests/xfs/1893 | 2 +- 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 tests/xfs/1818 create mode 100644 tests/xfs/1818.out create mode 100755 tests/xfs/1819 create mode 100644 tests/xfs/1819.out
tests/xfs/1818 new file +40 -0
@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1818 +# +# Race fsstress and rt refcount btree scrub for a while to see if we crash or +# livelock. +# +. ./common/preamble +_begin_fstest scrub fsstress_scrub + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +_require_realtime +_require_scratch +_require_xfs_stress_scrub + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_require_xfs_has_feature "$SCRATCH_MNT" reflink +_xfs_force_bdev realtime $SCRATCH_MNT + +_scratch_xfs_stress_scrub -s "scrub rtrefcountbt %rgno%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/1818.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1818 +Silence is golden
tests/xfs/1819 new file +40 -0
@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 1819 +# +# Race fsstress and rt refcount btree scrub for a while to see if we crash or +# livelock. +# +. ./common/preamble +_begin_fstest online_repair fsstress_online_repair + +_cleanup() { + _scratch_xfs_stress_scrub_cleanup &> /dev/null + cd / + rm -r -f $tmp.* +} +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/fuzzy +. ./common/inject +. ./common/xfs + +_require_realtime +_require_scratch +_require_xfs_stress_online_repair + +_scratch_mkfs > "$seqres.full" 2>&1 +_scratch_mount +_require_xfs_has_feature "$SCRATCH_MNT" realtime +_require_xfs_has_feature "$SCRATCH_MNT" reflink +_xfs_force_bdev realtime $SCRATCH_MNT + +_scratch_xfs_stress_online_repair -s "repair rtrefcountbt %rgno%" + +# success, all done +echo Silence is golden +status=0 +exit
tests/xfs/1819.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 1819 +Silence is golden
tests/xfs/1893 +1 -1
@@ -46,7 +46,7 @@ done # Metapath verbs that take a rt group number for ((rgno = 0; rgno < rgcount; rgno++)); do - for v in rtbitmap rtsummary rtrmapbt; do + for v in rtbitmap rtsummary rtrmapbt rtrefcbt; do testio=$(try_verb "$v" "$rgno") test -z "$testio" && verbs+=("$v $rgno") done
Re: [PATCH 4/7] xfs: race fsstress with realtime refcount btree scrub and repair
Looks good:
PATCH 5/7 xfs: remove xfs/131 now that we allow reflink on realtime volumes
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Remove this test, since we now support reflink on the rt volume.
--- tests/xfs/131 | 46 ---------------------------------------------- tests/xfs/131.out | 5 ----- 2 files changed, 51 deletions(-) delete mode 100755 tests/xfs/131 delete mode 100644 tests/xfs/131.out
tests/xfs/131 deleted +0 -46
@@ -1,46 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. -# -# FS QA Test No. 131 -# -# Ensure that we can't reflink realtime files. -# -. ./common/preamble -_begin_fstest auto quick clone realtime - -# Override the default cleanup function. -_cleanup() -{ - cd / - umount $SCRATCH_MNT > /dev/null 2>&1 - rm -rf $tmp.* $testdir $metadump_file -} - -# Import common functions. -. ./common/filter -. ./common/reflink - -_require_realtime -_require_scratch_reflink -_require_cp_reflink - -echo "Format and mount scratch device" -_scratch_mkfs >> $seqres.full -_scratch_mount - -testdir=$SCRATCH_MNT/test-$seq -mkdir $testdir - -echo "Create the original file blocks" -blksz=65536 -$XFS_IO_PROG -R -f -c "truncate $blksz" $testdir/file1 - -echo "Reflink every block" -_cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch - -test -s $testdir/file2 && _fail "Should not be able to reflink a realtime file." - -# success, all done -status=0 -exit
tests/xfs/131.out deleted +0 -5
@@ -1,5 +0,0 @@ -QA output created by 131 -Format and mount scratch device -Create the original file blocks -Reflink every block -cp: failed to clone 'SCRATCH_MNT/test-131/file2' from 'SCRATCH_MNT/test-131/file1': Invalid argument
Re: [PATCH 5/7] xfs: remove xfs/131 now that we allow reflink on realtime volumes
Looks good:
PATCH 6/7 generic/331,xfs/240: support files that skip delayed allocation
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
The goal of this test is to ensure that log recovery finishes a copy on write operation in the event of temporary media errors. It's important that the test observe some sort of IO error once we switch the scratch device to fail all IOs, but regrettably the test encoded the specific behavior of XFS and btrfs when the test was written -- the aio write to the page cache doesn't have to touch the disk and succeeds, and the fdatasync flushes things to disk and hits the IO error.
However, this is not how things work on the XFS realtime device. There is no delalloc on realtime when the rt extent size > 1 fsblock (or on any file with extent size hints), so the aio write allocates an unwritten extent to stage the write. The allocation fails due to EIO, so it's the write call that fails. Therefore, all we need to do is to detect an IO error at any point between the write and the fdatasync call to be satisfied that the test does what we want to do.
--- tests/generic/331 | 13 +++++++++++-- tests/generic/331.out | 2 +- tests/xfs/240 | 12 ++++++++++-- tests/xfs/240.out | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-)
tests/generic/331 +11 -2
@@ -58,10 +58,19 @@ echo "CoW and unmount" $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full _scratch_sync + +# If the filesystem supports delalloc, then the fdatasync will report an IO +# error. If the write goes directly to disk, then aiocp will return nonzero. +unset write_failed _dmerror_load_error_table -$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full 2>&1 +$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full 2>&1 || \ + write_failed=1 $XFS_IO_PROG -c "fdatasync" $testdir/file2 |& \ - _filter_flakey_EIO "fdatasync: Input/output error" + _filter_flakey_EIO "fdatasync: Input/output error" | \ + grep -q 'Input.output error' && \ + write_failed=1 +test -n $write_failed && echo "write failed" + _dmerror_load_working_table _dmerror_unmount _dmerror_mount
tests/generic/331.out +1 -1
@@ -5,7 +5,7 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-331/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-331/file2 CoW and unmount -fdatasync: Input/output error +write failed Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-331/file1 d94b0ab13385aba594411c174b1cc13c SCRATCH_MNT/test-331/file2
tests/xfs/240 +10 -2
@@ -64,9 +64,17 @@ $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full _scratch_sync _dmerror_load_error_table -$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full 2>&1 +# If the filesystem supports delalloc, then the fdatasync will report an IO +# error. If the write goes directly to disk, then aiocp will return nonzero. +unset write_failed +$AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full 2>&1 || \ + write_failed=1 $XFS_IO_PROG -c "fdatasync" $testdir/file2 |& \ - _filter_flakey_EIO "fdatasync: Input/output error" + _filter_flakey_EIO "fdatasync: Input/output error" | \ + grep -q 'Input.output error' && \ + write_failed=1 +test -n $write_failed && echo "write failed" + _dmerror_load_working_table _dmerror_unmount _dmerror_mount
tests/xfs/240.out +1 -1
@@ -5,7 +5,7 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-240/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-240/file2 CoW and unmount -fdatasync: Input/output error +write failed Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-240/file1 d94b0ab13385aba594411c174b1cc13c SCRATCH_MNT/test-240/file2
Re: [PATCH 6/7] generic/331,xfs/240: support files that skip delayed allocation
Looks good:
PATCH 7/7 common/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
It's possible for the sysadmin to set rtinherit on the directory tree even if there isn't a realtime section attached to the filesystem. When this is the case, the realtime flag is /not/ passed to new files, and file data is written to the data device. The file allocation unit for the file is the fs blocksize, and it is not correct to use the rt extent.
fstests can be fooled into doing the incorrect thing if test runner puts '-d rtinherit=1 -r extsize=28k' into MKFS_OPTIONS without configuring a realtime device. This causes many tests to do the wrong thing because they think they must operate on units of 28k (and not 4k). Fix this.
--- common/xfs | 11 +++++++++++ 1 file changed, 11 insertions(+)
common/xfs +11 -0
@@ -213,6 +213,8 @@ _xfs_get_file_block_size() { local path="$1" + # If rtinherit or realtime are not set on the path, then all files + # will be created on the data device. if ! ($XFS_IO_PROG -c "stat -v" "$path" 2>&1 | grep -E -q '(rt-inherit|realtime)'); then _get_block_size "$path" return
@@ -223,6 +225,15 @@ _xfs_get_file_block_size() while ! $XFS_INFO_PROG "$path" &>/dev/null && [ "$path" != "/" ]; do path="$(dirname "$path")" done + + # If there's no realtime section, the rtinherit and rextsize settings + # are irrelevant -- all files are created on the data device. + if $XFS_INFO_PROG "$path" | grep -q 'realtime =none'; then + _get_block_size "$path" + return + fi + + # Otherwise, report the rt extent size. _xfs_get_rtextsize "$path" }
Re: [PATCH 7/7] common/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section
Looks good:
PATCH 12/12 fstests: dump fs directory trees
In reply to Darrick J. WongHi all,
Here's a functional test for recovering parts or entire filesystem trees with xfs_db.
If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=rdump
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=rdump
---
Commits in this patchset:
* xfs: test filesystem recovery with rdump
--- tests/xfs/1895 | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1895.out | 6 ++ 2 files changed, 159 insertions(+) create mode 100755 tests/xfs/1895 create mode 100644 tests/xfs/1895.out
PATCH 1/1 xfs: test filesystem recovery with rdump
From: Darrick J. Wong <[email protected]>
Test how well we can dump a fully populated filesystem's contents.
--- tests/xfs/1895 | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1895.out | 6 ++ 2 files changed, 159 insertions(+) create mode 100755 tests/xfs/1895 create mode 100644 tests/xfs/1895.out
tests/xfs/1895 new file +153 -0
@@ -0,0 +1,153 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Oracle, Inc. All Rights Reserved. +# +# FS QA Test No. 1895 +# +# Populate a XFS filesystem, ensure that rdump can "recover" the contents to +# another directory, and compare the contents. +# +. ./common/preamble +_begin_fstest auto scrub + +_cleanup() +{ + command -v _kill_fsstress &>/dev/null && _kill_fsstress + cd / + test -e "$testfiles" && rm -r -f $testfiles +} + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_db_command "rdump" +_require_test +_require_scratch +_require_scrub +_require_populate_commands + +make_md5() +{ + (cd $1 ; find . -type f -print0 | xargs -0 md5sum) > $tmp.md5.$2 +} + +cmp_md5() +{ + (cd $1 ; md5sum --quiet -c $tmp.md5.$2) +} + +make_stat() +{ + # columns: raw mode in hex, + # major rdev for special + # minor rdev for special + # uid of owner + # gid of owner + # file type + # total size + # mtime + # name + # We can't directly control directory sizes so filter them. + # Too many things can bump (or not) atime so don't test that. + (cd $1 ; find . -print0 | + xargs -0 stat -c '%f %t:%T %u %g %F %s %Y %n' | + sed -e 's/ directory [1-9][0-9]* / directory SIZE /g' | + sort) > $tmp.stat.$2 +} + +cmp_stat() +{ + diff -u $tmp.stat.$1 $tmp.stat.$2 +} + +make_stat_files() { + for file in "${FILES[@]}"; do + find "$1/$file" -print0 | xargs -0 stat -c '%f %t:%T %u %g %F %s %Y %n' + done | sed \ + -e 's/ directory [1-9][0-9]* / directory SIZE /g' \ + -e "s| $1| DUMPDIR|g" \ + | sort > $tmp.stat.files.$2 +} + +cmp_stat_files() +{ + diff -u $tmp.stat.files.$1 $tmp.stat.files.$2 +} + +make_stat_dir() { + find "$1" -print0 | \ + xargs -0 stat -c '%f %t:%T %u %g %F %s %Y %n' | sed \ + -e 's/ directory [1-9][0-9]* / directory SIZE /g' \ + -e "s| $1| DUMPDIR|g" \ + | sort > $tmp.stat.dir.$2 +} + +cmp_stat_dir() +{ + diff -u $tmp.stat.dir.$1 $tmp.stat.dir.$2 +} + +FILES=( + "/S_IFDIR.FMT_INLINE" + "/S_IFBLK" + "/S_IFCHR" + "/S_IFLNK.FMT_LOCAL" + "/S_IFIFO" + "/S_IFDIR.FMT_INLINE/00000001" + "/ATTR.FMT_EXTENTS_REMOTE3K" + "/S_IFREG.FMT_EXTENTS" + "/S_IFREG.FMT_BTREE" + "/BNOBT" + "/S_IFDIR.FMT_BLOCK" +) +DIR="/S_IFDIR.FMT_LEAF" + +testfiles=$TEST_DIR/$seq +mkdir -p $testfiles + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 +_scratch_mount + +_run_fsstress -n 500 -d $SCRATCH_MNT/newfiles + +make_stat $SCRATCH_MNT before +make_md5 $SCRATCH_MNT before +make_stat_files $SCRATCH_MNT before +make_stat_dir $SCRATCH_MNT/$DIR before +_scratch_unmount + +echo "Recover filesystem" +dumpdir1=$testfiles/rdump +dumpdir2=$testfiles/sdump +dumpdir3=$testfiles/tdump +rm -r -f $dumpdir1 $dumpdir2 $dumpdir3 + +# as of linux 6.12 fchownat does not work on symlinks +_scratch_xfs_db -c "rdump / $dumpdir1" | sed -e '/could not be set/d' +_scratch_xfs_db -c "rdump ${FILES[*]} $dumpdir2" | sed -e '/could not be set/d' +_scratch_xfs_db -c "rdump $DIR $dumpdir3" | sed -e '/could not be set/d' + +echo "Check file contents" +make_stat $dumpdir1 after +cmp_stat before after +cmp_md5 $dumpdir1 before + +echo "Check selected files contents" +make_stat_files $dumpdir2 after +cmp_stat_files before after + +echo "Check single dir extraction contents" +make_stat_dir $dumpdir3 after +cmp_stat_dir before after + +# remount so we can check this fs +_scratch_mount + +# success, all done +status=0 +exit
tests/xfs/1895.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 1895 +Format and populate +Recover filesystem +Check file contents +Check selected files contents +Check single dir extraction contents
Re: [PATCH 1/1] xfs: test filesystem recovery with rdump
Quoted 3 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Test how well we can dump a fully populated filesystem's contents.
Looks good: