]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
ext4/307: allocate donor file size dynamically
authorcaokewu <caokewu1@uniontech.com>
Mon, 19 Jan 2026 05:54:11 +0000 (13:54 +0800)
committerZorro Lang <zlang@kernel.org>
Sun, 25 Jan 2026 16:05:29 +0000 (00:05 +0800)
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 <caokewu1@uniontech.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/ext4/307

index 1f0e42ca263811d28648ccf71a47bfdaa3cd96ff..4807334778a959b3239894afee9b23c6abf5af73 100755 (executable)
@@ -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