Hello Sebastian Hahn,

Thanks for your bug report.

On Thu, Jun 15, 2017 at 08:13:24AM +0200, Sebastian Hahn wrote:
> Package: util-linux
> Version: 2.29.2-1
> Severity: normal
> 
> Dear Maintainer,
> 
> I expected "fstrim -a -v" to trim all mounted filesystems, but this happens
> reproducibly (amount of bytes trimmed is different each time, of course):
> 
>   # fstrim -a -v
>   /boot: 313.3 MiB (328534016 bytes) trimmed
> 
>   # fstrim -v /
>   /: 52.9 GiB (56756269056 bytes) trimmed
> 
> I don't see why / would not be included by -a, as I would expect fstrim to
> either reject trimming / due to an error or include it when trimming. Here,
> /boot is an ext2 file system while / is ext4. If any other information might 
> be
> helpful in debugging this, I'd be happy to assist.

As can be seen in the while loop at:
http://sources.debian.net/src/util-linux/2.29.2-1/sys-utils/fstrim.c/#L205
... the code tries to iterate over all mounted filesystems and then
skip over ones that should not be considered (pseudo filesystems,
not having discard support, etc).

Unfortunately there's not much debug output lines in that part of the code
so you might have to hack it to output exactly why it decides to skip
things for you. Possibly the output from this command might be useful:
LIBMOUNT_DEBUG=0xffff fstrim -a -v ; echo "Exit code: $?"

Suggestions on how to most easily build your own modified version:
cd /tmp
apt-get source util-linux
cd util-linux-*
./configure
make fstrim
# hack sys-utils/fstrim.c
make fstrim
# rinse, repeat.

You could for example move the following line up and down the while loop
to see exactly at which condition filters out the filesystem you think
should be included:
printf("%s %d: tgt=%s\n", __FILE__, __LINE__, tgt);

HTH.

Regards,
Andreas Henriksson

Reply via email to