From: caokewu Date: Mon, 19 Jan 2026 05:54:11 +0000 (+0800) Subject: ext4/307: allocate donor file size dynamically X-Git-Tag: v2026.01.27~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=42c2ccaf370065c15d2f26e99f502a62c1a7c7f7;p=xfstests-dev.git ext4/307: allocate donor file size dynamically Currently, the donor file size is hardcoded to 250M. fsstress can generate more data than this limit, which causes the `e4compact` helper to crash. Specifically, `e4compact.c:do_defrag_range()` contains the following assertion: assert(donor->length >= len); If the donor file is not large enough to accommodate the data being compacted, this assertion fails (or validation logic rejects it), causing the test to fail unexpectedly with an abort or error. Additionally, the previous 'usage' calculation used `du -sch`, which outputs human-readable sizes (e.g., "1.5M"). xfs_io's falloc command does not support decimal values in length arguments, leading to syntax errors during file allocation. Fix this by: 1. Using `du -sm` to calcuate the required size in integer MB (rounding up), avoiding decimal issues. 2. Allocating the donor file using this calculated `usage` size instead of the fixed 250M limit, ensuring it is always large enough for the operation. Signed-off-by: caokewu Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- diff --git a/tests/ext4/307 b/tests/ext4/307 index 1f0e42ca..48073347 100755 --- a/tests/ext4/307 +++ b/tests/ext4/307 @@ -24,9 +24,10 @@ _workout() _run_fsstress $args find $out -type f > $out.list cat $out.list | xargs md5sum > $out.md5sum - usage=`du -sch $out | tail -n1 | gawk '{ print $1 }'` + # Use -m to get integer MB size to avoid decimals (e.g. 1.5M) which xfs_io rejects + usage=$(du -sm $out | awk '{print $1}') echo "Allocate donor file" - $XFS_IO_PROG -c "falloc 0 250M" -f $SCRATCH_MNT/donor | _filter_xfs_io + $XFS_IO_PROG -c "falloc 0 ${usage}m" -f $SCRATCH_MNT/donor | _filter_xfs_io echo "Perform compacting" cat $out.list | run_check $here/src/e4compact \ -i -v -f $SCRATCH_MNT/donor >> $seqres.full 2>&1