btrfs: simple quotas fstests
PATCH v4 1/6 common: refactor sysfs_attr functions
In reply to Boris BurkovExpand the has/get/require functions to allow passing a dev by parameter, and implement the test_dev specific one in terms of the new generic one.
--- common/rc | 127 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 82 insertions(+), 45 deletions(-)
common/rc +82 -45
@@ -4689,47 +4689,33 @@ run_fsx() rm -f $tmp.fsx } -# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +_require_statx() +{ + $here/src/stat_test --check-statx || + _notrun "This test requires the statx system call" +} + +# Get the path to the sysfs directory for the fs on a device # # Only one argument is needed: -# - attr: path name under /sys/fs/$FSTYP/DEV +# - dev: mounted block device for the fs # # Usage example: -# _require_fs_sysfs error/fail_at_unmount -_has_fs_sysfs() +# _fs_sysfs_dname /dev/mapper/scratch-dev +_fs_sysfs_dname() { - local attr=$1 - local dname + local dev=$1 + + if [ ! -b "$dev" ]; then + _fail "Usage: _fs_sysfs_dname <mounted_device>" + fi case "$FSTYP" in btrfs) - dname=$(findmnt -n -o UUID $TEST_DEV) ;; + findmnt -n -o UUID ${dev} ;; *) - dname=$(_short_dev $TEST_DEV) ;; + _short_dev $dev ;; esac - - if [ -z "$attr" -o -z "$dname" ];then - _fail "Usage: _require_fs_sysfs <sysfs_attr_path>" - fi - - test -e /sys/fs/${FSTYP}/${dname}/${attr} -} - -# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR -_require_fs_sysfs() -{ - _has_fs_sysfs "$@" && return - - local attr=$1 - local dname=$(_short_dev $TEST_DEV) - - _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" -} - -_require_statx() -{ - $here/src/stat_test --check-statx || - _notrun "This test requires the statx system call" } # Write "content" into /sys/fs/$FSTYP/$DEV/$ATTR
@@ -4753,13 +4739,7 @@ _set_fs_sysfs_attr() _fail "Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>" fi - local dname - case "$FSTYP" in - btrfs) - dname=$(findmnt -n -o UUID ${dev}) ;; - *) - dname=$(_short_dev $dev) ;; - esac + local dname=$(_fs_sysfs_dname $dev) echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr} }
@@ -4781,17 +4761,74 @@ _get_fs_sysfs_attr() _fail "Usage: _get_fs_sysfs_attr <mounted_device> <attr>" fi - local dname - case "$FSTYP" in - btrfs) - dname=$(findmnt -n -o UUID ${dev}) ;; - *) - dname=$(_short_dev $dev) ;; - esac + local dname=$(_fs_sysfs_dname $dev) cat /sys/fs/${FSTYP}/${dname}/${attr} } +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev +# +# Usage example: +# _has_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount +_has_fs_sysfs_attr() +{ + local dev=$1 + local attr=$2 + + if [ ! -b "$dev" -o -z "$attr" ];then + _fail "Usage: _get_fs_sysfs_attr <mounted_device> <attr>" + fi + + local dname=$(_fs_sysfs_dname $dev) + + test -e /sys/fs/${FSTYP}/${dname}/${attr} +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev +# +# Usage example: +# _require_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount +_require_fs_sysfs_attr() +{ + _has_fs_sysfs_attr "$@" && return + + local dev=$1 + local attr=$2 + local dname=$(_fs_sysfs_dname $dev) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" +} + +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/DEV +# +# Usage example: +# _has_fs_sysfs error/fail_at_unmount +_has_fs_sysfs() +{ + _has_fs_sysfs_attr $TEST_DEV "$@" +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +_require_fs_sysfs() +{ + _has_fs_sysfs "$@" && return + + local attr=$1 + local dname=$(_short_dev $TEST_DEV) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" +} + # Generic test for specific filesystem feature. # Currently only implemented to test overlayfs features. _require_scratch_feature()
Signature · 1 line
2.42.0
PATCH v4 2/6 btrfs: quota mode helpers
In reply to Boris BurkovTo facilitate skipping tests depending on the qgroup mode after mkfs, add support for figuring out the mode. This cannot just rely on the new sysfs file, since it might not be present on older kernels.
--- common/btrfs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
common/btrfs +38 -0
@@ -689,3 +689,41 @@ _require_btrfs_scratch_logical_resolve_v2() fi _scratch_unmount } + +_qgroup_mode() +{ + local dev=$1 + + if [ ! -b "$dev" ]; then + _fail "Usage: _qgroup_mode <mounted_device>" + fi + + if _has_fs_sysfs_attr $dev /qgroups/mode; then + _get_fs_sysfs_attr $dev qgroups/mode + else + echo "disabled" + fi +} + +_check_regular_qgroup() +{ + _qgroup_mode "$@" | grep -q 'qgroup' +} + +_require_scratch_qgroup() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + _check_regular_qgroup $SCRATCH_DEV || _notrun "not running normal qgroups" + _scratch_unmount +} + +_require_scratch_enable_simple_quota() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _qgroup_mode $SCRATCH_DEV | grep 'squota' && _notrun "cannot enable simple quota; on by default" + $BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT || _notrun "simple quotas not available" + _scratch_unmount +}
Signature · 1 line
2.42.0
v4 cover btrfs: simple quotas fstests
Add a new test for specific squota scenarios (btrfs/301)
Also made modifications for passing existing qgroups tests when possible and for passing all tests with simple quota enabled via mkfs and with squota-aware btrfs check. Since this required reading sysfs files of scratch fses, did a bit of refactoring to make those checks target a device rather than assuming TEST_DEV.
btrfs/301 depends on the kernel patchset:
https://lore.kernel.org/linux-btrfs/[email protected]/
and the btrfs-progs patchset:
https://lore.kernel.org/linux-btrfs/[email protected]/
(and config appropriate binaries to use squota-aware versions)
---
Changelog:
v4:
- fix rescan helper bug
- fix broken tab/spaces in squota helper
- cleanup comments
- improve test names, add some comments
- switch to remount commit=1 for forcing cleaner
- fix group list for 301
- use reflink helpers
- output errors to 301.out (and have expected ones there waiting)
- cleanup "/dev/ksmg" writes I missed when grepping for /dev/kmsg
- cleanup variable names
- proper fio/btrfs/xfs_io requires
- read nodesize from dump_super
- sync before dump_tree
- documented all calls to sync
v3:
- change btrfs/400 to btrfs/301
v2:
- new sysfs helpers in common
- better gating for the new squota test
- fix various formatting issues
- get rid of noisy dmesg logging
Boris Burkov (6):
common: refactor sysfs_attr functions
btrfs: quota mode helpers
btrfs/301: new test for simple quotas
btrfs: quota rescan helpers
btrfs: use new rescan wrapper
btrfs: skip squota incompatible tests
common/btrfs | 56 ++++++ common/rc | 127 ++++++++----- tests/btrfs/017 | 1 + tests/btrfs/022 | 1 + tests/btrfs/028 | 2 +- tests/btrfs/057 | 1 + tests/btrfs/091 | 3 +- tests/btrfs/104 | 2 +- tests/btrfs/123 | 2 +- tests/btrfs/126 | 2 +- tests/btrfs/139 | 2 +- tests/btrfs/153 | 2 +- tests/btrfs/171 | 6 +- tests/btrfs/179 | 2 +- tests/btrfs/180 | 2 +- tests/btrfs/190 | 2 +- tests/btrfs/193 | 2 +- tests/btrfs/210 | 2 +- tests/btrfs/224 | 6 +- tests/btrfs/230 | 2 +- tests/btrfs/232 | 2 +- tests/btrfs/301 | 435 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/301.out | 18 ++ 23 files changed, 615 insertions(+), 65 deletions(-) create mode 100755 tests/btrfs/301 create mode 100644 tests/btrfs/301.out
Signature · 1 line
2.42.0
PATCH v4 4/6 btrfs: quota rescan helpers
Many btrfs tests explicitly trigger quota rescan. This is not a meaningful operation for simple quotas, so we wrap it in a helper that doesn't blow up quite so badly and lets us run those tests where the rescan is a qgroup detail.
--- common/btrfs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
common/btrfs +18 -0
@@ -710,6 +710,24 @@ _check_regular_qgroup() _qgroup_mode "$@" | grep -q 'qgroup' } +_qgroup_rescan() +{ + local mnt=$1 + local dev=$(findmnt -n -o SOURCE $mnt) + + _check_regular_qgroup $dev || return 1 + _run_btrfs_util_prog quota rescan -w $mnt +} + +_require_qgroup_rescan() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT || _notrun "not able to run quota rescan" + _scratch_unmount +} + _require_scratch_qgroup() { _scratch_mkfs >>$seqres.full 2>&1
Signature · 1 line
2.42.0
PATCH v4 3/6 btrfs/301: new test for simple quotas
In reply to Boris BurkovTest some interesting basic and edge cases of simple quotas.
To some extent, this is redundant with the alternate testing strategy of using MKFS_OPTIONS to enable simple quotas, running the full suite and relying on kernel warnings and fsck to surface issues.
--- tests/btrfs/301 | 435 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/301.out | 18 ++ 2 files changed, 453 insertions(+) create mode 100755 tests/btrfs/301 create mode 100644 tests/btrfs/301.out
tests/btrfs/301 new file +435 -0
@@ -0,0 +1,435 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 301 +# +# Test common btrfs simple quotas scenarios involving sharing extents and +# removing them in various orders. +# +. ./common/preamble +_begin_fstest auto quick qgroup clone subvol prealloc snapshot + +# Import common functions. +. ./common/reflink + +# Real QA test starts here. + +# Modify as appropriate. +_supported_fs btrfs +_require_scratch_reflink +_require_cp_reflink +_require_btrfs_command inspect-internal dump-tree +_require_xfs_io_command "falloc" +_require_scratch_enable_simple_quota + +subv=$SCRATCH_MNT/subv +nested=$SCRATCH_MNT/subv/nested +snap=$SCRATCH_MNT/snap +nr_fill=512 +fill_sz=$((8 * 1024)) +total_fill=$(($nr_fill * $fill_sz)) +nodesize=$($BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep nodesize | $AWK_PROG '{print $2}') +ext_sz=$((128 * 1024 * 1024)) +limit_nr=8 +limit=$(($ext_sz * $limit_nr)) + +prep_fio_config=$tmp.fio +fio_out=$tmp.fio.out +cat >$prep_fio_config <<EOF +[randwrite] +name=filler +directory=${subv} +rw=randwrite +nrfiles=${nr_fill} +filesize=${fill_sz} +EOF +_require_fio $fio_config + +get_qgroup_usage() +{ + local qgroupid=$1 + + $BTRFS_UTIL_PROG qgroup show --sync --raw $SCRATCH_MNT | grep "$qgroupid" | $AWK_PROG '{print $3}' +} + +get_subvol_usage() +{ + local subvolid=$1 + get_qgroup_usage "0/$subvolid" +} + +count_subvol_owned_metadata() +{ + local subvolid=$1 + # We need to sync so that the metadata extents are on disk and visible to dump-tree. + sync + # Find nodes and leaves owned by the subvol, then get unique offsets + # to account for snapshots sharing metadata. + count=$($BTRFS_UTIL_PROG inspect-internal dump-tree $SCRATCH_DEV | \ + grep "owner $subvolid" | $AWK_PROG '{print $2}' | sort | uniq | wc -l) + # Output bytes rather than number of metadata blocks. + echo $(($count * $nodesize)) +} + +check_qgroup_usage() +{ + local qgroupid=$1 + local expected=$2 + local actual=$(get_qgroup_usage $qgroupid) + + [ $expected -eq $actual ] || echo "qgroup $qgroupid mismatched usage $actual vs $expected" +} + +check_subvol_usage() +{ + local subvolid=$1 + local expected_data=$2 + + local expected_meta=$(count_subvol_owned_metadata $subvolid) + local actual=$(get_subvol_usage $subvolid) + local expected=$(($expected_data + $expected_meta)) + + [ $expected -eq $actual ] || echo "subvol $subvolid mismatched usage $actual vs $expected (expected data $expected_data expected meta $expected_meta diff $(($actual - $expected)))" +} + +set_subvol_limit() +{ + local subvolid=$1 + local limit=$2 + + $BTRFS_UTIL_PROG qgroup limit $2 0/$1 $SCRATCH_MNT +} + +# We need the cleaner thread to run to actually delete extents for test +# cases that care about that. The remount wakes up the cleaner thread and sets +# the commit interval to 1s, so the 1.5s sleep is enough to wait for the cleaner +# thread to run. +trigger_cleaner() +{ + _scratch_remount commit=1 + sleep 1.5 +} + +cycle_mount_check_subvol_usage() +{ + _scratch_cycle_mount + check_subvol_usage $@ +} + + +do_write() +{ + local file=$1 + local sz=$2 + + $XFS_IO_PROG -fc "pwrite -q 0 $sz" $file +} + +do_enospc_write() +{ + local file=$1 + local sz=$2 + + do_write $file $sz +} + +do_falloc() +{ + local file=$1 + local sz=$2 + + $XFS_IO_PROG -fc "falloc 0 $sz" $file +} + +do_enospc_falloc() +{ + local file=$1 + local sz=$2 + + do_falloc $file $sz +} + +enable_quota() +{ + local mode=$1 + + [ $mode == "n" ] && return + arg=$([ $mode == "s" ] && echo "--simple") + + $BTRFS_UTIL_PROG quota enable $arg $SCRATCH_MNT +} + +prepare() +{ + _scratch_mkfs >> $seqres.full + _scratch_mount + enable_quota "s" + $BTRFS_UTIL_PROG subvolume create $subv >> $seqres.full + set_subvol_limit 256 $limit + check_subvol_usage 256 0 + + # Create a bunch of little filler files to generate several levels in + # the btree, to make snapshotting sharing scenarios complex enough. + $FIO_PROG $prep_fio_config --output=$fio_out + check_subvol_usage 256 $total_fill + + # Create a single file whose extents we will explicitly share/unshare. + do_write $subv/f $ext_sz + check_subvol_usage 256 $(($total_fill + $ext_sz)) +} + +prepare_snapshotted() +{ + prepare + $BTRFS_UTIL_PROG subvolume snapshot $subv $snap >> $seqres.full + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 +} + +prepare_nested() +{ + prepare + $BTRFS_UTIL_PROG qgroup create 1/100 $SCRATCH_MNT + $BTRFS_UTIL_PROG qgroup limit $limit 1/100 $SCRATCH_MNT + $BTRFS_UTIL_PROG qgroup assign 0/256 1/100 $SCRATCH_MNT >> $seqres.full + $BTRFS_UTIL_PROG subvolume create $nested >> $seqres.full + do_write $nested/f $ext_sz + check_subvol_usage 257 $ext_sz + check_subvol_usage 256 $(($total_fill + $ext_sz)) + local subv_usage=$(get_subvol_usage 256) + local nested_usage=$(get_subvol_usage 257) + check_qgroup_usage 1/100 $(($subv_usage + $nested_usage)) +} + +# Write in a single subvolume, including going over the limit. +basic_accounting() +{ + echo "basic accounting" + prepare + rm $subv/f + check_subvol_usage 256 $total_fill + cycle_mount_check_subvol_usage 256 $total_fill + do_write $subv/tmp 512M + rm $subv/tmp + do_write $subv/tmp 512M + rm $subv/tmp + do_enospc_falloc $subv/large_falloc 2G + do_enospc_write $subv/large 2G + _scratch_unmount +} + +# Write to the same range of a file a bunch of times in a row +# to test extent aware reservations. +reservation_accounting() +{ + echo "reservation accounting" + prepare + for i in $(seq 10); do + do_write $subv/tmp 512M + rm $subv/tmp + done + do_enospc_write $subv/large 2G + _scratch_unmount +} + +# Write in a snapshot. +snapshot_accounting() +{ + echo "snapshot accounting" + prepare_snapshotted + touch $snap/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + do_write $snap/f $ext_sz + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 $ext_sz + rm $snap/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $subv/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + _scratch_unmount +} + +# Delete the original ref first after a snapshot. +delete_snapshot_src_ref() +{ + echo "delete src ref first" + prepare_snapshotted + rm $subv/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $snap/f + trigger_cleaner + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + _scratch_unmount +} + +# Delete the snapshot ref first after a snapshot. +delete_snapshot_ref() +{ + echo "delete snapshot ref first" + prepare_snapshotted + rm $snap/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $subv/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + _scratch_unmount +} + +# Delete the snapshotted subvolume after a snapshot. +delete_snapshot_src() +{ + echo "delete snapshot src first" + prepare_snapshotted + $BTRFS_UTIL_PROG subvolume delete $subv >> $seqres.full + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + rm $snap/f + trigger_cleaner + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + $BTRFS_UTIL_PROG subvolume delete $snap >> $seqres.full + trigger_cleaner + check_subvol_usage 256 0 + check_subvol_usage 257 0 + cycle_mount_check_subvol_usage 256 0 + check_subvol_usage 257 0 + _scratch_unmount +} + +# Delete the snapshot subvolume after a snapshot. +delete_snapshot() +{ + echo "delete snapshot first" + prepare_snapshotted + $BTRFS_UTIL_PROG subvolume delete $snap >> $seqres.full + check_subvol_usage 256 $(($total_fill + $ext_sz)) + check_subvol_usage 257 0 + $BTRFS_UTIL_PROG subvolume delete $subv >> $seqres.full + trigger_cleaner + check_subvol_usage 256 0 + check_subvol_usage 257 0 + _scratch_unmount +} + +# Write to a subvolume nested in another subvolume. +# Exercises the auto-inheritance feature of simple quotas. +nested_accounting() +{ + echo "nested accounting" + prepare_nested + rm $subv/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 $ext_sz + local subv_usage=$(get_subvol_usage 256) + local nested_usage=$(get_subvol_usage 257) + check_qgroup_usage 1/100 $(($subv_usage + $nested_usage)) + rm $nested/f + check_subvol_usage 256 $total_fill + check_subvol_usage 257 0 + subv_usage=$(get_subvol_usage 256) + nested_usage=$(get_subvol_usage 257) + check_qgroup_usage 1/100 $(($subv_usage + $nested_usage)) + do_enospc_falloc $nested/large_falloc 2G + do_enospc_write $nested/large 2G + _scratch_unmount +} + +# Enable simple quotas on a filesystem with existing extents. +enable_mature() +{ + echo "enable mature" + _scratch_mkfs >> $seqres.full + _scratch_mount + $BTRFS_UTIL_PROG subvolume create $subv >> $seqres.full + do_write $subv/f $ext_sz + # Sync before enabling squotas to reliably *not* count the writes + # we did before enabling. + sync + enable_quota "s" + set_subvol_limit 256 $limit + _scratch_cycle_mount + usage=$(get_subvol_usage 256) + [ $usage -lt $ext_sz ] || echo "captured usage from before enable $usage >= $ext_sz" + do_write $subv/g $ext_sz + usage=$(get_subvol_usage 256) + [ $usage -lt $ext_sz ] && echo "failed to capture usage after enable $usage < $ext_sz" + check_subvol_usage 256 $ext_sz + rm $subv/f + check_subvol_usage 256 $ext_sz + _scratch_cycle_mount + rm $subv/g + check_subvol_usage 256 0 + _scratch_unmount +} + +# Reflink a file within the subvolume. +reflink_accounting() +{ + echo "reflink" + prepare + # Do enough reflinks to prove that they're free. If they counted, then this wouldn't fit in the limit. + for i in $(seq $(($limit_nr * 2))); do + _cp_reflink $subv/f $subv/f.i + done + # Confirm that there is no additional data usage from the reflinks. + check_subvol_usage 256 $(($total_fill + $ext_sz)) + _scratch_unmount +} + +# Delete the src ref of a reflink first. +delete_reflink_src_ref() +{ + echo "delete reflink src ref" + prepare + _cp_reflink $subv/f $subv/f.link + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f.link + check_subvol_usage 256 $(($total_fill)) + _scratch_unmount +} + +# Delete the link ref of a reflink first. +delete_reflink_ref() +{ + echo "delete reflink ref" + prepare + _cp_reflink $subv/f $subv/f.link + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f.link + check_subvol_usage 256 $(($total_fill + $ext_sz)) + rm $subv/f + check_subvol_usage 256 $(($total_fill)) + _scratch_unmount +} + +basic_accounting +reservation_accounting +snapshot_accounting +delete_snapshot_src_ref +delete_snapshot_ref +delete_snapshot_src +delete_snapshot +nested_accounting +enable_mature +reflink_accounting +delete_reflink_src_ref +delete_reflink_ref + +# success, all done +status=0 +exit
tests/btrfs/301.out new file +18 -0
@@ -0,0 +1,18 @@ +QA output created by 301 +basic accounting +fallocate: Disk quota exceeded +pwrite: Disk quota exceeded +reservation accounting +pwrite: Disk quota exceeded +snapshot accounting +delete src ref first +delete snapshot ref first +delete snapshot src first +delete snapshot first +nested accounting +fallocate: Disk quota exceeded +pwrite: Disk quota exceeded +enable mature +reflink +delete reflink src ref +delete reflink ref
Signature · 1 line
2.42.0
PATCH v4 5/6 btrfs: use new rescan wrapper
In reply to Boris BurkovThese tests can pass in simple quota mode if we skip the rescans via the wrapper.
--- tests/btrfs/022 | 1 + tests/btrfs/028 | 2 +- tests/btrfs/104 | 2 +- tests/btrfs/123 | 2 +- tests/btrfs/126 | 2 +- tests/btrfs/139 | 2 +- tests/btrfs/153 | 2 +- tests/btrfs/171 | 6 +++--- tests/btrfs/179 | 2 +- tests/btrfs/180 | 2 +- tests/btrfs/190 | 2 +- tests/btrfs/193 | 2 +- tests/btrfs/210 | 2 +- tests/btrfs/224 | 6 +++--- tests/btrfs/230 | 2 +- tests/btrfs/232 | 2 +- 16 files changed, 20 insertions(+), 19 deletions(-)
tests/btrfs/022 +1 -0
@@ -14,6 +14,7 @@ _begin_fstest auto qgroup limit _supported_fs btrfs _require_scratch +_require_qgroup_rescan _require_btrfs_qgroup_report # Test to make sure we can actually turn it on and it makes sense
tests/btrfs/028 +1 -1
@@ -25,7 +25,7 @@ _scratch_mkfs >/dev/null _scratch_mount _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT # Increase the probability of generating de-refer extent, and decrease # other.
tests/btrfs/104 +1 -1
@@ -94,7 +94,7 @@ _explode_fs_tree 1 $SCRATCH_MNT/snap2/files-snap2 # Enable qgroups now that we have our filesystem prepared. This # will kick off a scan which we will have to wait for. _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT # Remount to clear cache, force everything to disk _scratch_cycle_mount
tests/btrfs/123 +1 -1
@@ -39,7 +39,7 @@ sync # enable quota and rescan to get correct number _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT # now balance data block groups to corrupt qgroup _run_btrfs_balance_start -d $SCRATCH_MNT >> $seqres.full
tests/btrfs/126 +1 -1
@@ -28,7 +28,7 @@ _scratch_mkfs >/dev/null _scratch_mount "-o enospc_debug" _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT _run_btrfs_util_prog qgroup limit 512K 0/5 $SCRATCH_MNT # The amount of written data may change due to different nodesize at mkfs time,
tests/btrfs/139 +1 -1
@@ -30,7 +30,7 @@ SUBVOL=$SCRATCH_MNT/subvol _run_btrfs_util_prog subvolume create $SUBVOL _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT _run_btrfs_util_prog qgroup limit -e 1G $SUBVOL # Write and delete files within 1G limits, multiple times
tests/btrfs/153 +1 -1
@@ -24,7 +24,7 @@ _scratch_mkfs >/dev/null _scratch_mount _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT _run_btrfs_util_prog qgroup limit 100M 0/5 $SCRATCH_MNT testfile1=$SCRATCH_MNT/testfile1
tests/btrfs/171 +3 -3
@@ -35,7 +35,7 @@ $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/subvol" \ "$SCRATCH_MNT/snapshot" > /dev/null $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan $SCRATCH_MNT > /dev/null # Create high level qgroup $BTRFS_UTIL_PROG qgroup create 1/0 "$SCRATCH_MNT"
@@ -45,7 +45,7 @@ $BTRFS_UTIL_PROG qgroup assign "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \ # Above assignment will mark qgroup inconsistent due to the shared extents # between subvol/snapshot/high level qgroup, do rescan here. -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan $SCRATCH_MNT > /dev/null # Now remove the qgroup relationship and make 1/0 childless # Due to the shared extent outside of 1/0, we will mark qgroup inconsistent
@@ -54,7 +54,7 @@ $BTRFS_UTIL_PROG qgroup remove "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \ 2>&1 | _filter_btrfs_qgroup_assign_warnings # Above removal also marks qgroup inconsistent, rescan again -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan $SCRATCH_MNT > /dev/null # After the test, btrfs check will verify qgroup numbers to catch any # corruption.
tests/btrfs/179 +1 -1
@@ -33,7 +33,7 @@ _scratch_mount mkdir -p "$SCRATCH_MNT/snapshots" $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/src" > /dev/null $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null fill_workload() {
tests/btrfs/180 +1 -1
@@ -27,7 +27,7 @@ _scratch_mkfs > /dev/null _scratch_mount $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null $BTRFS_UTIL_PROG qgroup limit -e 1G "$SCRATCH_MNT" $XFS_IO_PROG -f -c "falloc 0 900M" "$SCRATCH_MNT/padding"
tests/btrfs/190 +1 -1
@@ -30,7 +30,7 @@ _log_writes_mkfs >> $seqres.full 2>&1 _log_writes_mount $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT >> $seqres.full -$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full +_qgroup_rescan $SCRATCH_MNT >> $seqres.full # Create enough metadata for later balance for ((i = 0; i < $nr_files; i++)); do
tests/btrfs/193 +1 -1
@@ -26,7 +26,7 @@ _scratch_mkfs > /dev/null _scratch_mount $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null $BTRFS_UTIL_PROG qgroup limit -e 256M "$SCRATCH_MNT" # Create a file with the following layout:
tests/btrfs/210 +1 -1
@@ -29,7 +29,7 @@ _pwrite_byte 0xcd 0 16M "$SCRATCH_MNT/src/file" > /dev/null # by qgroup sync $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" -$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null +_qgroup_rescan "$SCRATCH_MNT" > /dev/null $BTRFS_UTIL_PROG qgroup create 1/0 "$SCRATCH_MNT" # Create a snapshot with qgroup inherit
tests/btrfs/224 +3 -3
@@ -30,7 +30,7 @@ assign_shared_test() echo "=== qgroup assign shared test ===" >> $seqres.full $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full + _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full
@@ -54,7 +54,7 @@ assign_no_shared_test() echo "=== qgroup assign no shared test ===" >> $seqres.full $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full + _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/b >> $seqres.full
@@ -75,7 +75,7 @@ snapshot_test() echo "=== qgroup snapshot test ===" >> $seqres.full $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full + _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1
tests/btrfs/230 +1 -1
@@ -31,7 +31,7 @@ _pwrite_byte 0xcd 0 1G $SCRATCH_MNT/file >> $seqres.full sync $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT -$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full +_qgroup_rescan $SCRATCH_MNT >> $seqres.full # Set the limit to just 512MiB, which is way below the existing usage $BTRFS_UTIL_PROG qgroup limit 512M 0/5 $SCRATCH_MNT
tests/btrfs/232 +1 -1
@@ -46,7 +46,7 @@ _pwrite_byte 0xcd 0 900m $SCRATCH_MNT/file >> $seqres.full sync $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT -$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full +_qgroup_rescan $SCRATCH_MNT >> $seqres.full # set the limit to 1 g, leaving us just 100mb of slack space $BTRFS_UTIL_PROG qgroup limit 1G 0/5 $SCRATCH_MNT
Signature · 1 line
2.42.0
PATCH v4 6/6 btrfs: skip squota incompatible tests
In reply to Boris BurkovThese tests cannot succeed if mkfs enable squotas, as they either test the specifics of qgroups behavior or they test *enabling* squotas. Skip these in squota mode.
--- tests/btrfs/017 | 1 + tests/btrfs/057 | 1 + tests/btrfs/091 | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
tests/btrfs/017 +1 -0
@@ -22,6 +22,7 @@ _begin_fstest auto quick qgroup _supported_fs btrfs _require_scratch +_require_scratch_qgroup _require_cloner # Currently in btrfs the node/leaf size can not be smaller than the page
tests/btrfs/057 +1 -0
@@ -15,6 +15,7 @@ _begin_fstest auto quick # real QA test starts here _supported_fs btrfs _require_scratch +_require_qgroup_rescan _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
tests/btrfs/091 +2 -1
@@ -19,6 +19,7 @@ _begin_fstest auto quick qgroup _supported_fs btrfs _require_scratch _require_cp_reflink +_require_scratch_qgroup # use largest node/leaf size (64K) to allow the test to be run on arch with # page size > 4k.
@@ -35,7 +36,7 @@ _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3 _run_btrfs_util_prog quota enable $SCRATCH_MNT -_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT +_qgroup_rescan $SCRATCH_MNT $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1
Signature · 1 line
2.42.0
Re: [PATCH v4 1/6] common: refactor sysfs_attr functions
In reply to Boris BurkovQuoted 7 lines · Boris Burkov
Expand the has/get/require functions to allow passing a dev by parameter, and implement the
test_devspecific one in terms of the new generic one.Signed-off-by Boris Burkov <[email protected]>
looks good. The diff is confusing.
a small nit below.
Quoted 6 lines
common/rc +5
-0+# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev
common/rc _get_fs_sysfs_attr() · line 4783
Quoted 10 lines
common/rc +10
-0+# +# Usage example: +# _has_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount +_has_fs_sysfs_attr() +{ + local dev=$1 + local attr=$2 + + if [ ! -b "$dev" -o -z "$attr" ];then + _fail "Usage: _get_fs_sysfs_attr <mounted_device> <attr>"
^^^ _has_fs_sysfs_attr
No need to resend.
Thanks, Anand
Quoted 51 lines
common/rc +48
-0+ fi + + local dname=$(_fs_sysfs_dname $dev) + + test -e /sys/fs/${FSTYP}/${dname}/${attr} +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev +# +# Usage example: +# _require_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount +_require_fs_sysfs_attr() +{ + _has_fs_sysfs_attr "$@" && return + + local dev=$1 + local attr=$2 + local dname=$(_fs_sysfs_dname $dev) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" +} + +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/DEV +# +# Usage example: +# _has_fs_sysfs error/fail_at_unmount +_has_fs_sysfs() +{ + _has_fs_sysfs_attr $TEST_DEV "$@" +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +_require_fs_sysfs() +{ + _has_fs_sysfs "$@" && return + + local attr=$1 + local dname=$(_short_dev $TEST_DEV) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" +} + # Generic test for specific filesystem feature. # Currently only implemented to test overlayfs features. _require_scratch_feature()
Re: [PATCH v4 2/6] btrfs: quota mode helpers
In reply to Boris BurkovQuoted 5 lines · Boris Burkov
To facilitate skipping tests depending on the qgroup mode after mkfs, add support for figuring out the mode. This cannot just rely on the new sysfs file, since it might not be present on older kernels.
Signed-off-by Boris Burkov <[email protected]>
Nits Applied locally.
common/btrfs _require_btrfs_scratch_logical_resolve_v2() · line 717
Quoted 5 lines
common/btrfs +5
-0+_require_scratch_qgroup() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT
Some time ago, we stopped using _run_btrfs_util_prog() in favor of $BTRFS_UTIL_PROG. The idea is that any errors are printed to stdout, which is good. However, $BTRFS_UTIL_PROG has a drawback: it doesn't print the command used, as run_check() does.
common/btrfs _require_btrfs_scratch_logical_resolve_v2() · line 729
Quoted 12 lines
common/btrfs +12
-0+ _check_regular_qgroup $SCRATCH_DEV || _notrun "not running normal qgroups" + _scratch_unmount +} + +_require_scratch_enable_simple_quota() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _qgroup_mode $SCRATCH_DEV | grep 'squota' && _notrun "cannot enable simple quota; on by default" + $BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT || _notrun "simple quotas not available" + _scratch_unmount +}
Fixed lines above 80 chars long.
Thanks, Anand
Re: [PATCH v4 2/6] btrfs: quota mode helpers
Quoted 12 lines · Anand Jain
Quoted 5 lines · Boris Burkov
To facilitate skipping tests depending on the qgroup mode after mkfs, add support for figuring out the mode. This cannot just rely on the new sysfs file, since it might not be present on older kernels.
Signed-off-by Boris Burkov <[email protected]>Reviewed-by Anand Jain <[email protected]>Nits Applied locally.
Quoted 9 lines
common/btrfs _require_btrfs_scratch_logical_resolve_v2() · line 717
Quoted 5 lines
common/btrfs +5
-0+_require_scratch_qgroup() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNTSome time ago, we stopped using
_run_btrfs_util_prog()in favor of > $BTRFS_UTIL_PROG. The idea is that any errors are printed to stdout, which is good. However, $BTRFS_UTIL_PROG has a drawback: it doesn't
print the command used, asrun_check()does.
I'm correcting myself: We still use _run_btrfs_util_prog() in less critical scenarios for quick status checks.
Thx, Anand
Quoted 22 lines
Quoted 13 lines
+
_check_regular_qgroup$SCRATCH_DEV ||_notrun"not running normal qgroups"
+_scratch_unmountcommon/btrfs +7
-0+} + +_require_scratch_enable_simple_quota() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _qgroup_mode $SCRATCH_DEV | grep 'squota' && _notrun "cannotQuoted 5 lines
enable simple quota; on by default"
+ $BTRFS_UTIL_PROG quota enable --simple $SCRATCH_MNT ||_notrun"simple quotas not available"
+_scratch_unmount
+}Fixed lines above 80 chars long.
Thanks, Anand
Re: [PATCH v4 4/6] btrfs: quota rescan helpers
In reply to Boris BurkovQuoted 6 lines · Boris Burkov
Many btrfs tests explicitly trigger quota rescan. This is not a meaningful operation for simple quotas, so we wrap it in a helper that doesn't blow up quite so badly and lets us run those tests where the rescan is a qgroup detail.
Signed-off-by Boris Burkov <[email protected]>
common/btrfs _check_regular_qgroup() · line 727
Quoted 6 lines
common/btrfs +6
-0+_require_qgroup_rescan() +{ + _scratch_mkfs >>$seqres.full 2>&1 + _scratch_mount + _run_btrfs_util_prog quota enable $SCRATCH_MNT + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT || _notrun "not able to run quota rescan"
Fixed line length to < 80 chars.
Thx, Anand
Re: [PATCH v4 6/6] btrfs: skip squota incompatible tests
In reply to Boris Burkovtests/btrfs/057 _begin_fstest auto quick · line 21
Quoted 13 lines
tests/btrfs/057 +1
-0@@ -15,6 +15,7 @@ _begin_fstest auto quick # real QA test starts here _supported_fs btrfs _require_scratch +_require_qgroup_rescan _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
It appears that there is an issue with rescan's stdout and stderr , causing the failure. Please consider sending a fixup which apply on top of this.
btrfs/057 4s ... - output mismatch (see /xfstests-dev/results//btrfs/057.out.bad)
--- tests/btrfs/057.out 2023-02-20 12:32:31.399005973 +0800
+++ /xfstests-dev/results//btrfs/057.out.bad 2023-09-29 17:31:24.462334654 +0800
@@ -1,2 +1,3 @@
QA output created by 057
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/057.out
/xfstests-dev/results//btrfs/057.out.bad' to see the entire diff)
Thanks, Anand
Re: [PATCH v4 5/6] btrfs: use new rescan wrapper
In reply to Boris BurkovQuoted 4 lines · Boris Burkov
These tests can pass in simple quota mode if we skip the rescans via the wrapper.
Signed-off-by Boris Burkov <[email protected]>
Thx, Anand
Quoted 2 lines
--- tests/btrfs/022 | 1 +
Nit:
Probably 022 should I have been in 6/6.
Re: [PATCH v4 6/6] btrfs: skip squota incompatible tests
In reply to Anand JainQuoted 28 lines · Anand Jain
Quoted 11 lines
tests/btrfs/057 +0
-0@@ -15,6 +15,7 @@ _begin_fstest auto quick # real QA test starts here
_supported_fsbtrfs
_require_scratch
+_require_qgroup_rescan
_scratch_mkfs_sized$((1024 * 1024 * 1024)) >> $seqres.full 2>&1It appears that there is an issue with rescan's stdout and stderr , causing the failure. Please consider sending a fixup which apply on top of this.
btrfs/057 4s ... - output mismatch (see /xfstests-dev/results//btrfs/057.out.bad)
--- tests/btrfs/057.out 2023-02-20 12:32:31.399005973 +0800 +++ /xfstests-dev/results//btrfs/057.out.bad 2023-09-29
17:31:24.462334654 +0800
@@ -1,2 +1,3 @@
QA output created by 057
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/057.out
/xfstests-dev/results//btrfs/057.out.bad' to see the entire diff)
Quoted 1 line
Thanks, Anand
And btrfs/022 as well.
btrfs/022 3s ... - output mismatch (see /xfstests-dev/results//btrfs/022.out.bad)
--- tests/btrfs/022.out 2023-02-20 12:32:31.394980330 +0800
+++ /xfstests-dev/results//btrfs/022.out.bad 2023-09-29 17:41:18.393742664 +0800
@@ -1,2 +1,3 @@
QA output created by 022
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/022.out
/xfstests-dev/results//btrfs/022.out.bad' to see the entire diff)
Re: [PATCH v4 6/6] btrfs: skip squota incompatible tests
Quoted 39 lines · Anand Jain
Quoted 30 lines · Anand Jain
Quoted 11 lines
tests/btrfs/057 +0
-0@@ -15,6 +15,7 @@ _begin_fstest auto quick # real QA test starts here
_supported_fsbtrfs
_require_scratch
+_require_qgroup_rescan
_scratch_mkfs_sized$((1024 * 1024 * 1024)) >> $seqres.full 2>&1It appears that there is an issue with rescan's stdout and stderr , causing the failure. Please consider sending a fixup which apply on top of this.
btrfs/057 4s ... - output mismatch (see /xfstests-dev/results//btrfs/057.out.bad)
--- tests/btrfs/057.out 2023-02-20 12:32:31.399005973 +0800 +++ /xfstests-dev/results//btrfs/057.out.bad 2023-09-29
17:31:24.462334654 +0800
@@ -1,2 +1,3 @@
QA output created by 057
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/057.out
/xfstests-dev/results//btrfs/057.out.bad' to see the entire diff)Quoted 1 line
Thanks, Anand
And btrfs/022 as well.
btrfs/022 3s ... - output mismatch (see
/xfstests-dev/results//btrfs/022.out.bad)--- tests/btrfs/022.out 2023-02-20 12:32:31.394980330 +0800 +++ /xfstests-dev/results//btrfs/022.out.bad 2023-09-29
Quoted 11 lines
17:41:18.393742664 +0800
@@ -1,2 +1,3 @@
QA output created by 022
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/022.out
/xfstests-dev/results//btrfs/022.out.bad' to see the entire diff)
Oh, interesting. I am using BTRFS_UTIL_PROG to run a relatively new local-built progs in my test setup and it looks like that only prints the quota rescan message with -v passed in, while my system default btrfs prints it without -v. I'll make sure the test passes with that BTRFS_UTIL_PROG as well.
Thanks for the catch and all the other review!
Just to make sure, you would like this last fix as a separate patch or should I resend?
Re: [PATCH v4 6/6] btrfs: skip squota incompatible tests
In reply to Anand JainQuoted 39 lines · Anand Jain
Quoted 30 lines · Anand Jain
Quoted 11 lines
tests/btrfs/057 +0
-0@@ -15,6 +15,7 @@ _begin_fstest auto quick # real QA test starts here
_supported_fsbtrfs
_require_scratch
+_require_qgroup_rescan
_scratch_mkfs_sized$((1024 * 1024 * 1024)) >> $seqres.full 2>&1It appears that there is an issue with rescan's stdout and stderr , causing the failure. Please consider sending a fixup which apply on top of this.
btrfs/057 4s ... - output mismatch (see /xfstests-dev/results//btrfs/057.out.bad)
--- tests/btrfs/057.out 2023-02-20 12:32:31.399005973 +0800 +++ /xfstests-dev/results//btrfs/057.out.bad 2023-09-29
17:31:24.462334654 +0800
@@ -1,2 +1,3 @@
QA output created by 057
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/057.out
/xfstests-dev/results//btrfs/057.out.bad' to see the entire diff)Quoted 1 line
Thanks, Anand
And btrfs/022 as well.
btrfs/022 3s ... - output mismatch (see
/xfstests-dev/results//btrfs/022.out.bad)--- tests/btrfs/022.out 2023-02-20 12:32:31.394980330 +0800 +++ /xfstests-dev/results//btrfs/022.out.bad 2023-09-29
Quoted 11 lines
17:41:18.393742664 +0800
@@ -1,2 +1,3 @@
QA output created by 022
+quota rescan started
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/022.out
/xfstests-dev/results//btrfs/022.out.bad' to see the entire diff)
Actually, my previous analysis about btrfs-progs was incorrect, the issue is more subtle, and has to do with the behavior of rescan -w.
TL;DR: btrfs-progs is racily swallowing that output so my setup happens to not see it. We want to redirect it to fix it.
More detail:
In the new require_qgroup_rescan helper, we call quota rescan -w right after quota enable, which will also trigger a rescan. That rescan -w can hit EINPROGRESS which causes it to 1. not print "quota rescan started" and 2. since wait_for_completion=true, it swallows that particular error and issues the rescan wait ioctl which succeeds. Based on the doc, I am assuming that is the intentional behavior of the util, so we need to handle the variable output in fstests. The other rescan callers use the checked helper, which redirects the output, but since this callsite wants _notrun instead of _fail, it doesn't redirect, so if we race in the way that actually starts a new rescan, we get the message.
PATCH 1/1 btrfs: fix rescan helper
In reply to Anand Jainrescan -w silently handles the case where a rescan is already running. rescan -W works even in squota mode, so it is insufficient to implement the requires. Therefore, preface the rescan -w with rescan -W, which should reliably trigger a real rescan start.
This results in an extra log line reliably appearing in stdout, so also redirect the output to $seqres.full.
btrfs/022 and btrfs/057 now pass with and without mkfs -O squota.
--- common/btrfs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
common/btrfs +4 -1
@@ -724,7 +724,10 @@ _require_qgroup_rescan() _scratch_mkfs >>$seqres.full 2>&1 _scratch_mount _run_btrfs_util_prog quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT || _notrun "not able to run quota rescan" + # Wait for the first rescan. + $BTRFS_UTIL_PROG quota rescan -W $SCRATCH_MNT || _notrun "not able to wait on a quota rescan" + # Make sure we can start a rescan. + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full || _notrun "not able to run quota rescan" _scratch_unmount }
Signature · 1 line
2.42.0
Re: [PATCH] btrfs: fix rescan helper
Quoted 21 lines · Boris Burkov
rescan -w silently handles the case where a rescan is already running. rescan -W works even in squota mode, so it is insufficient to implement the requires. Therefore, preface the rescan -w with rescan -W, which should reliably trigger a real rescan start.
This results in an extra log line reliably appearing in stdout, so also redirect the output to $seqres.full.
btrfs/022 and btrfs/057 now pass with and without mkfs -O squota.
Signed-off-by Boris Burkov <[email protected]>--- common/btrfs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)common/btrfs +0
-0@@ -724,7 +724,10 @@ _require_qgroup_rescan() _scratch_mkfs >>$seqres.full 2>&1
common/btrfs _require_qgroup_rescan() · line 733
Quoted 10 lines
common/btrfs +4
-1_scratch_mount _run_btrfs_util_prog quota enable $SCRATCH_MNT - $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT || _notrun "not able to run quota rescan" + # Wait for the first rescan. + $BTRFS_UTIL_PROG quota rescan -W $SCRATCH_MNT || _notrun "not able to wait on a quota rescan" + # Make sure we can start a rescan. + $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full || _notrun "not able to run quota rescan" _scratch_unmount }
Now updated.
Thanks, Anand
Quoted 71 lines · Boris Burkov
Add a new test for specific squota scenarios (btrfs/301)
Also made modifications for passing existing qgroups tests when possible and for passing all tests with simple quota enabled via mkfs and with squota-aware
btrfs check. Since this required reading sysfs files of scratch fses, did a bit of refactoring to make those checks target a device rather than assumingTEST_DEV.btrfs/301 depends on the kernel patchset:
https://lore.kernel.org/linux-btrfs/[email protected]/
and the btrfs-progs patchset:
https://lore.kernel.org/linux-btrfs/[email protected]/
(and config appropriate binaries to use squota-aware versions)
---
Changelog:
v4:
- fix rescan helper bug
- fix broken tab/spaces in squota helper
- cleanup comments
- improve test names, add some comments
- switch to remount commit=1 for forcing cleaner
- fix group list for 301
- use reflink helpers
- output errors to 301.out (and have expected ones there waiting)
- cleanup "/dev/ksmg" writes I missed when grepping for/dev/kmsg
- cleanup variable names
- proper fio/btrfs/xfs_io requires
- read nodesize fromdump_super
- sync beforedump_tree
- documented all calls to sync
v3:
- change btrfs/400 to btrfs/301
v2:
- new sysfs helpers in common
- better gating for the new squota test
- fix various formatting issues
- get rid of noisy dmesg loggingBoris Burkov (6):
common: refactorsysfs_attrfunctions
btrfs: quota mode helpers
btrfs/301: new test for simple quotas
btrfs: quota rescan helpers
btrfs: use new rescan wrapper
btrfs: skip squota incompatible testscommon/btrfs | 56 ++++++ common/rc | 127 ++++++++----- tests/btrfs/017 | 1 + tests/btrfs/022 | 1 + tests/btrfs/028 | 2 +- tests/btrfs/057 | 1 + tests/btrfs/091 | 3 +- tests/btrfs/104 | 2 +- tests/btrfs/123 | 2 +- tests/btrfs/126 | 2 +- tests/btrfs/139 | 2 +- tests/btrfs/153 | 2 +- tests/btrfs/171 | 6 +- tests/btrfs/179 | 2 +- tests/btrfs/180 | 2 +- tests/btrfs/190 | 2 +- tests/btrfs/193 | 2 +- tests/btrfs/210 | 2 +- tests/btrfs/224 | 6 +- tests/btrfs/230 | 2 +- tests/btrfs/232 | 2 +- tests/btrfs/301 | 435 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/301.out | 18 ++ 23 files changed, 615 insertions(+), 65 deletions(-)
Quoted 3 lines
create mode 100755 tests/btrfs/301
create mode 100644 tests/btrfs/301.out
All test cases modified here run fine on a system with PAGESIZE=64K, except for btrfs/153 with and without MKFS_OPTIONS="-O squota". btrfs/153 is successful on kernel v5.15 (I haven't tried other kernels)
btrfs/153 2s ... - output mismatch (see /xfstests-dev/results//btrfs/153.out.bad)
--- tests/btrfs/153.out 2021-07-13 08:07:54.096971521 -0400
+++ /xfstests-dev/results//btrfs/153.out.bad 2023-09-30 05:33:53.560640258 -0400
@@ -1,2 +1,3 @@
QA output created by 153
+pwrite: Disk quota exceeded
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/153.out
/xfstests-dev/results//btrfs/153.out.bad' to see the entire diff)
Thanks, Anand
Quoted 80 lines · Anand Jain
Quoted 71 lines · Boris Burkov
Add a new test for specific squota scenarios (btrfs/301)
Also made modifications for passing existing qgroups tests when possible and for passing all tests with simple quota enabled via mkfs and with squota-aware
btrfs check. Since this required reading sysfs files of scratch fses, did a bit of refactoring to make those checks target a device rather than assumingTEST_DEV.btrfs/301 depends on the kernel patchset:
https://lore.kernel.org/linux-btrfs/[email protected]/
and the btrfs-progs patchset:
https://lore.kernel.org/linux-btrfs/[email protected]/
(and config appropriate binaries to use squota-aware versions)
---
Changelog:
v4:
- fix rescan helper bug
- fix broken tab/spaces in squota helper
- cleanup comments
- improve test names, add some comments
- switch to remount commit=1 for forcing cleaner
- fix group list for 301
- use reflink helpers
- output errors to 301.out (and have expected ones there waiting)
- cleanup "/dev/ksmg" writes I missed when grepping for/dev/kmsg
- cleanup variable names
- proper fio/btrfs/xfs_io requires
- read nodesize fromdump_super
- sync beforedump_tree
- documented all calls to sync
v3:
- change btrfs/400 to btrfs/301
v2:
- new sysfs helpers in common
- better gating for the new squota test
- fix various formatting issues
- get rid of noisy dmesg loggingBoris Burkov (6):
common: refactorsysfs_attrfunctions
btrfs: quota mode helpers
btrfs/301: new test for simple quotas
btrfs: quota rescan helpers
btrfs: use new rescan wrapper
btrfs: skip squota incompatible testscommon/btrfs | 56 ++++++
common/rc | 127 ++++++++-----tests/btrfs/017 | 1 + tests/btrfs/022 | 1 + tests/btrfs/028 | 2 +- tests/btrfs/057 | 1 + tests/btrfs/091 | 3 +- tests/btrfs/104 | 2 +- tests/btrfs/123 | 2 +- tests/btrfs/126 | 2 +- tests/btrfs/139 | 2 +- tests/btrfs/153 | 2 +- tests/btrfs/171 | 6 +- tests/btrfs/179 | 2 +- tests/btrfs/180 | 2 +- tests/btrfs/190 | 2 +- tests/btrfs/193 | 2 +- tests/btrfs/210 | 2 +- tests/btrfs/224 | 6 +- tests/btrfs/230 | 2 +- tests/btrfs/232 | 2 +- tests/btrfs/301 | 435 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/301.out | 18 ++ 23 files changed, 615 insertions(+), 65 deletions(-)Quoted 3 lines
create mode 100755 tests/btrfs/301
create mode 100644 tests/btrfs/301.outAll test cases modified here run fine on a system with PAGESIZE=64K, except for btrfs/153 with and without MKFS_OPTIONS="-O squota". btrfs/153 is successful on kernel v5.15 (I haven't tried other kernels)
Quoted 12 lines
btrfs/153 2s ... - output mismatch (see /xfstests-dev/results//btrfs/153.out.bad)
--- tests/btrfs/153.out 2021-07-13 08:07:54.096971521 -0400 +++ /xfstests-dev/results//btrfs/153.out.bad 2023-09-30
05:33:53.560640258 -0400
@@ -1,2 +1,3 @@
QA output created by 153
+pwrite: Disk quota exceeded
Silence is golden
...
(Run 'diff -u /xfstests-dev/tests/btrfs/153.out
/xfstests-dev/results//btrfs/153.out.bad' to see the entire diff)
The test case works with the standard 4k page size. It's already in the Staged branch. Please send any required fix patches when they're ready to be applied on top of this set.
Thanks, Anand