-
Bug
-
Resolution: Not a Bug
-
Undefined
-
None
-
rhel-10.1
-
None
-
Yes
-
None
-
rhel-fs
-
4
-
False
-
False
-
-
None
-
None
-
None
-
None
-
Unspecified
-
Unspecified
-
Unspecified
-
None
Description of problem:
fstrim on fedora images does not trim as much as expected on rhel10
Version-Release number of selected component (if applicable):
libguestfs-1.55.8-1.el10.x86_64
kernel-6.12.0-74.el10.x86_64
How reproducible:
100%
Steps:
1. Create and mount an XFS filesystem, in this case 5GB in size.
2. Run fstrim -v /mnt
# fstrim -v /mnt /mnt: 5 GiB (5365563392 bytes) trimmed
The problem here is that the amount of trimming reported is all wrong. The kernel now just returns the full size of the filesystem, giving us no useful information on whether or not the filesystem attempted to trim and how many blocks it was able to discard.
This is caused because of the following upstream commit:
commit 410e8a18f8e9311c6bf29ae47f32ad46f0219569 Author: Darrick J. Wong <djwong@kernel.org> Date: Thu Aug 22 16:59:48 2024 -0700 xfs: don't bother reporting blocks trimmed via FITRIM Don't bother reporting the number of bytes that we "trimmed" because the underlying storage isn't required to do anything(!) and failed discard IOs aren't reported to the caller anyway. It's not like userspace can use the reported value for anything useful like adjusting the offset parameter of the next call, and it's not like anyone ever wrote a manpage about FITRIM's out parameters. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Tested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Note this behaviour is a regression in XFS, and it's also different from how ext4, vfat and btrfs work.
It's also a userspace regression. The util-linux fstrim command uses the result of ioctl(FITRIM) and has expectations about how it behaves: https://github.com/util-linux/util-linux/blob/0e4f4f6f9e0c165b04c5663091548a342cc2f2ec/sys-utils/fstrim.c#L144
Actual result:
As above description
Expect result:
Fix the bug
Additional info
Can't reproduce the bug with libguestfs-1.54.0-7.el9.x86_64 and kernel-5.14.0-580.el9.x86_64
# virt-v2v -i disk fedora-40.qcow2 -o null -vx |& grep trimmed /sysroot/: 3.9 GiB (4197629952 bytes) trimmed /sysroot/: 3.9 GiB (4197629952 bytes) trimmed /sysroot/: 718.2 MiB (753123328 bytes) trimmed /sysroot/: 718.2 MiB (753123328 bytes) trimmed # virt-v2v -i disk fedora-41.img -o null -vx |& grep trimmed /sysroot/: 3.8 GiB (4093538304 bytes) trimmed /sysroot/: 3.8 GiB (4093538304 bytes) trimmed /sysroot/: 689.2 MiB (722714624 bytes) trimmed /sysroot/: 250.2 MiB (262385664 bytes) trimmed