]> git.ipfire.org Git - thirdparty/util-linux.git/commit
fstrim: prefer earlier mounted filesystems
authorAlex Ivanov <yourbestfriend@openmailbox.org>
Thu, 15 Jun 2017 08:26:25 +0000 (11:26 +0300)
committerKarel Zak <kzak@redhat.com>
Fri, 23 Jun 2017 13:20:51 +0000 (15:20 +0200)
commitcf9a3db0a84c1baee08e92db50e88c22ebc21f5d
tree5fea5d18a48b778bad49b9a8959865f669170e51
parent122e060d282105165b1a16af0c032fdee1f58d9c
fstrim: prefer earlier mounted filesystems

fstrim --all is broken in a way that if there is a bind mount for some filesystem,
that filesystem will not be trimmed. This is especially critical for e.g.
NixOS distribution, which needs bind mount within root fs:
https://github.com/NixOS/nixos/blob/master/modules/system/boot/stage-2-init.sh#L55

Currently for a given filesystem during "de-duplication by source and root" phase,
an early mounted fs path is filtered (e.g. "/"), while later mounted fs path is kept
(e.g. "/nix/store") though anyway discarded later (since it's an overlaying mount).
This leads to skipped trimming.

So flip this behaviour. Should also help for other types of overlaying mounts.

Reference:
https://github.com/karelzak/util-linux/blob/stable/v2.29/libmount/src/tab.c#L715

Signed-off-by: Alex Ivanov <yourbestfriend@openmailbox.org>
sys-utils/fstrim.c