btrfs: Add new test for setting the chunk size.
PATCH v8 1/1 btrfs: Add new test for setting the chunk size.
Add new testcase for testing the new btrfs sysfs knob to change the chunk size. The new knob uses /sys/fs/btrfs/<UUID>/allocation/<block type>/chunk_size.
The test case implements three different cases:
- Test allocation with the default chunk size
- Test allocation after increasing the chunk size
- Test allocation when the free space is smaller than the chunk size.
Note: this test needs to force the allocation of space. It uses the /sys/fs/btrfs/<UUID>/allocation/<block type>/force_chunk_alloc knob.
Testing:
The test has been run with volumes of different sizes.
---
V8: - fix whitespace issues
- use _real_dev helper
- change comment
V7: - fixed whitespace issues
- removed test_file variable (no longer needed)
- removed _require_btrfs_fs_sysfs (check for filesystem attributes is sufficient)
- Added comment for 10G requirement
V6: - renamed test case from 248 to 251
- use _require_fs_sysfs
- use device name in _get_fs_sysfs_attr and _set_fs_sysfs_attr
V5: - Modify _get_fs_sysfs_attr and _set_fs_sysfs_attr to support btrfs
- Use _get_fs_sysfs_attr and _set_fs_sysfs_attr
- Remove _get_btrfs_sysfs_attr and _set_btrfs_fsysfs_attr
- Rename local functions to not use "_"
- use $AWK_PROG and $BTRFS_UTIL_PROG
- remove call to _require_scratch_size
- fixes for coding convention
- replace fail calls with echo
V4: - fixed indentation in common/btrfs
- Removed UUID code, which is no longer necessary (provided by helper function)
- Used new helper _get_btrfs_sysfs_attr
- Direct output to /dev/null
V3: - removed tests for system block type.
- added failure case for system block type.
- renamed stripe_size to chunk_size
V2: - added new functions to common/btrfs and use them in the new test
- _require_btrfs_sysfs_attr - Make sure btrfs supports a sysfs setting
- _get_btrfs_sysfs_attr - Read sysfs value
- _set_btrfs_sysfs_attr - Write sysfs value
- create file system of required size with _scratch_mkfs_sized
- use shortened error message
- Remove last logging message
--- common/rc | 27 ++++- tests/btrfs/251 | 273 ++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/251.out | 10 ++ 3 files changed, 307 insertions(+), 3 deletions(-) create mode 100755 tests/btrfs/251 create mode 100644 tests/btrfs/251.out
common/rc +24 -3
@@ -4401,7 +4401,14 @@ run_fsx() _require_fs_sysfs() { local attr=$1 - local dname=$(_short_dev $TEST_DEV) + local dname + + case "$FSTYP" in + btrfs) + dname=$(findmnt -n -o UUID $TEST_DEV) ;; + *) + dname=$(_short_dev $TEST_DEV) ;; + esac if [ -z "$attr" -o -z "$dname" ];then _fail "Usage: _require_fs_sysfs <sysfs_attr_path>"
@@ -4439,7 +4446,14 @@ _set_fs_sysfs_attr() _fail "Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>" fi - local dname=$(_short_dev $dev) + local dname + case "$FSTYP" in + btrfs) + dname=$(findmnt -n -o UUID ${dev}) ;; + *) + dname=$(_short_dev $dev) ;; + esac + echo "$content" > /sys/fs/${FSTYP}/${dname}/${attr} }
@@ -4460,7 +4474,14 @@ _get_fs_sysfs_attr() _fail "Usage: _get_fs_sysfs_attr <mounted_device> <attr>" fi - local dname=$(_short_dev $dev) + local dname + case "$FSTYP" in + btrfs) + dname=$(findmnt -n -o UUID ${dev}) ;; + *) + dname=$(_short_dev $dev) ;; + esac + cat /sys/fs/${FSTYP}/${dname}/${attr} }
tests/btrfs/251 new file +273 -0
273 lines not on this page · raw message
tests/btrfs/251.out new file +10 -0
@@ -0,0 +1,10 @@ +QA output created by 251 +Capture default chunk sizes. +First allocation. +Second allocation. +Calculate request size so last memory allocation cannot be completely fullfilled. +Third allocation. +Force allocation of system block type must fail. +Verify first allocation. +Verify second allocation. +Verify third allocation.
base-commit: 9f8f0e4d5ae00990bac05fbd69a882255bf7bf9f
Signature · 1 line
2.30.2