]> 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>
Thu, 15 Jun 2017 09:45:35 +0000 (11:45 +0200)
commit155d48f590a50bb5dc265162ff2f9a971daed543
tree747cbcb46cdb12dbebbd5b9099a107acda10fa65
parent2a67d912c642765b63cdc41b07515e30e77839ff
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