Skip to content

Conversation

@N-R-K
Copy link
Contributor

@N-R-K N-R-K commented Mar 22, 2025

this turns mouninfo into a multicall binary which can also do
parallel unmounting. most mountinfo code is unchanged; only
notable change is find_mounts() now returns the number of mounts
found and also takes the "process" function as an argument; so
that is_mounted() can be implemented on top of it.

rc_unmount mostly follows the logic of previous do_unmount. some
notable changes:

  • rc_unmount is "lazy" when it comes to retrying failed
    unmounts. it will greedily keep running unmount as long as it
    can before it looks at the "waiting" queue.
  • rc_unmount will check if the mountpoint is still mounted or
    not when umount returns non-zero exit code. this is due to the
    fact that multiple umount calls might race to unmount a shared
    mount. so if umount fails but the mountpoint is no longer
    mounted, we assume success.
  • do_unmount used to fail if fuser did not find any pids using
    the mount. rc_unmount tries one more time; the rationale being
    that there's a gap between the umount call and the fuser call,
    and so whatever was using the mount before might have stopped
    using it now and so it's worth another attempt.

Closes: #662

Copy link
Contributor Author

@N-R-K N-R-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on: #810

@N-R-K N-R-K mentioned this pull request Mar 22, 2025
@N-R-K N-R-K force-pushed the rc_unmount branch 3 times, most recently from 263d4d6 to b586bf6 Compare March 26, 2025 12:42
@N-R-K N-R-K marked this pull request as ready for review March 26, 2025 12:42
@N-R-K N-R-K force-pushed the rc_unmount branch 2 times, most recently from d3c6a6c to e52d16f Compare April 10, 2025 01:12
res = do_exec(&args);
if (res.pid > 0)
rc_waitpid(res.pid);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first fuser command to query the pids has a timeout and is async, this one to send the signals on the other hand is synchronous and has no timeout (copied from the rc-mount.sh script).

But this doesn't seem to make sense (?) If we anticipate fuser might take a while then shouldn't we be timing out both of the calls rather than just one of them?

Also the only reason we're doing 2 commands (query pids + send signal) is to avoid killing ourselves if we happen to be using that mount. If we can figure out whether we're using it or not beforehand then it can be changed into a single fuser call which directly sends the signal (async, with timeout).

openrc-run has a (hardcoded) 60 seconds timeout, it a service
fails to start/stop within that time, it will be SIGKILL-ed. so
a default 60 seconds fuser_timeout is kind of bad. change it to
20seconds which is somewhat more sensible.
this turns mouninfo into a multicall binary which can also do
parallel unmounting. most mountinfo code is unchanged; only
notable change is find_mounts() now returns the number of mounts
found and also takes the "process" function as an argument; so
that is_mounted() can be implemented on top of it.

do_unmount mostly follows the logic of previous code. some
notable changes:

- do_unmount is now "lazy" when it comes to retrying failed
  unmounts. it will greedily keep running unmount as long as it
  can before it looks at the "waiting" queue.
- it will check if the mountpoint is still mounted or not when
  umount returns non-zero exit code. this is due to the fact that
  multiple umount calls might race to unmount a shared mount. so
  if umount fails _but_ the mountpoint is no longer mounted, we
  assume success.
- do_unmount used to fail if fuser did not find any pids using
  the mount. the new code tries one more time; the rationale being
  that there's a gap between the umount call and the fuser call,
  and so whatever was using the mount before might have stopped
  using it now and so it's worth another attempt.

Fixes: OpenRC#662
Closes: OpenRC#698
@navi-desu
Copy link
Member

rebased and renamed it back to do_unmount, and removed the manpage entry, i'd like to keep it internal for now, like it used to be

@navi-desu navi-desu merged commit 303bc52 into OpenRC:master Nov 12, 2025
4 of 6 checks passed
@N-R-K N-R-K deleted the rc_unmount branch November 13, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parallezing do_unmount

2 participants