Refactor *_fs_sysfs_* helpers
v3 cover Refactor *_fs_sysfs_* helpers
As we talked in:
https://lore.kernel.org/fstests/amhKovVDjwawoWdQ@zlang-mailbox/
This patchset refactors two redundant and messy sets of *_fs_sysfs_* helpers (PATCH 1/6 2/6), move btrfs specific sysfs policy helpers to common/btrfs (PATCH 3/6), introduces helpers for /sys/fs/$FSTYP/features (PATCH 4/6), and replaces the original btrfs-specific helpers with these common ones (PATCH 6/6).
V2 did below changes:
1) According to review point:
https://lore.kernel.org/fstests/[email protected]/
split original patch 1/5 to two patches 1/6 and 2/6.
2) According to review point:
https://lore.kernel.org/fstests/[email protected]/
rename functions in common/sysfs and move them to common/btrfs.
V3 did below changes:
1) Address Christoph's review points on [PATCH 2/6] by introducing _require_{test,scratch}_sysfs_dev_attr and wrapping lines that were too long (Waiting for RVB).
2) Since an upcoming test case (btrfs/363) is also affected by [PATCH 6/6], I have rebased patch 6/6 and the entire patchset onto the latest patches-in-queue branch.
Thanks,
Zorro
Zorro Lang (6):
fstests: rename _*_fs_sysfs_attr helpers to _*_fs_sysfs_dev_attr
fstests: consolidate _require_fs_sysfs and _require_fs_sysfs_dev_attr
common: move btrfs-only sysfs policy helpers out of common/sysfs common/rc: add helpers for /sys/fs/$FSTYP/features/ common/rc: use common helper in _require_fanotify_ioerrors for f2fs
fstests: replace btrfs specific helpers with common sysfs helpers
common/btrfs | 176 ++++++++++++++++++++++++++++++++++++---------- common/rc | 109 +++++++++++++++++++++------- common/sysfs | 145 -------------------------------------- common/xfs | 24 ++++--- tests/btrfs/010 | 3 +- tests/btrfs/055 | 2 +- tests/btrfs/056 | 2 +- tests/btrfs/112 | 2 +- tests/btrfs/131 | 2 +- tests/btrfs/165 | 2 +- tests/btrfs/188 | 2 +- tests/btrfs/192 | 2 +- tests/btrfs/201 | 2 +- tests/btrfs/205 | 2 +- tests/btrfs/209 | 2 +- tests/btrfs/211 | 2 +- tests/btrfs/219 | 3 +- tests/btrfs/231 | 2 +- tests/btrfs/253 | 29 ++++---- tests/btrfs/285 | 3 +- tests/btrfs/296 | 8 +-- tests/btrfs/304 | 4 +- tests/btrfs/305 | 4 +- tests/btrfs/306 | 4 +- tests/btrfs/307 | 4 +- tests/btrfs/308 | 4 +- tests/btrfs/311 | 2 +- tests/btrfs/313 | 2 +- tests/btrfs/314 | 2 +- tests/btrfs/315 | 2 +- tests/btrfs/329 | 5 +- tests/btrfs/334 | 5 +- tests/btrfs/342 | 2 +- tests/btrfs/352 | 2 +- tests/btrfs/363 | 2 +- tests/f2fs/025 | 2 +- tests/generic/098 | 2 +- tests/generic/101 | 2 +- tests/xfs/006 | 4 +- tests/xfs/177 | 4 +- tests/xfs/264 | 14 ++-- tests/xfs/668 | 6 +- tests/xfs/669 | 6 +- tests/xfs/670 | 2 +- 44 files changed, 307 insertions(+), 303 deletions(-) delete mode 100644 common/sysfs
Signature · 1 line
2.56.0
PATCH v3 1/6 fstests: rename _*_fs_sysfs_attr helpers to _*_fs_sysfs_dev_attr
The _set/_get/_has/_require_fs_sysfs_attr helpers all operate on per-device sysfs entries under /sys/fs/$FSTYP/$dev. Insert "_dev_" into their names to distinguish them from other sysfs paths such as /sys/fs/$FSTYP/features/, and update all callers. No functional change.
--- common/btrfs | 4 ++-- common/rc | 30 +++++++++++++++--------------- common/sysfs | 6 +++--- common/xfs | 22 +++++++++++----------- tests/btrfs/253 | 22 +++++++++++----------- tests/btrfs/334 | 2 +- tests/f2fs/025 | 2 +- tests/xfs/006 | 2 +- tests/xfs/177 | 2 +- tests/xfs/264 | 8 ++++---- tests/xfs/668 | 6 +++--- tests/xfs/669 | 6 +++--- tests/xfs/670 | 2 +- 13 files changed, 57 insertions(+), 57 deletions(-)
common/btrfs +2 -2
@@ -906,8 +906,8 @@ _qgroup_mode() _fail "Usage: _qgroup_mode <mounted_device>" fi - if _has_fs_sysfs_attr $dev /qgroups/mode; then - _get_fs_sysfs_attr $dev qgroups/mode + if _has_fs_sysfs_dev_attr $dev /qgroups/mode; then + _get_fs_sysfs_dev_attr $dev qgroups/mode else echo "qgroup" fi
common/rc +15 -15
@@ -4223,7 +4223,7 @@ _require_fs_survives_data_write_eio() # This is an XFS per-mount sysfs attribute, not a block queue # attribute. Its existence means XFS mounted this instance with # zoned filesystem semantics. - if _has_fs_sysfs_attr "$dev" "zoned/max_open_zones"; then + if _has_fs_sysfs_dev_attr "$dev" "zoned/max_open_zones"; then _notrun "zoned XFS shuts down on data write EIO" fi ;;
@@ -5481,8 +5481,8 @@ _fs_sysfs_dname() # - content: the content of $attr # # Usage example: -# _set_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount 0 -_set_fs_sysfs_attr() +# _set_fs_sysfs_dev_attr /dev/mapper/scratch-dev error/fail_at_unmount 0 +_set_fs_sysfs_dev_attr() { local dev=$1 shift
@@ -5491,7 +5491,7 @@ _set_fs_sysfs_attr() local content="$*" if [ ! -b "$dev" -o -z "$attr" -o -z "$content" ];then - _fail "Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>" + _fail "Usage: _set_fs_sysfs_dev_attr <mounted_device> <attr> <content>" fi local dname=$(_fs_sysfs_dname $dev)
@@ -5507,14 +5507,14 @@ _set_fs_sysfs_attr() # - attr: path name under /sys/fs/$FSTYP/$dev # # Usage example: -# _get_fs_sysfs_attr /dev/mapper/scratch-dev error/fail_at_unmount -_get_fs_sysfs_attr() +# _get_fs_sysfs_dev_attr /dev/mapper/scratch-dev error/fail_at_unmount +_get_fs_sysfs_dev_attr() { local dev=$1 local attr=$2 if [ ! -b "$dev" -o -z "$attr" ];then - _fail "Usage: _get_fs_sysfs_attr <mounted_device> <attr>" + _fail "Usage: _get_fs_sysfs_dev_attr <mounted_device> <attr>" fi local dname=$(_fs_sysfs_dname $dev)
@@ -5529,14 +5529,14 @@ _get_fs_sysfs_attr() # - 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() +# _has_fs_sysfs_dev_attr /dev/mapper/scratch-dev error/fail_at_unmount +_has_fs_sysfs_dev_attr() { local dev=$1 local attr=$2 if [ ! -b "$dev" -o -z "$attr" ];then - _fail "Usage: _has_fs_sysfs_attr <mounted_device> <attr>" + _fail "Usage: _has_fs_sysfs_dev_attr <mounted_device> <attr>" fi local dname=$(_fs_sysfs_dname $dev)
@@ -5550,10 +5550,10 @@ _has_fs_sysfs_attr() # - 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() +# _require_fs_sysfs_dev_attr /dev/mapper/scratch-dev error/fail_at_unmount +_require_fs_sysfs_dev_attr() { - _has_fs_sysfs_attr "$@" && return + _has_fs_sysfs_dev_attr "$@" && return local dev=$1 local attr=$2
@@ -5571,7 +5571,7 @@ _require_fs_sysfs_attr() # _has_fs_sysfs error/fail_at_unmount _has_fs_sysfs() { - _has_fs_sysfs_attr $TEST_DEV "$@" + _has_fs_sysfs_dev_attr $TEST_DEV "$@" } # Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
@@ -6302,7 +6302,7 @@ _require_fanotify_ioerrors() ;; ext4) # added at the same time as err_report_sec - x="$(_get_fs_sysfs_attr $TEST_DEV err_report_sec)" + x="$(_get_fs_sysfs_dev_attr $TEST_DEV err_report_sec)" test -n "$x" && return 0 ;; f2fs)
common/sysfs +3 -3
@@ -61,11 +61,11 @@ _set_sysfs_policy() shift local policy=$@ - _set_fs_sysfs_attr $dev $attr ${policy} + _set_fs_sysfs_dev_attr $dev $attr ${policy} case "$FSTYP" in btrfs) - _get_fs_sysfs_attr $dev $attr | grep -q "[${policy}]" + _get_fs_sysfs_dev_attr $dev $attr | grep -q "[${policy}]" if [[ $? != 0 ]]; then echo "Setting sysfs $attr $policy failed" fi
@@ -85,7 +85,7 @@ _set_sysfs_policy_must_fail() shift local policy=$@ - _set_fs_sysfs_attr $dev $attr ${policy} | _filter_sysfs_error \ + _set_fs_sysfs_dev_attr $dev $attr ${policy} | _filter_sysfs_error \ | tee -a $seqres.full }
common/xfs +11 -11
@@ -1167,23 +1167,23 @@ _reset_xfs_sysfs_error_handling() _fail "Usage: reset_xfs_sysfs_error_handling <device>" fi - _set_fs_sysfs_attr $dev error/fail_at_unmount 1 + _set_fs_sysfs_dev_attr $dev error/fail_at_unmount 1 echo -n "error/fail_at_unmount=" - _get_fs_sysfs_attr $dev error/fail_at_unmount + _get_fs_sysfs_dev_attr $dev error/fail_at_unmount # Make sure all will be configured to retry forever by default, except # for ENODEV, which is an unrecoverable error, so it will be configured # to not retry on error by default. for e in default EIO ENOSPC; do - _set_fs_sysfs_attr $dev \ + _set_fs_sysfs_dev_attr $dev \ error/metadata/${e}/max_retries -1 echo -n "error/metadata/${e}/max_retries=" - _get_fs_sysfs_attr $dev error/metadata/${e}/max_retries + _get_fs_sysfs_dev_attr $dev error/metadata/${e}/max_retries - _set_fs_sysfs_attr $dev \ + _set_fs_sysfs_dev_attr $dev \ error/metadata/${e}/retry_timeout_seconds -1 echo -n "error/metadata/${e}/retry_timeout_seconds=" - _get_fs_sysfs_attr $dev \ + _get_fs_sysfs_dev_attr $dev \ error/metadata/${e}/retry_timeout_seconds done }
@@ -1226,13 +1226,13 @@ _xfs_prepare_for_eio_shutdown() _add_dmesg_filter "Internal error" # Don't retry any writes during the (presumably) post-shutdown unmount - _has_fs_sysfs "$ctlfile" && _set_fs_sysfs_attr $dev "$ctlfile" 1 + _has_fs_sysfs "$ctlfile" && _set_fs_sysfs_dev_attr $dev "$ctlfile" 1 # Disable retry of metadata writes that fail with EIO for ctl in max_retries retry_timeout_seconds; do ctlfile="error/metadata/EIO/$ctl" - _has_fs_sysfs "$ctlfile" && _set_fs_sysfs_attr $dev "$ctlfile" 0 + _has_fs_sysfs "$ctlfile" && _set_fs_sysfs_dev_attr $dev "$ctlfile" 0 done }
@@ -2149,7 +2149,7 @@ _scratch_xfs_force_no_metadir() # do not run on zoned file systems _require_xfs_scratch_non_zoned() { - if _has_fs_sysfs_attr $SCRATCH_DEV "zoned/max_open_zones"; then + if _has_fs_sysfs_dev_attr $SCRATCH_DEV "zoned/max_open_zones"; then _notrun "Not supported on zoned file systems" fi }
@@ -2160,12 +2160,12 @@ _require_xfs_scratch_zoned() local attr="zoned/max_open_zones" local min_open_zones=$1 - if ! _has_fs_sysfs_attr $SCRATCH_DEV $attr; then + if ! _has_fs_sysfs_dev_attr $SCRATCH_DEV $attr; then _notrun "Requires zoned file system" fi if [ -n "${min_open_zones}" ]; then - local has_open_zones=`_get_fs_sysfs_attr $SCRATCH_DEV $attr` + local has_open_zones=`_get_fs_sysfs_dev_attr $SCRATCH_DEV $attr` if [ "${min_open_zones}" -gt "${has_open_zones}" ]; then _notrun "Requires at least ${min_open_zones} open zones"
tests/btrfs/253 +11 -11
@@ -119,7 +119,7 @@ FIRST_DATA_CHUNK_SIZE_B=$((1024 * 1024 * 1024)) # For metadata, we are safe to use the exported value, as the default # metadata chunk size limit is already smaller than its stripe size. -FIRST_METADATA_CHUNK_SIZE_B=$(_get_fs_sysfs_attr ${SCRATCH_BDEV} allocation/metadata/chunk_size) +FIRST_METADATA_CHUNK_SIZE_B=$(_get_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/metadata/chunk_size) echo "Orig Data chunk size = ${FIRST_DATA_CHUNK_SIZE_B}" >> ${seqres}.full echo "Orig Metaata chunk size = ${FIRST_METADATA_CHUNK_SIZE_B}" >> ${seqres}.full
@@ -138,8 +138,8 @@ alloc_size "Metadata" METADATA_SIZE_START_MB echo "Block group Data alloc size = ${DATA_SIZE_START_MB}MB" >> $seqres.full echo "Block group Metadata alloc size = ${METADATA_SIZE_START_MB}MB" >> $seqres.full -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/data/force_chunk_alloc 1 -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/metadata/force_chunk_alloc 1 +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/data/force_chunk_alloc 1 +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/metadata/force_chunk_alloc 1 alloc_size "Data" FIRST_DATA_SIZE_MB alloc_size "Metadata" FIRST_METADATA_SIZE_MB
@@ -171,15 +171,15 @@ fi echo "Second block group Data alloc size = ${SECOND_DATA_CHUNK_SIZE_B}" >> $seqres.full echo "Second block group Metadata alloc size = ${SECOND_METADATA_CHUNK_SIZE_B}" >> $seqres.full -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/data/chunk_size ${SECOND_DATA_CHUNK_SIZE_B} -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/metadata/chunk_size ${SECOND_METADATA_CHUNK_SIZE_B} +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/data/chunk_size ${SECOND_DATA_CHUNK_SIZE_B} +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/metadata/chunk_size ${SECOND_METADATA_CHUNK_SIZE_B} -SECOND_DATA_CHUNK_SIZE_READ_B=$(_get_fs_sysfs_attr ${SCRATCH_BDEV} allocation/data/chunk_size) -SECOND_METADATA_CHUNK_SIZE_READ_B=$(_get_fs_sysfs_attr ${SCRATCH_BDEV} allocation/metadata/chunk_size) +SECOND_DATA_CHUNK_SIZE_READ_B=$(_get_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/data/chunk_size) +SECOND_METADATA_CHUNK_SIZE_READ_B=$(_get_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/metadata/chunk_size) -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/data/force_chunk_alloc 1 +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/data/force_chunk_alloc 1 echo "Allocated data chunk" >> $seqres.full -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/metadata/force_chunk_alloc 1 +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/metadata/force_chunk_alloc 1 echo "Allocated metadata chunk" >> $seqres.full alloc_size "Data" SECOND_DATA_SIZE_MB
@@ -210,12 +210,12 @@ echo "Allocation size in bytes = ${THIRD_DATA_CHUNK_SIZE_B}" >> ${seqres}.full # Do allocation until free space is exhausted. # echo "Third allocation." -_set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/data/chunk_size ${THIRD_DATA_CHUNK_SIZE_B} +_set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/data/chunk_size ${THIRD_DATA_CHUNK_SIZE_B} free_space FREE_SPACE_MB while [ $FREE_SPACE_MB -gt $THIRD_DATA_CHUNK_SIZE_MB ]; do alloc_size "Data" THIRD_DATA_SIZE_MB - _set_fs_sysfs_attr ${SCRATCH_BDEV} allocation/data/force_chunk_alloc 1 + _set_fs_sysfs_dev_attr ${SCRATCH_BDEV} allocation/data/force_chunk_alloc 1 free_space FREE_SPACE_MB done
tests/btrfs/334 +1 -1
@@ -13,7 +13,7 @@ _begin_fstest auto quick . ./common/filter _require_test -_require_fs_sysfs_attr $TEST_DEV allocation/data/chunk_size +_require_fs_sysfs_dev_attr $TEST_DEV allocation/data/chunk_size _verify_sysfs_syntax $TEST_DEV allocation/data/chunk_size 256m
tests/f2fs/025 +1 -1
@@ -21,7 +21,7 @@ _require_scratch_shutdown _require_xfs_io_command "pwrite" _require_xfs_io_command "truncate" _require_f2fs_io_command gc_urgent -_require_fs_sysfs_attr $TEST_DEV gc_urgent +_require_fs_sysfs_dev_attr $TEST_DEV gc_urgent _require_check_dmesg # Clear options to avoid interference from external configurations
tests/xfs/006 +1 -1
@@ -38,7 +38,7 @@ _reset_xfs_sysfs_error_handling $DMERROR_DEV # errors at unmount time. _fail the test if we fail to set it to 1, # because the test probably will hang in such case and block # subsequent tests. -attr=`_get_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount` +attr=`_get_fs_sysfs_dev_attr $DMERROR_DEV error/fail_at_unmount` if [ "$attr" != "1" ]; then _fail "Failed to set error/fail_at_unmount: $attr" fi
tests/xfs/177 +1 -1
@@ -51,7 +51,7 @@ _require_scratch _require_fs_sysfs stats/stats count_xfs_inode_objs() { - _get_fs_sysfs_attr $SCRATCH_DEV stats/stats | awk '/vnodes/ {print $2}' + _get_fs_sysfs_dev_attr $SCRATCH_DEV stats/stats | awk '/vnodes/ {print $2}' } dump_debug_info() {
tests/xfs/264 +4 -4
@@ -39,12 +39,12 @@ do_test() _dmerror_mount _reset_xfs_sysfs_error_handling $DMERROR_DEV # Disable fail_at_unmount before test EIO error handling - _set_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount 0 + _set_fs_sysfs_dev_attr $DMERROR_DEV error/fail_at_unmount 0 echo -n "error/fail_at_unmount=" - _get_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount + _get_fs_sysfs_dev_attr $DMERROR_DEV error/fail_at_unmount - _set_fs_sysfs_attr $DMERROR_DEV $attr 1 - num=`_get_fs_sysfs_attr $DMERROR_DEV $attr` + _set_fs_sysfs_dev_attr $DMERROR_DEV $attr 1 + num=`_get_fs_sysfs_dev_attr $DMERROR_DEV $attr` echo "$attr=$num" # _fail the test if we fail to set $attr to 1, because the test # probably will hang in such case and block subsequent tests.
tests/xfs/668 +3 -3
@@ -36,7 +36,7 @@ done # remount read-only and set the gc limit to free up unused space _scratch_remount ro rt_available_pre="$(_xfs_get_user_available_rt_blocks "$SCRATCH_MNT")" -_set_fs_sysfs_attr $SCRATCH_DEV "zoned/zonegc_low_space" 100 +_set_fs_sysfs_dev_attr $SCRATCH_DEV "zoned/zonegc_low_space" 100 # reclaiming a zone with 5% used blocks should take way less than 1 second sleep 1
@@ -46,14 +46,14 @@ rt_available_post="$(_xfs_get_user_available_rt_blocks "$SCRATCH_MNT")" [ "$rt_available_post" -gt "$rt_available_pre" ] && \ _fail "gc should not run while read only" -_set_fs_sysfs_attr $SCRATCH_DEV "zoned/zonegc_low_space" 0 +_set_fs_sysfs_dev_attr $SCRATCH_DEV "zoned/zonegc_low_space" 0 # remount rw and check that gc starts, frees up blocks and stops after # the threshold is set to reclaim the unused blocks _scratch_remount rw rt_available_pre="$(_xfs_get_user_available_rt_blocks "$SCRATCH_MNT")" -_set_fs_sysfs_attr $SCRATCH_DEV "zoned/zonegc_low_space" 100 +_set_fs_sysfs_dev_attr $SCRATCH_DEV "zoned/zonegc_low_space" 100 i=0 while [ $(_xfs_get_rt_gc_required "$SCRATCH_MNT") -eq "1" ]; do
tests/xfs/669 +3 -3
@@ -35,7 +35,7 @@ $MKFS_XFS_PROG -b size=${bsize} -r zoned=1,rgsize=${blocks}b \ _mount $SCRATCH_DEV $SCRATCH_MNT -o max_open_zones=${open_zones} || \ _notrun "Zoned allocator not supported" -_has_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones || \ +_has_fs_sysfs_dev_attr $SCRATCH_DEV zoned/nr_open_zones || \ _notrun "This test requires /sys/fs/${FSTYP}/$SCRATCH_DEV/zoned/nr_open_zones" for i in $(seq 1 $nr_files); do
@@ -51,8 +51,8 @@ done _scratch_unmount _mount $SCRATCH_DEV $SCRATCH_MNT -o max_open_zones=${open_zones} -max_open=$(_get_fs_sysfs_attr $SCRATCH_DEV zoned/max_open_zones) -nr_open=$(_get_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones) +max_open=$(_get_fs_sysfs_dev_attr $SCRATCH_DEV zoned/max_open_zones) +nr_open=$(_get_fs_sysfs_dev_attr $SCRATCH_DEV zoned/nr_open_zones) if [ ${max_open} -ne $((open_zones - 1)) ]; then _fail "Test needs adjustments for multiple open GC zones"
tests/xfs/670 +1 -1
@@ -36,7 +36,7 @@ $XFS_GROWFS_PROG $SCRATCH_MNT -R $((2 * rblocks)) >> $seqres.full 2>&1 || \ # For zoned file systems, check that the growfs did increase the available free # zones. This avoids a hang on unfixed kernels when filling later. free_zones_post=$(_xfs_get_mountstat $SCRATCH_MNT "free zones:") -if _has_fs_sysfs_attr $SCRATCH_DEV "zoned/max_open_zones"; then +if _has_fs_sysfs_dev_attr $SCRATCH_DEV "zoned/max_open_zones"; then if [ "$free_zones_pre" == "$free_zones_post" ]; then _fail "growfs did not increase free zones" fi
Signature · 1 line
2.56.0
PATCH v3 2/6 fstests: consolidate _require_fs_sysfs and _require_fs_sysfs_dev_attr
In reply to Zorro LangThere is heavy overlap between _require_fs_sysfs and _require_fs_sysfs_dev_attr, and their ambiguous names make it difficult to tell them apart.
Make _require_fs_sysfs_dev_attr a generic helper that requires both a device and an attribute, remove _has_fs_sysfs and _require_fs_sysfs, and add _require_test_sysfs_dev_attr and _require_scratch_sysfs_dev_attr wrappers.
--- common/rc | 28 +++++++++++++++------------- common/xfs | 6 ++++-- tests/btrfs/253 | 4 ++-- tests/btrfs/285 | 2 +- tests/btrfs/334 | 2 +- tests/f2fs/025 | 2 +- tests/xfs/006 | 2 +- tests/xfs/177 | 2 +- tests/xfs/264 | 6 +++--- 9 files changed, 29 insertions(+), 25 deletions(-)
common/rc +15 -13
@@ -5545,6 +5545,7 @@ _has_fs_sysfs_dev_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
@@ -5562,27 +5563,28 @@ _require_fs_sysfs_dev_attr() _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" } -# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$TEST_DEV/$ATTR # # Only one argument is needed: -# - attr: path name under /sys/fs/$FSTYP/DEV +# - attr: path name under /sys/fs/$FSTYP/$TEST_DEV # # Usage example: -# _has_fs_sysfs error/fail_at_unmount -_has_fs_sysfs() +# _require_test_sysfs_dev_attr error/fail_at_unmount +_require_test_sysfs_dev_attr() { - _has_fs_sysfs_dev_attr $TEST_DEV "$@" + _require_fs_sysfs_dev_attr $TEST_DEV "$1" } -# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR -_require_fs_sysfs() +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$SCRATCH_DEV/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/$SCRATCH_DEV +# +# Usage example: +# _require_scratch_sysfs_dev_attr error/fail_at_unmount +_require_scratch_sysfs_dev_attr() { - _has_fs_sysfs "$@" && return - - local attr=$1 - local dname=$(_short_dev $TEST_DEV) - - _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}" + _require_fs_sysfs_dev_attr $SCRATCH_DEV "$1" } # Generic test for specific filesystem feature.
common/xfs +4 -2
@@ -1226,13 +1226,15 @@ _xfs_prepare_for_eio_shutdown() _add_dmesg_filter "Internal error" # Don't retry any writes during the (presumably) post-shutdown unmount - _has_fs_sysfs "$ctlfile" && _set_fs_sysfs_dev_attr $dev "$ctlfile" 1 + _has_fs_sysfs_dev_attr $dev "$ctlfile" && \ + _set_fs_sysfs_dev_attr $dev "$ctlfile" 1 # Disable retry of metadata writes that fail with EIO for ctl in max_retries retry_timeout_seconds; do ctlfile="error/metadata/EIO/$ctl" - _has_fs_sysfs "$ctlfile" && _set_fs_sysfs_dev_attr $dev "$ctlfile" 0 + _has_fs_sysfs_dev_attr $dev "$ctlfile" && \ + _set_fs_sysfs_dev_attr $dev "$ctlfile" 0 done }
tests/btrfs/253 +2 -2
@@ -90,8 +90,8 @@ _scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1 # Check if there is sufficient sysfs support. -_require_fs_sysfs allocation/metadata/chunk_size -_require_fs_sysfs allocation/metadata/force_chunk_alloc +_require_test_sysfs_dev_attr allocation/metadata/chunk_size +_require_test_sysfs_dev_attr allocation/metadata/force_chunk_alloc # Get free space. free_space FREE_SPACE_MB
tests/btrfs/285 +1 -1
@@ -16,7 +16,7 @@ sysfs_size_classes() { _require_scratch _require_btrfs_fs_sysfs -_require_fs_sysfs allocation/data/size_classes +_require_test_sysfs_dev_attr allocation/data/size_classes f="$SCRATCH_MNT/f" small=$((16 * 1024))
tests/btrfs/334 +1 -1
@@ -13,7 +13,7 @@ _begin_fstest auto quick . ./common/filter _require_test -_require_fs_sysfs_dev_attr $TEST_DEV allocation/data/chunk_size +_require_test_sysfs_dev_attr allocation/data/chunk_size _verify_sysfs_syntax $TEST_DEV allocation/data/chunk_size 256m
tests/f2fs/025 +1 -1
@@ -21,7 +21,7 @@ _require_scratch_shutdown _require_xfs_io_command "pwrite" _require_xfs_io_command "truncate" _require_f2fs_io_command gc_urgent -_require_fs_sysfs_dev_attr $TEST_DEV gc_urgent +_require_test_sysfs_dev_attr gc_urgent _require_check_dmesg # Clear options to avoid interference from external configurations
tests/xfs/006 +1 -1
@@ -25,7 +25,7 @@ _cleanup() _require_scratch _require_dm_target error -_require_fs_sysfs error/fail_at_unmount +_require_test_sysfs_dev_attr error/fail_at_unmount _scratch_mkfs > $seqres.full 2>&1 _dmerror_init
tests/xfs/177 +1 -1
@@ -48,7 +48,7 @@ _require_scratch # We require /sys/fs/xfs/$device/stats/stats to monitor per-filesystem inode # cache usage. -_require_fs_sysfs stats/stats +_require_test_sysfs_dev_attr stats/stats count_xfs_inode_objs() { _get_fs_sysfs_dev_attr $SCRATCH_DEV stats/stats | awk '/vnodes/ {print $2}'
tests/xfs/264 +3 -3
@@ -24,9 +24,9 @@ _cleanup() _require_scratch _require_dm_target error -_require_fs_sysfs error/fail_at_unmount -_require_fs_sysfs error/metadata/EIO/max_retries -_require_fs_sysfs error/metadata/EIO/retry_timeout_seconds +_require_test_sysfs_dev_attr error/fail_at_unmount +_require_test_sysfs_dev_attr error/metadata/EIO/max_retries +_require_test_sysfs_dev_attr error/metadata/EIO/retry_timeout_seconds _scratch_mkfs >> $seqres.full 2>&1 _dmerror_init
Signature · 1 line
2.56.0
Re: [PATCH v3 2/6] fstests: consolidate _require_fs_sysfs and _require_fs_sysfs_dev_attr
Looks good:
PATCH v3 3/6 common: move btrfs-only sysfs policy helpers out of common/sysfs
In reply to Zorro LangThe sysfs policy helpers in common/sysfs are only usable for btrfs. The only filesystem supported by them is btrfs and the only callers are btrfs tests. So rename them with a _btrfs_ infix and move them to common/btrfs, then remove empty common/sysfs and its references.
--- common/btrfs | 135 ++++++++++++++++++++++++++++++++++++++++++++ common/sysfs | 145 ------------------------------------------------ tests/btrfs/253 | 3 +- tests/btrfs/329 | 5 +- tests/btrfs/334 | 3 +- 5 files changed, 139 insertions(+), 152 deletions(-) delete mode 100644 common/sysfs
common/btrfs +135 -0
@@ -1084,3 +1084,138 @@ _require_btrfs_iouring_encoded_read() _notrun "btrfs io_uring encoded read failed with -EOPNOTSUPP" fi } + +# Btrfs-only sysfs policy helpers. They operate on per-device sysfs +# attributes that accept a "policy" value, e.g. read_policy. + +# Test for the existence of a policy 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 +# - policy: policy within /sys/fs/$FSTYP/$dev +# +# Usage example: +# _has_btrfs_sysfs_dev_policy /dev/mapper/scratch-dev read_policy round-robin +_has_btrfs_sysfs_dev_policy() +{ + local dev=$1 + local attr=$2 + local policy=$3 + + if [ ! -b "$dev" -o -z "$attr" -o -z "$policy" ]; then + _fail \ + "Usage: _has_btrfs_sysfs_dev_policy <mounted_device> <attr> <policy>" + fi + + local dname=$(_fs_sysfs_dname $dev) + if ! test -e /sys/fs/${FSTYP}/${dname}/${attr}; then + return 1 + fi + + cat /sys/fs/${FSTYP}/${dname}/${attr} | grep -q ${policy} +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR +# and value in it contains $policy +# All arguments are necessary, and in this order: +# - dev: device name, e.g. $SCRATCH_DEV +# - attr: path name under /sys/fs/$FSTYP/$dev +# - policy: mentioned in /sys/fs/$FSTYP/$dev/$attr +# +# Usage example: +# _require_btrfs_sysfs_dev_policy /dev/mapper/scratch-dev read_policy round-robin +_require_btrfs_sysfs_dev_policy() +{ + _has_btrfs_sysfs_dev_policy "$@" && return + + local dev=$1 + local attr=$2 + local policy=$3 + local dname=$(_fs_sysfs_dname $dev) + + _notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr} ${policy}" +} + +_set_btrfs_sysfs_dev_policy() +{ + local dev=$1 + local attr=$2 + shift + shift + local policy=$@ + + _set_fs_sysfs_dev_attr $dev $attr ${policy} + + _get_fs_sysfs_dev_attr $dev $attr | grep -q "[${policy}]" + if [[ $? != 0 ]]; then + echo "Setting sysfs $attr $policy failed" + fi +} + +_set_btrfs_sysfs_dev_policy_must_fail() +{ + local dev=$1 + local attr=$2 + shift + shift + local policy=$@ + + _set_fs_sysfs_dev_attr $dev $attr ${policy} | _filter_sysfs_error \ + | tee -a $seqres.full +} + +# Verify sysfs attribute rejects invalid input. +# Usage syntax: +# _verify_btrfs_sysfs_dev_syntax <$dev> <$attr> <$policy> [$value] +# Examples: +# _verify_btrfs_sysfs_dev_syntax $TEST_DEV read_policy pid +# _verify_btrfs_sysfs_dev_syntax $TEST_DEV read_policy round-robin 4k +# Note: +# Testcase must include +# . ./common/filter +# Prerequisite checks are kept outside this function +# to make them clear to the test case, rather than hiding +# them deep inside another function. +# _require_btrfs_sysfs_dev_policy $TEST_DEV $attr $policy +_verify_btrfs_sysfs_dev_syntax() +{ + local dev=$1 + local attr=$2 + local policy=$3 + local value=$4 + + # Test policy specified wrongly. Must fail. + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy $policy'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy t'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "' '" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'${policy} n'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'n ${policy}'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "' ${policy}'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "' ${policy} '" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'${policy} '" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr _${policy} + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr ${policy}_ + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr _${policy}_ + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr ${policy}: + # Test policy longer than 32 chars fails stable. + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr 'jfdkkkkjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjffjfjfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' + + # Test policy specified correctly. Must pass. + _set_btrfs_sysfs_dev_policy $dev $attr $policy + + # If the policy has no value return + if [[ -z $value ]]; then + return + fi + + # Test value specified wrongly. Must fail. + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy: $value'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy:$value '" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy:$value typo'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy:${value}typo'" + _set_btrfs_sysfs_dev_policy_must_fail $dev $attr "'$policy :$value'" + + # Test policy and value all specified correctly. Must pass. + _set_btrfs_sysfs_dev_policy $dev $attr $policy:$value +}
common/sysfs deleted +0 -145
145 lines not on this page · raw message
tests/btrfs/253 +1 -2
@@ -25,7 +25,6 @@ # value is in megabytes. # . ./common/preamble -. ./common/sysfs _begin_fstest auto # Parse a size string which is in the format "XX.XXMib".
@@ -226,7 +225,7 @@ alloc_size "Data" FOURTH_DATA_SIZE_MB # Force chunk allocation of system block type must fail. # echo "Force allocation of system block type must fail." -_set_sysfs_policy_must_fail ${SCRATCH_BDEV} allocation/system/force_chunk_alloc 1 +_set_btrfs_sysfs_dev_policy_must_fail ${SCRATCH_BDEV} allocation/system/force_chunk_alloc 1 # # Verification of initial allocation.
tests/btrfs/329 +2 -3
@@ -9,13 +9,12 @@ . ./common/preamble _begin_fstest auto quick -. ./common/sysfs . ./common/filter _require_test -_require_fs_sysfs_attr_policy $TEST_DEV read_policy round-robin +_require_btrfs_sysfs_dev_policy $TEST_DEV read_policy round-robin -_verify_sysfs_syntax $TEST_DEV read_policy round-robin 4096 +_verify_btrfs_sysfs_dev_syntax $TEST_DEV read_policy round-robin 4096 status=0 exit
tests/btrfs/334 +1 -2
@@ -9,13 +9,12 @@ . ./common/preamble _begin_fstest auto quick -. ./common/sysfs . ./common/filter _require_test _require_test_sysfs_dev_attr allocation/data/chunk_size -_verify_sysfs_syntax $TEST_DEV allocation/data/chunk_size 256m +_verify_btrfs_sysfs_dev_syntax $TEST_DEV allocation/data/chunk_size 256m status=0 exit
Signature · 1 line
2.56.0
PATCH v3 4/6 common/rc: add helpers for /sys/fs/$FSTYP/features/
In reply to Zorro LangMore and more test cases depend on /sys/fs/$FSTYP/features/ entries. To improve code structure and maintainability, introduce the
- _has_fs_sysfs_feature_attr
- _get_fs_sysfs_feature_attr
- _require_fs_sysfs_feature_attr
helpers.
--- common/rc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
common/rc +52 -0
@@ -5587,6 +5587,58 @@ _require_scratch_sysfs_dev_attr() _require_fs_sysfs_dev_attr $SCRATCH_DEV "$1" } +# Print the content of /sys/fs/$FSTYP/features/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/features +# +# Usage example: +# _get_fs_sysfs_feature_attr send_stream_version +_get_fs_sysfs_feature_attr() +{ + local attr=$1 + + if [ -z "$attr" ];then + _fail "Usage: _get_fs_sysfs_feature_attr <attr>" + fi + + cat /sys/fs/${FSTYP}/features/${attr} +} + +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/features/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/features +# +# Usage example: +# _has_fs_sysfs_feature_attr raid56 +_has_fs_sysfs_feature_attr() +{ + local attr=$1 + + if [ -z "$attr" ];then + _fail "Usage: _has_fs_sysfs_feature_attr <attr>" + fi + + test -e /sys/fs/${FSTYP}/features/${attr} +} + +# Require the existence of a sysfs entry at /sys/fs/$FSTYP/features/$ATTR +# +# Only one argument is needed: +# - attr: path name under /sys/fs/$FSTYP/features +# +# Usage example: +# _require_fs_sysfs_feature_attr raid56 +_require_fs_sysfs_feature_attr() +{ + local attr=$1 + + _has_fs_sysfs_feature_attr "$attr" && return + + _notrun "This test requires /sys/fs/${FSTYP}/features/${attr}" +} + # Generic test for specific filesystem feature. # Currently only implemented to test overlayfs features. _require_scratch_feature()
Signature · 1 line
2.56.0
PATCH v3 5/6 common/rc: use common helper in _require_fanotify_ioerrors for f2fs
In reply to Zorro LangThe f2fs branch of _require_fanotify_ioerrors() reads the raw /sys/fs/f2fs/features/fserror path. Use the new _get_fs_sysfs_feature_attr helper instead.
--- common/rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +2 -2
@@ -6360,8 +6360,8 @@ _require_fanotify_ioerrors() test -n "$x" && return 0 ;; f2fs) - local feat_file="/sys/fs/f2fs/features/fserror" - if [ -f "$feat_file" ] && [ "$(cat "$feat_file")" = "supported" ]; then + x="$(_get_fs_sysfs_feature_attr fserror 2>/dev/null)" + if [ "$x" = "supported" ];then return 0 fi ;;
Signature · 1 line
2.56.0
PATCH v3 6/6 fstests: replace btrfs specific helpers with common sysfs helpers
In reply to Zorro LangSwitch from btrfs specific helpers to the generic sysfs helpers across btrfs test cases, reduce code duplication.
--- common/btrfs | 37 ++----------------------------------- common/rc | 3 ++- tests/btrfs/010 | 3 ++- tests/btrfs/055 | 2 +- tests/btrfs/056 | 2 +- tests/btrfs/112 | 2 +- tests/btrfs/131 | 2 +- tests/btrfs/165 | 2 +- tests/btrfs/188 | 2 +- tests/btrfs/192 | 2 +- tests/btrfs/201 | 2 +- tests/btrfs/205 | 2 +- tests/btrfs/209 | 2 +- tests/btrfs/211 | 2 +- tests/btrfs/219 | 3 +-- tests/btrfs/231 | 2 +- tests/btrfs/285 | 1 - tests/btrfs/296 | 8 +------- tests/btrfs/304 | 4 ++-- tests/btrfs/305 | 4 ++-- tests/btrfs/306 | 4 ++-- tests/btrfs/307 | 4 ++-- tests/btrfs/308 | 4 ++-- tests/btrfs/311 | 2 +- tests/btrfs/313 | 2 +- tests/btrfs/314 | 2 +- tests/btrfs/315 | 2 +- tests/btrfs/342 | 2 +- tests/btrfs/352 | 2 +- tests/btrfs/363 | 2 +- tests/generic/098 | 2 +- tests/generic/101 | 2 +- 32 files changed, 39 insertions(+), 78 deletions(-)
common/btrfs +2 -35
@@ -100,26 +100,6 @@ _require_btrfs_mkfs_uuid_option() fi } -_require_btrfs_fs_feature() -{ - if [ -z $1 ]; then - echo "Missing feature name argument for _require_btrfs_fs_feature" - _exit 1 - fi - feat=$1 - modprobe btrfs > /dev/null 2>&1 - [ -e /sys/fs/btrfs/features/$feat ] || \ - _notrun "Feature $feat not supported by the available btrfs version" -} - -_require_btrfs_fs_sysfs() -{ - modprobe btrfs > /dev/null 2>&1 - [ -e /sys/fs/btrfs/features ] || \ - _notrun "Sysfs not supported by the available btrfs version" - -} - _require_btrfs_no_compress() { if _normalize_mount_options "$MOUNT_OPTIONS" | grep -q "compress"; then
@@ -962,18 +942,6 @@ _require_scratch_enable_simple_quota() _scratch_unmount } -_has_btrfs_sysfs_feature_attr() -{ - local feature_attr=$1 - - [ -z $feature_attr ] && \ - _fail "Missing feature name argument for _has_btrfs_sysfs_attr" - - modprobe btrfs &> /dev/null - - test -e /sys/fs/btrfs/features/$feature_attr -} - # Print the fsid and metadata uuid replaced with constant strings FSID and # METADATA_UUID. Compare temp_fsid with fsid and metadata_uuid, then echo what # it matches to or TEMP_FSID. This helps in comparing with the golden output.
@@ -983,9 +951,8 @@ _check_temp_fsid() local fsid local metadata_uuid - _require_btrfs_fs_sysfs - _require_btrfs_fs_feature temp_fsid - _require_btrfs_fs_feature metadata_uuid + _require_fs_sysfs_feature_attr temp_fsid + _require_fs_sysfs_feature_attr metadata_uuid _require_btrfs_command inspect-internal dump-super # on disk fsid
common/rc +2 -1
@@ -5634,6 +5634,7 @@ _require_fs_sysfs_feature_attr() { local attr=$1 + modprobe $FSTYP > /dev/null 2>&1 _has_fs_sysfs_feature_attr "$attr" && return _notrun "This test requires /sys/fs/${FSTYP}/features/${attr}"
@@ -6136,7 +6137,7 @@ _require_duplicate_fsid() { case "$FSTYP" in "btrfs") - _require_btrfs_fs_feature temp_fsid + _require_fs_sysfs_feature_attr temp_fsid ;; "ext4") ;;
tests/btrfs/010 +2 -1
@@ -23,7 +23,8 @@ _cleanup() . ./common/filter _require_test -_require_btrfs_fs_sysfs +_require_test_sysfs_dev_attr allocation/metadata/bytes_may_use +_require_test_sysfs_dev_attr allocation/global_rsv_reserved # Create 32k extents. All of these extents will be accounted as outstanding and # reserved.
tests/btrfs/055 +1 -1
@@ -25,7 +25,7 @@ _cleanup() _require_scratch _require_cloner -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" test_btrfs_clone_with_holes()
tests/btrfs/056 +1 -1
@@ -29,7 +29,7 @@ _cleanup() _require_scratch _require_cloner -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_dm_target flakey
tests/btrfs/112 +1 -1
@@ -15,7 +15,7 @@ _begin_fstest auto quick clone prealloc compress _require_scratch _require_cloner -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_xfs_io_command "falloc"
tests/btrfs/131 +1 -1
@@ -16,7 +16,7 @@ _begin_fstest auto quick _require_scratch _require_btrfs_command inspect-internal dump-super -_require_btrfs_fs_feature free_space_tree +_require_fs_sysfs_feature_attr free_space_tree _require_btrfs_v1_cache _scratch_mkfs >/dev/null 2>&1
tests/btrfs/165 +1 -1
@@ -34,7 +34,7 @@ rm_r_subvol() { . ./common/filter _require_scratch -_require_btrfs_fs_feature "rmdir_subvol" +_require_fs_sysfs_feature_attr "rmdir_subvol" _scratch_mkfs > /dev/null 2>&1 || _fail "mkfs failed" _scratch_mount
tests/btrfs/188 +1 -1
@@ -24,7 +24,7 @@ _cleanup() _require_test _require_scratch -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_xfs_io_command "fpunch" _require_xfs_io_command "falloc" "-k"
tests/btrfs/192 +1 -1
@@ -28,7 +28,7 @@ _cleanup() _require_command "$BLKDISCARD_PROG" blkdiscard -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_log_writes _require_scratch
tests/btrfs/201 +1 -1
@@ -27,7 +27,7 @@ _require_scratch _require_dm_target flakey _require_attrs _require_xfs_io_command "fpunch" -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_odirect
tests/btrfs/205 +1 -1
@@ -22,7 +22,7 @@ _begin_fstest auto quick clone compress prealloc _require_scratch_reflink _require_xfs_io_command "falloc" "-k" _require_command "$CHATTR_PROG" chattr -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" # We want to create a compressed inline extent representing 4K of data for file # foo1 and then clone it into a file without compression, and since compression
tests/btrfs/209 +1 -1
@@ -26,7 +26,7 @@ _cleanup() _require_scratch _require_dm_target flakey -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_xfs_io_command "sync_range"
tests/btrfs/211 +1 -1
@@ -27,7 +27,7 @@ _require_scratch _require_xfs_io_command "falloc" "-k" # fiemap needed by _count_extents() _require_xfs_io_command "fiemap" -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_dm_target flakey
tests/btrfs/219 +1 -2
@@ -47,7 +47,6 @@ loop_dev2="" _require_test _require_loop -_require_btrfs_fs_sysfs _require_btrfs_forget_or_module_loadable _fixed_by_kernel_commit 5f58d783fd78 \ "btrfs: free device in btrfs_close_devices for a single device filesystem"
@@ -91,7 +90,7 @@ _btrfs_forget_or_module_reload _mount $loop_dev1 $loop_mnt1 > /dev/null 2>&1 || \ _fail "Failed to mount the third time" -if ! _has_btrfs_sysfs_feature_attr temp_fsid; then +if ! _has_fs_sysfs_feature_attr temp_fsid; then _mount $loop_dev2 $loop_mnt2 > /dev/null 2>&1 && \ _fail "We were allowed to mount when we should have failed" fi
tests/btrfs/231 +1 -1
@@ -25,7 +25,7 @@ _cleanup() . ./common/dmflakey _require_scratch -_require_btrfs_fs_feature "no_holes" +_require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" _require_dm_target flakey
tests/btrfs/285 +0 -1
@@ -15,7 +15,6 @@ sysfs_size_classes() { } _require_scratch -_require_btrfs_fs_sysfs _require_test_sysfs_dev_attr allocation/data/size_classes f="$SCRATCH_MNT/f"
tests/btrfs/296 +1 -7
@@ -14,14 +14,8 @@ _require_scratch_dev_pool 3 _fixed_by_kernel_commit b7625f461da6 \ "btrfs: sysfs: update fs features directory asynchronously" -# We need the global features support -_require_btrfs_fs_sysfs - -global_features="/sys/fs/btrfs/features" # Make sure we have support RAID1C34 first -if [ ! -f "${global_features}/raid1c34" ]; then - _notrun "no RAID1C34 support" -fi +_require_fs_sysfs_feature_attr raid1c34 _scratch_dev_pool_get 3
tests/btrfs/304 +2 -2
@@ -16,8 +16,8 @@ _begin_fstest auto quick raid remount volume raid-stripe-tree _require_btrfs_command inspect-internal dump-tree _require_btrfs_mkfs_feature "raid-stripe-tree" _require_scratch_dev_pool 4 -_require_btrfs_fs_feature "raid_stripe_tree" -_require_btrfs_fs_feature "free_space_tree" +_require_fs_sysfs_feature_attr "raid_stripe_tree" +_require_fs_sysfs_feature_attr "free_space_tree" _require_btrfs_free_space_tree _require_btrfs_no_compress _require_btrfs_support_sectorsize 4096
tests/btrfs/305 +2 -2
@@ -17,8 +17,8 @@ _begin_fstest auto quick raid remount volume raid-stripe-tree _require_btrfs_command inspect-internal dump-tree _require_btrfs_mkfs_feature "raid-stripe-tree" _require_scratch_dev_pool 4 -_require_btrfs_fs_feature "raid_stripe_tree" -_require_btrfs_fs_feature "free_space_tree" +_require_fs_sysfs_feature_attr "raid_stripe_tree" +_require_fs_sysfs_feature_attr "free_space_tree" _require_btrfs_free_space_tree _require_btrfs_no_compress _require_btrfs_support_sectorsize 4096
tests/btrfs/306 +2 -2
@@ -17,8 +17,8 @@ _begin_fstest auto quick raid remount volume raid-stripe-tree _require_btrfs_command inspect-internal dump-tree _require_btrfs_mkfs_feature "raid-stripe-tree" _require_scratch_dev_pool 4 -_require_btrfs_fs_feature "raid_stripe_tree" -_require_btrfs_fs_feature "free_space_tree" +_require_fs_sysfs_feature_attr "raid_stripe_tree" +_require_fs_sysfs_feature_attr "free_space_tree" _require_btrfs_free_space_tree _require_btrfs_no_compress _require_btrfs_support_sectorsize 4096
tests/btrfs/307 +2 -2
@@ -16,8 +16,8 @@ _begin_fstest auto quick raid remount volume raid-stripe-tree _require_btrfs_command inspect-internal dump-tree _require_btrfs_mkfs_feature "raid-stripe-tree" _require_scratch_dev_pool 4 -_require_btrfs_fs_feature "raid_stripe_tree" -_require_btrfs_fs_feature "free_space_tree" +_require_fs_sysfs_feature_attr "raid_stripe_tree" +_require_fs_sysfs_feature_attr "free_space_tree" _require_btrfs_free_space_tree _require_btrfs_no_compress
tests/btrfs/308 +2 -2
@@ -17,8 +17,8 @@ _begin_fstest auto quick raid remount volume raid-stripe-tree _require_btrfs_command inspect-internal dump-tree _require_btrfs_mkfs_feature "raid-stripe-tree" _require_scratch_dev_pool 4 -_require_btrfs_fs_feature "raid_stripe_tree" -_require_btrfs_fs_feature "free_space_tree" +_require_fs_sysfs_feature_attr "raid_stripe_tree" +_require_fs_sysfs_feature_attr "free_space_tree" _require_btrfs_free_space_tree _require_btrfs_no_compress _require_btrfs_no_nodatacow
tests/btrfs/311 +1 -1
@@ -24,7 +24,7 @@ _cleanup() _require_cp_reflink _require_scratch -_require_btrfs_fs_feature temp_fsid +_require_fs_sysfs_feature_attr temp_fsid mnt1=$TEST_DIR/$seq/mnt1 mkdir -p $mnt1
tests/btrfs/313 +1 -1
@@ -22,7 +22,7 @@ _cleanup() _require_cp_reflink _require_scratch_dev_pool 2 -_require_btrfs_fs_feature temp_fsid +_require_fs_sysfs_feature_attr temp_fsid _scratch_dev_pool_get 2
tests/btrfs/314 +1 -1
@@ -22,7 +22,7 @@ _cleanup() . ./common/filter.btrfs _require_scratch_dev_pool 2 -_require_btrfs_fs_feature temp_fsid +_require_fs_sysfs_feature_attr temp_fsid _scratch_dev_pool_get 2
tests/btrfs/315 +1 -1
@@ -21,7 +21,7 @@ _cleanup() . ./common/filter _require_scratch_dev_pool 3 -_require_btrfs_fs_feature temp_fsid +_require_fs_sysfs_feature_attr temp_fsid _scratch_dev_pool_get 3
tests/btrfs/342 +1 -1
@@ -13,7 +13,7 @@ _begin_fstest auto quick _require_scratch _require_btrfs_command inspect-internal dump-super -_require_btrfs_fs_feature free_space_tree +_require_fs_sysfs_feature_attr free_space_tree # The block-group-tree feature relies on v2 cache, thus it doesn't support # "nospace_cache" mount option.
tests/btrfs/352 +1 -1
@@ -14,7 +14,7 @@ _begin_fstest auto quick remount _fixed_by_kernel_commit XXXXXXXXXXXX \ "btrfs: fix leaking BTRFS_FS_STATE_REMOUNTING flag" -_require_btrfs_fs_feature supported_rescue_options +_require_fs_sysfs_feature_attr supported_rescue_options if ! grep -q "ignorebadroots" "/sys/fs/btrfs/features/supported_rescue_options"; then _notrun "\"rescue=ignorebadroots\" mount option not supported"
tests/btrfs/363 +1 -1
@@ -24,7 +24,7 @@ _cleanup() . ./common/dmflakey _require_btrfs_mkfs_feature "raid-stripe-tree" -_require_btrfs_fs_feature "raid_stripe_tree" +_require_fs_sysfs_feature_attr "raid_stripe_tree" _require_scratch _require_dm_target flakey
tests/generic/098 +1 -1
@@ -24,7 +24,7 @@ _require_scratch # feature is enabled (introduced in kernel 3.14). So enable the feature if the # fs being tested is btrfs. if [ $FSTYP == "btrfs" ]; then - _require_btrfs_fs_feature "no_holes" + _require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" MKFS_OPTIONS="$MKFS_OPTIONS -O no-holes" fi
tests/generic/101 +1 -1
@@ -32,7 +32,7 @@ _require_dm_target flakey # feature is enabled (introduced in kernel 3.14). So enable the feature if the # fs being tested is btrfs. if [ $FSTYP == "btrfs" ]; then - _require_btrfs_fs_feature "no_holes" + _require_fs_sysfs_feature_attr "no_holes" _require_btrfs_mkfs_feature "no-holes" MKFS_OPTIONS="$MKFS_OPTIONS -O no-holes" fi
Signature · 1 line
2.56.0