]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commit
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)
commit42c2ccaf370065c15d2f26e99f502a62c1a7c7f7
tree3cb706d210be8f855ae83c1174f63d61d200722b
parent725b08a6d61ad5f860198f8c67e09d34b9563954
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 <caokewu1@uniontech.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/ext4/307