mount: check right before invoking /bin/umount if it makes sense
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Mar 2023 18:05:30 +0000 (19:05 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 May 2023 08:57:16 +0000 (10:57 +0200)
commit1483892a421ca34bc841a8e8b1f385744c0407ed
tree7807d6e4ec6c85e23182564f6bbb001a1b19d8a3
parent2fdc274c66b6735114ddc00df7f537bcc5372e41
mount: check right before invoking /bin/umount if it makes sense

Notifications from /proc/self/mountinfo are async, so if we stop a
service (and while doing so get rid of the credentials mount point of
it), then it will take a while until the notification reaches us and we
actually scan the table again. In particular as we nowadays ratelimit
notifications on the table, since it's so inefficient. And as I learnt
the ratelimiting is actually quite regularly hit during shutdown, where
a flurry of umount events are genreated. Hence, let's check if a mount
point is actually a mountpoint before trying to unmount it. And if it
isn't let's wait for the notification to come in.

(This race might be triggred not just by us on ourselves btw: there are
other daemons that unmount stuff when stopping where the race also
exists, but might simply be harder to trigger: if during service
shutdown these services remove some mount then they might collide with
us doing the same. After all, we have the rule to unmount everything
mounted automatically for you during shutdown.)

In the long run we should also start making us of this when it becomes
available: https://github.com/util-linux/util-linux/issues/2132 With
that we can make issues like this go away entirely from our side of
things at least.

Fixes: #25527
src/basic/unit-def.c
src/basic/unit-def.h
src/core/mount.c